Web APIs
TransformStreamDefaultController.prototype.enqueue()
Emits a chunk onto the transform readable side; a transform can emit zero or multiple chunks.
Formal Syntax & Structure
javascript syntaxjavascript
controller.enqueue(chunk)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| chunk | any | Output chunk. |
Return Value
undefined
Emits a chunk onto the transform readable side; a transform can emit zero or multiple chunks.
Working Example
Example Snippetjavascript
(async () => {const s=new ReadableStream({start(c){c.enqueue(0);c.enqueue(4);c.close();}});const t=new TransformStream({transform(n,c){if(n>0)c.enqueue(n);}});const r=s.pipeThrough(t).getReader();console.log((await r.read()).value,(await r.read()).done);r.releaseLock();})()