1 // META: title=Encoding API: TextDecoder decode() optional arguments
4 const decoder = new TextDecoder();
6 // Just passing nothing.
8 decoder.decode(undefined), '',
9 'Undefined as first arg should decode to empty string');
11 // Flushing an incomplete sequence.
12 decoder.decode(new Uint8Array([0xc9]), {stream: true});
14 decoder.decode(undefined), '\uFFFD',
15 'Undefined as first arg should flush the stream');
17 }, 'TextDecoder decode() with explicit undefined');
20 const decoder = new TextDecoder();
22 // Just passing nothing.
24 decoder.decode(undefined, undefined), '',
25 'Undefined as first arg should decode to empty string');
27 // Flushing an incomplete sequence.
28 decoder.decode(new Uint8Array([0xc9]), {stream: true});
30 decoder.decode(undefined, undefined), '\uFFFD',
31 'Undefined as first arg should flush the stream');
33 }, 'TextDecoder decode() with undefined and undefined');
36 const decoder = new TextDecoder();
38 // Just passing nothing.
40 decoder.decode(undefined, {}), '',
41 'Undefined as first arg should decode to empty string');
43 // Flushing an incomplete sequence.
44 decoder.decode(new Uint8Array([0xc9]), {stream: true});
46 decoder.decode(undefined, {}), '\uFFFD',
47 'Undefined as first arg should flush the stream');
49 }, 'TextDecoder decode() with undefined and options');