mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 21:22:46 +00:00 
			
		
		
		
	 221f18f72e
			
		
	
	
		221f18f72e
		
	
	
	
	
		
			
			This test proves the ability of TransformStream to execute caller supplied code in the flush callback, and have access to TransformStreamDefaultController.
		
			
				
	
	
		
			25 lines
		
	
	
	
		
			698 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			25 lines
		
	
	
	
		
			698 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
| <script src="../include.js"></script>
 | |
| <script>
 | |
|   test(() => {
 | |
|     const {writable, readable} = new TransformStream({
 | |
|       transform(chunk, controller) {
 | |
|         controller.enqueue(chunk.toUpperCase());
 | |
|       },
 | |
|       flush(controller) {
 | |
|           controller.enqueue("Enqueued in flush, this the last chunk that will be processed.");
 | |
|       }
 | |
|     });
 | |
|     const writer = writable.getWriter();
 | |
|     writer.write("Hello, world!");
 | |
|     writer.close();
 | |
|     const reader = readable.getReader();
 | |
|     reader.read().then(function processText({done, value}) {
 | |
|       println(`Done: ${done}`);
 | |
|       if (done)
 | |
|         return;
 | |
| 
 | |
|       println(value);
 | |
|       reader.read().then(processText);
 | |
|     });
 | |
|   });
 | |
| </script>
 |