🚀 Big News: Socket Acquires Coana to Bring Reachability Analysis to Every Appsec Team.Learn more
Socket
DemoInstallSign in
Socket

queue-that-promise

Package Overview
Dependencies
Maintainers
1
Versions
6
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

queue-that-promise

Push promises to a queue. The queue runs. That's all.

1.2.3
latest
Source
npm
Version published
Weekly downloads
112
14.29%
Maintainers
1
Weekly downloads
 
Created
Source

queue-that-promise Build Status

Push promises to a queue. The queue runs in order. That's all. 500b gzipped.

Install

$ npm install --save queue-that-promise

Usage

var Queue = require('queue-that-promise')
var queue = Queue()

queue.add(() => new Promise((resolve) => setTimeout(resolve, 100))
  .then(() => console.log('first'))

queue.add(() => new Promise((resolve) => setTimeout(resolve, 100))
  .then(() => console.log('second'))

queue.add(() => new Promise((resolve) => setTimeout(resolve, 100))
  .then(() => console.log('third'))

queue.done().then(() => console.log('done'))

// Wait 100ms...
// => "first"
// Wait 100ms...
// => "second"
// Wait 100ms...
// => "third"
// => "done"

API

Queue() -> queue

Returns a queue instance.

queue.done() -> Promise

Returns a promise that will be resolved once the queue is empty.

queue.add(callback<Promise> | Array<callback<Promise>>) -> Promise

Adds a callback or multiple callbacks to the queue.

The callback will run after all previously added callbacks have finished.

Returns a promise that will be resolved or rejected once the given callback's returned promise is resolved or rejected.

queue.count() -> number

Returns the current length of the queue.

License

MIT © Andrew Joslin

Keywords

promise

FAQs

Package last updated on 22 Feb 2017

Did you know?

Socket

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