async-promise-queue

WebJar for async-promise-queue

License

License

MIT
GroupId

GroupId

org.webjars.npm
ArtifactId

ArtifactId

async-promise-queue
Last Version

Last Version

1.0.5
Release Date

Release Date

Type

Type

jar
Description

Description

async-promise-queue
WebJar for async-promise-queue
Project URL

Project URL

https://www.webjars.org
Source Code Management

Source Code Management

https://github.com/stefanpenner/async-promise-queue

Download async-promise-queue

How to add to project

<!-- https://jarcasting.com/artifacts/org.webjars.npm/async-promise-queue/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>async-promise-queue</artifactId>
    <version>1.0.5</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/async-promise-queue/
implementation 'org.webjars.npm:async-promise-queue:1.0.5'
// https://jarcasting.com/artifacts/org.webjars.npm/async-promise-queue/
implementation ("org.webjars.npm:async-promise-queue:1.0.5")
'org.webjars.npm:async-promise-queue:jar:1.0.5'
<dependency org="org.webjars.npm" name="async-promise-queue" rev="1.0.5">
  <artifact name="async-promise-queue" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='async-promise-queue', version='1.0.5')
)
libraryDependencies += "org.webjars.npm" % "async-promise-queue" % "1.0.5"
[org.webjars.npm/async-promise-queue "1.0.5"]

Dependencies

compile (2)

Group / Artifact Type Version
org.webjars.npm : async jar [2.4.1,3)
org.webjars.npm : debug jar [2.6.8,3)

Project Modules

There are no modules declared in this project.

async-promise-queue

Build Status

A wrapper around the async module, that provides an improved promise queue.

Some highlights:

  • promiseified method (all wired up)
  • in a failure scenario, it will wait for pending work before rejecting. This prevents the run-away work problem.

Usage

npm install async-promise-queue

or

yarn add async-promise-queue

Debug logging

DEBUG="async-promise-queue*" node <your program>

And you will be informed when a queue is used, and what its concurrency becomes (note: we can always add more logging, submit your ideas as pull requests!)

Example

'use strict';

const queue = require('async-promise-queue');

queue.async // a reference to the `async` module which `async-promise-queue` is requiring.

// the example worker
const worker = queue.async.asyncify(function(work) {
  console.log('work', work.file);
  return new Promise(resolve => {
    if (work.file === '/path-2') { throw new Error('/path-2'); }
    if (work.file === '/path-3') { throw new Error('/path-3'); }
    setTimeout(resolve, work.duration);
  });
});

// the work
const work = [
  { file:'/path-1',  duration: 1000 },
  { file:'/path-2',  duration: 50 },
  { file:'/path-3',  duration: 100 },
  { file:'/path-4',  duration: 50 },
];

// calling our queue helper
queue(worker, work, 3)
  .catch(reason => console.error(reason))
  .then(value   => console.log('complete!!', value))

Versions

Version
1.0.5
1.0.4