Web APIs

TextDecoder streaming option

Try the free JavaScript compiler

Preserves decoder state between chunks until the final non-streaming decode.

Formal Syntax & Structure

javascript syntaxjavascript
decoder.decode(chunk, {stream: true})

Parameters & Attributes

NameTypeDescription
chunkBufferSourceEncoded bytes.

Return Value

string

Preserves decoder state between chunks until the final non-streaming decode.

Working Example

Example Snippetjavascript
(async () => {const d=new TextDecoder();const a=d.decode(new Uint8Array([195]),{stream:true});const b=d.decode(new Uint8Array([169]),{stream:true});console.log(JSON.stringify(a),b+d.decode());})()
JavaScript Reference