it-length-prefixed
Streaming length prefixed buffers with async iterables
About
Encode/decode streams of bytes with length-prefixes.
Example
import { pipe } from 'it-pipe'
import * as lp from 'it-length-prefixed'
const encoded = []
await pipe(
[uint8ArrayFromString('hello world')],
(source) => lp.encode(source),
async source => {
for await (const chunk of source) {
encoded.push(chunk.slice())
}
}
)
console.log(encoded)
const decoded = []
await pipe(
encoded,
(source) => lp.decode(source),
async source => {
for await (const chunk of source) {
decoded.push(chunk.slice())
}
}
)
console.log(decoded)
API Docs
License
Licensed under either of
Contribution
Unless you explicitly state otherwise, any contribution intentionally submitted for inclusion in the work by you, as defined in the Apache-2.0 license, shall be dual licensed as above, without any additional terms or conditions.