Skip to content

What's the correct use of {stream: true} option for Textdecoder.decode #184

Closed
@lin7sh

Description

@lin7sh

Just came cross there is a second option can be passed to decoder, My first thought about it is a buffer, so I can do

 decoder.decode( new Uint8ArrayBuffer([97, 98, 99]), { stream: true })

and append another buffer

 decoder.decode( new Uint8ArrayBuffer([100,  101 , 102]), { stream: true })

and finally get me a string back which include the 2 parts

 const finalString = decoder.decode( new Uint8ArrayBuffer([]) , { stream: false })

but it isn't the case
the first two expression return "abc" and "def" the third give me empty, just like them without the stream option. and I've tried TextDecoder in Nodejs, it have the same behaviour

Can anyone can tell me how to use it correctly?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions