mirror of
				https://github.com/RGBCube/serenity
				synced 2025-10-31 16:42:44 +00:00 
			
		
		
		
	 74fdf59941
			
		
	
	
		74fdf59941
		
	
	
	
	
		
			
			This test proves the ability of TransformStream to execute to execute caller supplied code in the transform callback that can transform incoming chunks, and have access to TransformStreamDefaultController.
		
			
				
	
	
		
			22 lines
		
	
	
	
		
			655 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
			
		
		
	
	
			22 lines
		
	
	
	
		
			655 B
		
	
	
	
		
			HTML
		
	
	
	
	
	
| <script src="../include.js"></script>
 | |
| <script>
 | |
|     test(() => {
 | |
|         const {writable, readable} = new TransformStream({
 | |
|             transform(chunk, controller) {
 | |
|                 controller.enqueue(chunk.toUpperCase());
 | |
|             }
 | |
|         });
 | |
|         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>
 |