Web APIs
TextDecoder streaming option
Preserves decoder state between chunks until the final non-streaming decode.
Formal Syntax & Structure
javascript syntaxjavascript
decoder.decode(chunk, {stream: true})Parameters & Attributes
| Name | Type | Description |
|---|---|---|
| chunk | BufferSource | Encoded 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());})()