cb-barrier

1.0.3 • Public • Published

This is a fork of Teamwork.

Usage

const Barrier = require('cb-barrier');
 
const main = async () => {
  const barrier = new Barrier();
 
  setTimeout(() => {
    barrier.pass();
  }, 100);
 
  await barrier;
};

Pass limits

You can specify a number in the constructor for the number of times a barrier should be passed before it resolves.

const Barrier = require('cb-barrier');
 
const main = async () => {
  const barrier = new Barrier(2);
 
  setTimeout(() => {
    barrier.pass();
    barrier.pass();
  }, 100);
 
  await barrier;
};

Providing return values

const Barrier = require('cb-barrier');
 
const main = async () => {
  const barrier = new Barrier();
 
  setTimeout(() => {
    barrier.pass('result');
  }, 100);
 
  // value equals 'result'
  const value = await barrier;
};

Dependencies (0)

    Dev Dependencies (3)

    Package Sidebar

    Install

    npm i cb-barrier

    Weekly Downloads

    6

    Version

    1.0.3

    License

    BSD-3

    Unpacked Size

    5.11 kB

    Total Files

    5

    Last publish

    Collaborators

    • wyatt