3.2.3 • Published 6 months ago

it-pushable v3.2.3

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

it-pushable

codecov CI

An iterable that you can push values into

About

An iterable that you can push values into.

Example

import { pushable } from 'it-pushable'

const source = pushable()

setTimeout(() => source.push('hello'), 100)
setTimeout(() => source.push('world'), 200)
setTimeout(() => source.end(), 300)

const start = Date.now()

for await (const value of source) {
  console.log(`got "${value}" after ${Date.now() - start}ms`)
}
console.log(`done after ${Date.now() - start}ms`)

// Output:
// got "hello" after 105ms
// got "world" after 207ms
// done after 309ms

Example

import { pushableV } from 'it-pushable'
import all from 'it-all'

const source = pushableV()

source.push(1)
source.push(2)
source.push(3)
source.end()

console.info(await all(source))

// Output:
// [ [1, 2, 3] ]

Table of contents

Install

$ npm i it-pushable

Browser <script> tag

Loading this module through a script tag will make it's exports available as ItPushable in the global namespace.

<script src="https://unpkg.com/it-pushable/dist/index.min.js"></script>

Usage

import { pushable } from 'it-pushable'

const source = pushable()

setTimeout(() => source.push('hello'), 100)
setTimeout(() => source.push('world'), 200)
setTimeout(() => source.end(), 300)

const start = Date.now()

for await (const value of source) {
  console.log(`got "${value}" after ${Date.now() - start}ms`)
}
console.log(`done after ${Date.now() - start}ms`)

/*
Output:
got "hello" after 105ms
got "world" after 207ms
done after 309ms
*/
import { pushableV } from 'it-pushable'
import all from 'it-all'

const source = pushableV()

source.push(1)
source.push(2)
source.push(3)
source.end()

console.info(await all(source))
/*
Output:
[ [1, 2, 3] ]
*/

Related

  • it-pipe Utility to "pipe" async iterables together

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.

@hoprnet/hopr-core@everything-registry/sub-chunk-1939ipfs-repoipfs-grpc-serveripfs-unixfs-exporteripfs-demoipfs-coreipfs-grpc-clientipfs-http-serverit-mergeit-multipartit-pb-streamit-handshakeit-pipeinterface-ipfs-corelibp2p-interfaceslibp2p-mesh-rpclibp2p-mplexlibp2p-mplex-curltechlibp2p-daemonfastify-sse-v2fastify-uwsstarpcchatterbox-core@dreamcatcher-tech/interblock@douganderson444/ipfs-core@dao-xyz/libp2p-webrtc@libp2p/interface@libp2p/interface-compliance-tests@libp2p/daemon-server@libp2p/interface-mocks@libp2p/interface-pubsub@libp2p/interface-stream-muxer@libp2p/utils@libp2p/webrtc@libp2p/webrtc-peer@libp2p/perf@libp2p/pubsub@libp2p/tls@libp2p/kad-dht@libp2p/mplex@ndn/repo-api@ndn/repo-external@ndn/cat@ndn/endpoint@ndn/fw@ndn/l3face@nodefactory/web3-server-wallet@futureverse/sylo-protocol-sdk@replit/riverdatastore-core@organicdesign/libp2p-message-handler@organicdesign/net-rpc@mdip/ipfs-core@individe/libp2p-snappy-muxerblockstore-datastore-adapterblockstore-coreweb3-server-walletwelo@dstanesc/ipfs-core-store-accessdenetwork-gossipsub@galtproject/libp2p-interfaces@waylaidwanderer/fastify-sse-v2@types/it-pushable@xx-johnwick-xx/fastify-sse-v2@web3-storage/multistream-select@zalastax/nolb-it-@0xvaibhav/libp2p-events@0xvaibhav/libp2p-events-client@canvas-js/gossiplog@canvas-js/pubsub-service-discoveryaxonproto-lib@chainsafe/libp2p-gossipsub@chainsafe/libp2p-yamux@chat1/fastify-sse-v2@chris.troutner/ipfs-grpc-client@chris.troutner/ipfs-grpc-server@chris.troutner/ipfs-http-server@chris.troutner/interface-ipfs-core
3.2.2

6 months ago

3.2.3

6 months ago

3.2.1

10 months ago

3.2.0

10 months ago

3.1.4

10 months ago

3.1.3

1 year ago

3.1.2

1 year ago

3.1.1

1 year ago

3.1.0

2 years ago

3.0.0

2 years ago

2.0.2

2 years ago

2.0.1

2 years ago

2.0.0

2 years ago

1.4.2

3 years ago

1.4.1

3 years ago

1.4.0

5 years ago

1.3.2

5 years ago

1.3.1

5 years ago

1.3.0

5 years ago

1.2.1

5 years ago

1.2.0

5 years ago

1.1.1

5 years ago

1.1.0

5 years ago

1.0.0

5 years ago