10.0.1 • Published 4 months ago
it-length-prefixed v10.0.1
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 = []
// encode
await pipe(
[uint8ArrayFromString('hello world')],
(source) => lp.encode(source),
async source => {
for await (const chunk of source) {
encoded.push(chunk.slice()) // (.slice converts Uint8ArrayList to Uint8Array)
}
}
)
console.log(encoded)
// => [Buffer <0b 68 65 6c 6c 6f 20 77 6f 72 6c 64>]
const decoded = []
// decode
await pipe(
encoded, // e.g. from above
(source) => lp.decode(source),
async source => {
for await (const chunk of source) {
decoded.push(chunk.slice()) // (.slice converts Uint8ArrayList to Uint8Array)
}
}
)
console.log(decoded)
// => [Buffer <68 65 6c 6c 6f 20 77 6f 72 6c 64>]
API Docs
License
Licensed under either of
- Apache 2.0, (LICENSE-APACHE / http://www.apache.org/licenses/LICENSE-2.0)
- MIT (LICENSE-MIT / http://opensource.org/licenses/MIT)
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.
10.0.0
4 months ago
10.0.1
4 months ago
9.1.1
5 months ago
9.0.5
10 months ago
9.1.0
10 months ago
9.0.4
1 year ago
9.0.3
2 years ago
9.0.2
2 years ago
9.0.1
2 years ago
9.0.0
2 years ago
8.0.3
3 years ago
8.0.4
2 years ago
8.0.1
3 years ago
8.0.0
3 years ago
8.0.2
3 years ago
7.0.1
3 years ago
6.0.1
3 years ago
6.0.0
3 years ago
7.0.0
3 years ago
5.0.3
4 years ago
5.0.2
4 years ago
5.0.1
4 years ago
5.0.0
4 years ago
4.0.0
4 years ago
3.1.0
5 years ago
3.0.1
5 years ago
3.0.0
6 years ago
2.0.0
6 years ago
1.1.0
6 years ago
1.0.0
6 years ago