@supercharge/promise-pool
Advanced tools
Comparing version 1.1.0 to 1.1.1
# Changelog | ||
## [1.1.1](https://github.com/superchargejs/promise-pool/compare/v1.1.0...v1.1.1) - 2019-09-24 | ||
### Updated | ||
- bump dependencies | ||
- move package docs to Supercharge docs | ||
## [1.1.0](https://github.com/superchargejs/promise-pool/compare/v1.0.0...v1.1.0) - 2019-08-14 | ||
@@ -5,0 +12,0 @@ |
{ | ||
"name": "@supercharge/promise-pool", | ||
"description": "Map-like, concurrent promise processing for Node.js", | ||
"version": "1.1.0", | ||
"version": "1.1.1", | ||
"author": "Marcus Pöhls <marcus@futurestud.io>", | ||
@@ -11,9 +11,9 @@ "bugs": { | ||
"@hapi/code": "~6.0.0", | ||
"@hapi/lab": "~20.0.0", | ||
"eslint": "~6.1.0", | ||
"eslint-config-standard": "~13.0.1", | ||
"@hapi/lab": "~20.3.2", | ||
"eslint": "~6.4.0", | ||
"eslint-config-standard": "~14.1.0", | ||
"eslint-plugin-import": "~2.18.2", | ||
"eslint-plugin-node": "~9.1.0", | ||
"eslint-plugin-node": "~10.0.0", | ||
"eslint-plugin-promise": "~4.2.1", | ||
"eslint-plugin-standard": "~4.0.0" | ||
"eslint-plugin-standard": "~4.0.1" | ||
}, | ||
@@ -20,0 +20,0 @@ "engines": { |
@@ -16,2 +16,3 @@ <div align="center"> | ||
<a href="#installation"><strong>Installation</strong></a> · | ||
<a href="#docs"><strong>Docs</strong></a> · | ||
<a href="#usage"><strong>Usage</strong></a> · | ||
@@ -40,2 +41,6 @@ <a href="#api"><strong>API</strong></a> | ||
## Docs | ||
Find all the [details and available methods in the extensive Supercharge docs](https://superchargejs.com/docs/promise-pool). | ||
## Usage | ||
@@ -64,52 +69,2 @@ Using the promise pool is pretty straightforward. The pacakge exposes a class and you can create a promise pool instance using the fluent interface. Here’s a working example: | ||
## API | ||
#### `new PromisePool({ concurrency?, items? })` constructor | ||
Creates a new promise pool. The constructor takes an optional `options` object allowing you to passing in the `concurrency` and `items`. | ||
```js | ||
const pool = new PromisePool({ concurrency: 2, items: [1, 2, 3] }) | ||
``` | ||
#### `.withConcurrency(amount)` | ||
Set the maximum number of functions to process in parallel. Default `concurrency: 10`. Returns the promise pool instance. | ||
```js | ||
const pool = new PromisePool().withConcurrency(5) | ||
``` | ||
#### `.for(items)` | ||
Set the items to be processed in the promise pool. Returns the promise pool instance. | ||
```js | ||
const users = [ | ||
{ name: 'Marcus' }, | ||
{ name: 'Norman' }, | ||
{ name: 'Christian' } | ||
] | ||
const pool = new PromisePool().withConcurrency(5).for(users) | ||
``` | ||
#### `.process(callback)` | ||
Starts processing the promise pool by iterating over the items and passing each item to the async mapper function. Returns an object containing the results and errors. | ||
```js | ||
const users = [ | ||
{ name: 'Marcus' }, | ||
{ name: 'Norman' }, | ||
{ name: 'Christian' } | ||
] | ||
const pool = new PromisePool().withConcurrency(5).for(users) | ||
const { results, errors } = await pool.process(async (user) => { | ||
await User.createIfNotExisting(user) | ||
}) | ||
``` | ||
## Contributing | ||
@@ -116,0 +71,0 @@ |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
16509
84