Back to articles
Releasing @hsblabs/web-stream-extras: small utilities for WHATWG byte stream pipelines

Releasing @hsblabs/web-stream-extras: small utilities for WHATWG byte stream pipelines

via Dev.to Webdevmktbsh

I published @hsblabs/web-stream-extras . It started as internal plumbing I kept copy-pasting across projects. Enough utility collected around ReadableStream<Uint8Array> that it made sense to package it properly. npm install @hsblabs/web-stream-extras Node.js ≥22 and modern browsers. No runtime dependencies. What's in the root package The root export handles the everyday byte stream operations. import { readableFromChunks , readAllBytes , stringToBinary , binaryToString , } from " @hsblabs/web-stream-extras " ; const stream = readableFromChunks ([ stringToBinary ( " hello " ), stringToBinary ( " world " ), ]); const result = await readAllBytes ( stream ); console . log ( binaryToString ( result )); // "hello world" readableFromChunks wraps an array of Uint8Array chunks into a proper ReadableStream . readAllBytes collects everything from a stream into a single Uint8Array . The string and buffer conversion helpers — stringToBinary , binaryToString , toU8Array , toArrayBuffer , concatU8Arr

Continue reading on Dev.to Webdev

Opens in a new tab

Read Full Article
1 views

Related Articles