LogoPear Docs

bare-string-decoder

`string_decoder` shim for Bare

stable

bare-string-decoderstring_decoder shim for Bare.

npm i bare-string-decoder

API

StringDecoder

new StringDecoder(encoding: BufferEncoding)

Source

Create a StringDecoder for the given encoding.

Parameters

ParameterTypeDefaultDescription
encodingBufferEncodingThe character encoding the bytes are decoded from (a BufferEncoding such as 'utf8' or 'utf16le').

end(buffer: string | Buffer): string

Source

Decode any remaining buffered bytes together with buffer and return the resulting string, flushing incomplete sequences.

Parameters

ParameterTypeDefaultDescription
bufferstring | BufferA final chunk of bytes to decode together with any bytes buffered from previous calls.

Returns string — The decoded string, including any bytes buffered from previous calls.

write(buffer: string | Buffer): string

Source

Decode buffer and return the resulting string, retaining any trailing incomplete multi-byte sequence to be completed by a subsequent call.

Parameters

ParameterTypeDefaultDescription
bufferstring | BufferThe bytes to decode.

Returns string — The decoded string, excluding any trailing incomplete multi-byte sequence, which is buffered for the next call.

See also

On this page