Web APIs

ReadableStreamDefaultReader.prototype.read()

Try the free JavaScript compiler

Returns a promise for the next chunk or completion; errors reject the promise.

Formal Syntax & Structure

javascript syntaxjavascript
reader.read()

Return Value

Promise<object>

Returns a promise for the next chunk or completion; errors reject the promise.

Working Example

Example Snippetjavascript
(async () => {const s=new ReadableStream({start(c){c.enqueue("a");c.close();}});const r=s.getReader();console.log((await r.read()).value,(await r.read()).done);r.releaseLock();})()
JavaScript Reference