Web APIs
ReadableStream.tee()
Split a stream into two readable branches. The original becomes locked; a slower branch may buffer substantial data, so bound inputs when using tee. Example console output: ["hi","hi"].
Formal Syntax & Structure
javascript syntaxjavascript
stream.tee()Return Value
ReadableStream[]
Two readable branches.
Working Example
Example Snippetjavascript
(async () => {const s=new Blob(["hi"]).stream(); const [a,b]=s.tee(); const results=await Promise.all([new Response(a).text(),new Response(b).text()]); console.log(JSON.stringify(results));})()