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;
};

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 1.0.3
    8
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 1.0.3
    8
  • 1.0.2
    0
  • 1.0.1
    0

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