Socket
Socket
Sign inDemoInstall

ts-async-iterable-queue

Package Overview
Dependencies
0
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    ts-async-iterable-queue

A queue structure implementing AsyncIterableIterator<T>


Version published
Weekly downloads
638
increased by19.48%
Maintainers
1
Install size
67.7 kB
Created
Weekly downloads
 

Readme

Source

ts-async-iterable-queue

A queue structure implementing AsyncIterableIterator<T>

npm version Build Status

Usage

import { createAsyncQueue } from 'ts-async-iterable-queue'

const q = createAsyncQueue<number>();

const postToQueue= async () => {
    for (let x = 0; x < 100; ++x) {
        await delay(1)
        q.enqueue(x)
    }
    q.complete();
}

const receiveFromQueue= async () => {
    let i = 0;
    for await (const ii of q) {
        if(i++ !== ii){
            throw Error()
        }
    }
    if(ii !== 100){
        throw Error()
    }
    console.log("queue completed!")
}

postToQueue()       // fire-and-forget
receiveFromQueue()  // fire-and-forget

acknowledgements

Created using the wonderful https://github.com/alexjoverm/typescript-library-starter.

FAQs

Last updated on 20 Apr 2019

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc