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

queue-up

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-up

Simple promise-based function queue

1.2.0
Source
npm
Version published
Maintainers
1
Created
Source

queue-up Build Status

Simple promise-based function queue

Cool way to enqueue rate-limited operations. Even cooler when used with Promise-returning functions.

Install

$ npm install --save queue-up

Usage

const ghGot = require('gh-got');
const Queue = require('queue-up');

// GitHub API allows us to make 5000 requests per hour:

const queue = new Queue(60 * 60 * 1000 / 5000);

const users = [
	'dsblv',
	'strikeentco',
	'sindresorhus',
	'octocat'
];

for (var i in users) {
	queue.up(users[i])
		.then(user => {
			return ghGot('users/' + user, {token: 'koten'});
		})
		.then(data => {
			console.log(data.body.name + ' is in ' + data.body.location);
		});
}

API

new Queue([interval], [promiseModule])

Creates new instance of Queue.

interval

Type: number
Default: 1000

promiseModule

Type: function

Pass custom Promise module to use instead of the native one.

queue.up([value]) → promise

Alias: queue.enqueue()

Returns a Promise which is resolved in specified time after previous one.

value

Value to be passed to resolve handler function:

queue.up('hello').then(console.log);
//=> hello

License

MIT © Dimzel Sobolev

Keywords

queue

FAQs

Package last updated on 20 Sep 2015

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