async-iterable-queue
TypeScript icon, indicating that this package has built-in type declarations

1.0.16 • Public • Published

async-iterable-queue license npm

dependency maintenance quality

async-iterable-queue - A library for 'Queue' class which implements AsyncIterable<T> works on Node.js

CI Status

Workflow Name Status
Build GitHub CI (Build)
CodeQL GitHub CI (CodeQL)
Coverage GitHub CI (Coverage)
Example GitHub CI (Example)

Installation

npm i async-iterable-queue

Usage

import { AsyncIterableQueue } from 'async-iterable-queue'

type Foo = {
  id: number
  name: string
}

async function example1(queue: AsyncIterableQueue<Foo>): Promise<void> {
  console.debug('pushing 123')
  await queue.push({
    id: 123,
    name: 'foo',
  })
  console.debug('123 has been pushed')
  await queue.push({
    id: 456,
    name: 'bar',
  })
  console.debug('456 has been pushed')
  await queue.push({
    id: 789,
    name: 'baz',
  })
  console.debug('789 has been pushed')
  await queue.end()
  console.debug('\'end\' has been pushed')
}

async function example2(queue: AsyncIterableQueue<Foo>): Promise<void> {
  for await (const value of queue)
    console.debug(value)
  console.debug('all elements have been popped from queue')
}

async function example(): Promise<void> {
  console.debug('example for AsyncIterableQueue has begun')
  const queue = new AsyncIterableQueue<Foo>()
  await Promise.all([
    example1(queue),
    example2(queue),
  ])
  console.debug('example for AsyncIterableQueue has finished')
}

example()

License

The scripts and documentation in this project are released under the BSD-3-Clause License

Contributions

Contributions are welcome! See Contributor's Guide

Code of Conduct

👏 Be nice. See our code of conduct

Versions

Current Tags

VersionDownloads (Last 7 Days)Tag
1.0.1622latest

Version History

VersionDownloads (Last 7 Days)Published
1.0.1622
1.0.152
1.0.140
1.0.130
1.0.120
1.0.110
1.0.100
1.0.91
1.0.80
1.0.70
1.0.60
1.0.50
1.0.40
1.0.30
1.0.20
1.0.10
1.0.00

Package Sidebar

Install

npm i async-iterable-queue

Weekly Downloads

25

Version

1.0.16

License

BSD-3-Clause

Unpacked Size

18.5 kB

Total Files

9

Last publish

Collaborators

  • kei-g