@esfx/async-queue
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

@esfx/async-queue

The @esfx/async-queue package provides the AsyncQueue class, an async coordination primitive.

Overview

Installation

npm i @esfx/async-queue

Usage

import { AsyncQueue } from "@esfx/async-queue";

async function main() {
    const queue = new AsyncQueue();

    // put two items on the queue
    queue.put(1);
    queue.put(2);

    // take two items from the queue
    await queue.get(); // 1
    await queue.get(); // 2

    // take two more pending items from the queue
    const p3 = queue.get();
    const p4 = queue.get();

    // put two more items on the queue
    queue.put(3);
    queue.put(4);

    await p3; // 3
    await p4; // 4
}

API

You can read more about the API here.

Readme

Keywords

none

Package Sidebar

Install

npm i @esfx/async-queue

Weekly Downloads

119

Version

1.0.0

License

Apache-2.0

Unpacked Size

48.4 kB

Total Files

9

Last publish

Collaborators

  • rbuckton