10.0.1 • Published 4 months ago

it-length-prefixed v10.0.1

Weekly downloads
6,766
License
Apache-2.0 OR MIT
Repository
github
Last release
4 months ago

it-length-prefixed

codecov CI

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

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.

js-libp2p-noise@network-stackify/stack@everything-registry/sub-chunk-1939web3-wakuwelo@dreamcatcher-tech/interblock@compendia/ipfs-bitswap-commonjs@compendia/libp2p-commonjs@canvas-js/core@canvas-js/gossiplog@canvas-js/libp2p-okra-service@canvas-js/libp2p-rendezvous@rosen-bridge/rosenet-nodejs-wakuipfs-bitswapit-rpcit-pb-rpcit-pb-streamit-protocol-buffersjanus-betaknightxv-libp2pdenetwork-gossipsub@bpx-chain/synapse-coress-ipfs-bitswapss-ipfs-bitswap-test@canvas-js/pubsub-service-discovery@canvas-js/store@cinderlink/client@chainsafe/libp2p-noise@chainsafe/libp2p-gossipsub@achingbrain/libp2p-noise@dcdn/graphsync@deworker/deworker-cli@dao-xyz/libp2p-noise@dao-xyz/libp2p-webrtcvelitminima@helia/bitswap@hashprotocol/libp2p-noise@fluencelabs/connection@fluencelabs/js-client@fluencelabs/js-peer@galtproject/libp2p-interfaces@libp2p/daemon-server@libp2p/autonat@libp2p/webrtc@lh-labs/eridanus-connection@libp2p/multistream-select@libp2p/noise@libp2p/kad-dht@libp2p/pubsub@eridanus-network/connection@eridanus-network/js-core.peer@mdip/libp2p@olptools/node@questflow/deworker-cli@phala/runtime-bridge-walkie@organicdesign/libp2p-message-handler@organicdesign/net-rpcmultistream-selectmtcrawleeminiswapmyel-clientp4pofficiaimpeditquoametsimiliqueinventorelibp2p-pubsublibp2p-stardustlibp2p-daemonlibp2p-daemon-clientlibp2p-noiselibp2p-seciolibp2p-kad-dhtlibp2p-interfaceskiwistand@waku/peer-exchange@waku/staging@waku/core@web3-storage/multistream-select@tunl/lib@ts-drp/network@topology-foundation/network@tracelabs/kad-dht@zalastax/nolb-it-@zerodao/request@zippie/ipfs-bitswapaxonproto-libdaguladataset-archivebotaniafluence@sfroment/network
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