Converts a string to a ReadableStream of Uint8Array chunks.
Encodes the string as UTF-8 and creates a stream with a single chunk. Useful for creating request bodies or piping string data through streams.
The string to convert to a stream
Optional TextEncoder (uses singleton if not provided)
ReadableStream containing the encoded string
const stream = string2stream('Hello, World!');await stream.pipeTo(writable); Copy
const stream = string2stream('Hello, World!');await stream.pipeTo(writable);
Converts a string to a ReadableStream of Uint8Array chunks.
Encodes the string as UTF-8 and creates a stream with a single chunk. Useful for creating request bodies or piping string data through streams.