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 - npm Package Compare versions

Comparing version 2.0.0 to 2.1.0

4

index.js
'use strict';
var delay = require('delay');
var Queue = module.exports = function (interval) {
var Queue = module.exports = function (interval, initialValue) {
this.interval = interval || 1000;
this.remaining = Promise.resolve();
this.remaining = Promise.resolve(initialValue);
};

@@ -8,0 +8,0 @@

{
"name": "queue-up",
"version": "2.0.0",
"version": "2.1.0",
"description": "Simple promise-based function queue",

@@ -5,0 +5,0 @@ "license": "MIT",

@@ -32,3 +32,3 @@ # queue-up [![Build Status](https://travis-ci.org/dsblv/queue-up.svg?branch=master)](https://travis-ci.org/dsblv/queue-up)

opts = {
const opts = {
token: 'the-private-token'

@@ -47,3 +47,3 @@ };

### new Queue([interval])
### new Queue([interval, initialValue])

@@ -57,3 +57,26 @@ Creates new instance of Queue.

Time in `ms` from when previous function resolves to when next is invoked.
#### initialValue
Type: `any`
Default: `undefined`
Every function in a queue gets result of the previous one as an argument. If you specify `initialValue`, it will be fed to the first function:
```js
function double(value) {
return value * 2;
}
const queue = new Queue(100, 1337);
queue.up(double).then(console.log);
//=> 2674
queue.up(double).then(console.log);
//=> 5348 (after 100ms)
```
### queue.up(fn)

@@ -75,3 +98,3 @@

Like [`Promise.all()`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/all), but with interval between invocations.
Enqueues several function and returns a `promise` that resolves to an `array` of all results.

@@ -85,5 +108,15 @@ #### fns

```js
function double(value) {
return value * 2;
}
const queue = new Queue(100, 1337);
queue.all([double, double]).then(console.log);
//=> [2674, 5348] (after 100ms)
```
## License
MIT © [Dmitriy Sobolev](https://github.com/dsblv)
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