Web APIs
TransformStream
Creates a paired writable/readable stream with configurable transformation hooks.
Formal Syntax & Structure
javascript syntaxjavascript
new TransformStream(transformer)Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| transformer | object | Optional transformation hooks. |
Return Value
TransformStream
Creates a paired writable/readable stream with configurable transformation hooks.
Working Example
Example Snippetjavascript
(async () => {const src=new ReadableStream({start(c){c.enqueue(2);c.enqueue(3);c.close();}});const t=new TransformStream({transform(n,c){c.enqueue(n*2);}});const r=src.pipeThrough(t).getReader();const a=await r.read(),b=await r.read(),d=await r.read();r.releaseLock();console.log(a.value,b.value,d.done);})()