API · Formats
encode()
Convert byte-like input chunks into a continuous base64 text stream.
Signature
encode(encoding: 'base64'): Exstream<string, C> Example
const encoded = await exstream(byteChunks).encode('base64').toPromise()
const base64 = encoded.join('') Parameters
encodingNo other output encoding is currently implemented.
Input and output
Accepted data includes strings, Uint8Array/Buffer, ArrayBuffer, arrays, and array-like byte objects supported by the runtime. The encoder carries incomplete three-byte groups across inputs, so joining output chunks produces the same base64 as encoding the concatenated bytes. It may emit empty string chunks, including its final flush; consumers should concatenate or stream them unchanged.
Order and context are preserved, buffering is constant, and existing record errors pass through.
Errors
Unsupported encoding throws immediately. A value that cannot be converted to bytes becomes a record error naming its JavaScript type; processing can continue after an error policy handles it.
Forms
stream.encode('base64')
exstream.pipeline().encode('base64')
exstream.encode('base64', stream)
stream.through(exstream.encode('base64'))