Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
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
  • Socket score

Version published
Weekly downloads
2
increased by100%
Maintainers
1
Weekly downloads
 
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

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

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc