Important: This documentation covers Yarn 1 (Classic).
For Yarn 2+ docs and migration guide, see yarnpkg.com.

Package detail

it-pushable

alanshaw346.9kApache-2.0 OR MIT3.2.3TypeScript support: included

An iterable that you can push values into

iterable, iterator, push, pushable

readme

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] ]
*/
  • 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.

changelog

3.2.3 (2023-11-16)

Bug Fixes

3.2.2 (2023-11-11)

Trivial Changes

  • add or force update .github/workflows/js-test-and-release.yml (#66) (9dc3452)
  • delete templates [skip ci] (#65) (623e049)

Dependencies

  • dev: bump aegir from 39.0.13 to 41.0.5 (#74) (ca99910)

3.2.1 (2023-07-04)

Bug Fixes

  • await returned promise in waitNext (#59) (d19e8ca)

3.2.0 (2023-07-03)

Features

  • add onEmpty function that resolves when the queue is empty (#58) (2bed38a)

3.1.4 (2023-06-30)

Dependencies

  • dev: bump aegir from 37.12.1 to 39.0.13 (#52) (9399579)

3.1.3 (2023-04-18)

Bug Fixes

3.1.2 (2022-12-16)

Documentation

3.1.1 (2022-12-16)

Trivial Changes

  • deps-dev: bump it-all from 1.0.6 to 2.0.0 (#34) (1b50e5e)

3.1.0 (2022-08-02)

Features

  • support Uint8ArrayLists in the same way as Uint8Arrays (#30) (7bae368)

3.0.0 (2022-06-10)

⚠ BREAKING CHANGES

  • Uint8Arrays are expected by default, pass objectMode: true to push any other data types. If using TypeScript, use generics to define the data type.

Features

Trivial Changes

2.0.2 (2022-06-08)

Bug Fixes

Trivial Changes

2.0.1 (2022-01-13)

Trivial Changes

2.0.0 (2022-01-13)

⚠ BREAKING CHANGES

  • switch to named exports, ESM only

Features