pax_global_header00006660000000000000000000000064140106456620014516gustar00rootroot0000000000000052 comment=8e514fee209d56707cb6c232813b3d56280dde3f run-parallel-1.2.0/000077500000000000000000000000001401064566200141145ustar00rootroot00000000000000run-parallel-1.2.0/.airtap.yml000066400000000000000000000004341401064566200161760ustar00rootroot00000000000000sauce_connect: true loopback: airtap.local browsers: - name: chrome version: latest - name: firefox version: latest - name: safari version: latest - name: microsoftedge version: latest - name: iphone version: latest - name: android version: latest run-parallel-1.2.0/.npmignore000066400000000000000000000000461401064566200161130ustar00rootroot00000000000000img.png .airtap.yml .travis.yml test/ run-parallel-1.2.0/.travis.yml000066400000000000000000000007401401064566200162260ustar00rootroot00000000000000language: node_js node_js: - lts/* addons: sauce_connect: true hosts: - airtap.local env: global: - secure: T7mCjAOoVie1FZmArsemYTcZcw7qCBwmZAZG1s0nRZNEoa5HilHRntUtIUzKf8Kd9lpibAjcF2DBDieq5AiaQIANfcPhxzp31nDRwPEsF5rFhHKYdWRsPyRrv3D387VH/X5xZ5I1Mk9vAvZzqd6mGdlPYZ0YPAG0aNOalQnRXOM= - secure: NwZOvg2y84GTit1rL6P+mhfrju8yua0lZ/+i4Pp5sQhI/bU2nCt1Gpr4UtaogevQAYZKtlTlW0GI+iuph67Qx9lq4Uf9HvuhFeEz3fRBiR3KzLbzlDXaWyRo9W86sjUiO/giVaWty7OQSsFRgXDzkZd7sbVjGhWIbqLBvSss1Yo= run-parallel-1.2.0/LICENSE000066400000000000000000000020711401064566200151210ustar00rootroot00000000000000The MIT License (MIT) Copyright (c) Feross Aboukhadijeh Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software. THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. run-parallel-1.2.0/README.md000066400000000000000000000061251401064566200153770ustar00rootroot00000000000000# run-parallel [![travis][travis-image]][travis-url] [![npm][npm-image]][npm-url] [![downloads][downloads-image]][downloads-url] [![javascript style guide][standard-image]][standard-url] [travis-image]: https://img.shields.io/travis/feross/run-parallel/master.svg [travis-url]: https://travis-ci.org/feross/run-parallel [npm-image]: https://img.shields.io/npm/v/run-parallel.svg [npm-url]: https://npmjs.org/package/run-parallel [downloads-image]: https://img.shields.io/npm/dm/run-parallel.svg [downloads-url]: https://npmjs.org/package/run-parallel [standard-image]: https://img.shields.io/badge/code_style-standard-brightgreen.svg [standard-url]: https://standardjs.com ### Run an array of functions in parallel ![parallel](https://raw.githubusercontent.com/feross/run-parallel/master/img.png) [![Sauce Test Status](https://saucelabs.com/browser-matrix/run-parallel.svg)](https://saucelabs.com/u/run-parallel) ### install ``` npm install run-parallel ``` ### usage #### parallel(tasks, [callback]) Run the `tasks` array of functions in parallel, without waiting until the previous function has completed. If any of the functions pass an error to its callback, the main `callback` is immediately called with the value of the error. Once the `tasks` have completed, the results are passed to the final `callback` as an array. It is also possible to use an object instead of an array. Each property will be run as a function and the results will be passed to the final `callback` as an object instead of an array. This can be a more readable way of handling the results. ##### arguments - `tasks` - An array or object containing functions to run. Each function is passed a `callback(err, result)` which it must call on completion with an error `err` (which can be `null`) and an optional `result` value. - `callback(err, results)` - An optional callback to run once all the functions have completed. This function gets a results array (or object) containing all the result arguments passed to the task callbacks. ##### example ```js var parallel = require('run-parallel') parallel([ function (callback) { setTimeout(function () { callback(null, 'one') }, 200) }, function (callback) { setTimeout(function () { callback(null, 'two') }, 100) } ], // optional callback function (err, results) { // the results array will equal ['one','two'] even though // the second function had a shorter timeout. }) ``` This module is basically equavalent to [`async.parallel`](https://github.com/caolan/async#paralleltasks-callback), but it's handy to just have the one function you need instead of the kitchen sink. Modularity! Especially handy if you're serving to the browser and need to reduce your javascript bundle size. Works great in the browser with [browserify](http://browserify.org/)! ### see also - [run-auto](https://github.com/feross/run-auto) - [run-parallel-limit](https://github.com/feross/run-parallel-limit) - [run-series](https://github.com/feross/run-series) - [run-waterfall](https://github.com/feross/run-waterfall) ### license MIT. Copyright (c) [Feross Aboukhadijeh](http://feross.org). run-parallel-1.2.0/img.png000066400000000000000000000030651401064566200154020ustar00rootroot00000000000000PNG  IHDR<qtEXtSoftwareAdobe ImageReadyqe<IDATx]ej*R7j($y!d.H^!R Y``xu"yEMX.bfl.^,A&ywa≠38av83NSZ5eI`!B ,D"X(5򥮮.ǯˏ';i7mZ[[KxnooЄE_jfQ! O N3Ӥc_8-ߓWwd,ߑ7Sb&'X^@mLͲ'\n@h|N <'X"GUi{oOy*^ug}=rW`FM.3sV:,rnu]n;㬰 w >N}AfƘj;N+\Pߔ7GbwxԽ6,TP_`]=ATzB>*,߂zH~K.ߔr;]&Ze?8+ ^ϑȻb[E=\nT%ytov_:nn?kյZ+PكxP\kſ088sh@=4g˯_`,@}Lr ~hrzRLyBFF6Hc>R>&X1K_l7gAMaT\Pe>5qL ?Pw.@c{SHQ4guP\B@u P0Q '3 u Pi,@u3 p@i,@=PuB@u Pp@`B@=Pu Pi,@`ai,@Ken,@`B@P/ac4Ncz 3 u PKX:,@P/(i,@6NuF!u PG7Nu(i,@X:#3 uc4o,@`QX:u PG PgQ PG5Y^#7(`-?ʫwcuP?zTIP'T5#Zz'~B@P-_.Wu(.##oꨑ`!qOo:W ,y|RX.3@@ akT3W y2q@xgy P/ =u, P2g*,@= u#?G-uk*j1"Lt/PgfU"#݋+oϛh3?FaZtA>ܻB#ޮ>'Q -_p_Z!;vW:/xc2+US-m4< */ module.exports = runParallel const queueMicrotask = require('queue-microtask') function runParallel (tasks, cb) { let results, pending, keys let isSync = true if (Array.isArray(tasks)) { results = [] pending = tasks.length } else { keys = Object.keys(tasks) results = {} pending = keys.length } function done (err) { function end () { if (cb) cb(err, results) cb = null } if (isSync) queueMicrotask(end) else end() } function each (i, err, result) { results[i] = result if (--pending === 0 || err) { done(err) } } if (!pending) { // empty done(null) } else if (keys) { // object keys.forEach(function (key) { tasks[key](function (err, result) { each(key, err, result) }) }) } else { // array tasks.forEach(function (task, i) { task(function (err, result) { each(i, err, result) }) }) } isSync = false } run-parallel-1.2.0/package.json000066400000000000000000000024131401064566200164020ustar00rootroot00000000000000{ "name": "run-parallel", "description": "Run an array of functions in parallel", "version": "1.2.0", "author": { "name": "Feross Aboukhadijeh", "email": "feross@feross.org", "url": "https://feross.org" }, "bugs": { "url": "https://github.com/feross/run-parallel/issues" }, "dependencies": { "queue-microtask": "^1.2.2" }, "devDependencies": { "airtap": "^3.0.0", "standard": "*", "tape": "^5.0.1" }, "homepage": "https://github.com/feross/run-parallel", "keywords": [ "parallel", "async", "function", "callback", "asynchronous", "run", "array", "run parallel" ], "license": "MIT", "main": "index.js", "repository": { "type": "git", "url": "git://github.com/feross/run-parallel.git" }, "scripts": { "test": "standard && npm run test-node && npm run test-browser", "test-browser": "airtap -- test/*.js", "test-browser-local": "airtap --local -- test/*.js", "test-node": "tape test/*.js" }, "funding": [ { "type": "github", "url": "https://github.com/sponsors/feross" }, { "type": "patreon", "url": "https://www.patreon.com/feross" }, { "type": "consulting", "url": "https://feross.org/support" } ] } run-parallel-1.2.0/test/000077500000000000000000000000001401064566200150735ustar00rootroot00000000000000run-parallel-1.2.0/test/array.js000066400000000000000000000023011401064566200165430ustar00rootroot00000000000000const parallel = require('../') const test = require('tape') test('functions run in parallel', function (t) { t.plan(4) const tasks = [ function (cb) { t.pass('cb 1') cb(null) }, function (cb) { t.pass('cb 2') cb(null) }, function (cb) { t.pass('cb 3') cb(null) } ] parallel(tasks, function (err) { t.error(err) }) }) test('functions that return results', function (t) { t.plan(4) const tasks = [ function (cb) { t.pass('cb 1') cb(null, 1) }, function (cb) { t.pass('cb 2') cb(null, 2) } ] parallel(tasks, function (err, results) { t.error(err) t.deepEqual(results, [1, 2]) }) }) test('functions that return results preserve order', function (t) { t.plan(4) const tasks = [ function (cb) { setTimeout(function () { t.pass('cb 1') cb(null, 1) }, 200) }, function (cb) { setTimeout(function () { t.pass('cb 2') cb(null, 2) }, 100) } ] parallel(tasks, function (err, results) { t.error(err) // 2 should be second, even though it gets returned first t.deepEqual(results, [1, 2]) }) }) run-parallel-1.2.0/test/empty-tasks.js000066400000000000000000000007771401064566200177250ustar00rootroot00000000000000const parallel = require('../') const test = require('tape') test('empty tasks array', function (t) { t.plan(1) parallel([], function (err) { t.error(err) }) }) test('empty tasks object', function (t) { t.plan(1) parallel({}, function (err) { t.error(err) }) }) test('empty tasks array and no callback', function (t) { parallel([]) t.pass('did not throw') t.end() }) test('empty tasks object and no callback', function (t) { parallel({}) t.pass('did not throw') t.end() }) run-parallel-1.2.0/test/error.js000066400000000000000000000030321401064566200165600ustar00rootroot00000000000000const parallel = require('../') const test = require('tape') test('functions that return errors (array)', function (t) { t.plan(3) const tasks = [ function (cb) { t.pass('cb 1') cb(new Error('oops')) }, function (cb) { setTimeout(function () { t.pass('cb 2') cb(null, 2) }, 100) } ] parallel(tasks, function (err) { t.ok(err instanceof Error) }) }) test('functions that return errors (object)', function (t) { t.plan(3) const tasks = { one: function (cb) { t.pass('cb 1') cb(new Error('oops')) }, two: function (cb) { setTimeout(function () { t.pass('cb 2') cb(null, 2) }, 100) } } parallel(tasks, function (err) { t.ok(err instanceof Error) }) }) test('functions that return errors (object) w/ partial results', function (t) { t.plan(4) const tasks = { one: function (cb) { t.pass('cb 1') cb(null, 1) }, two: function (cb) { setTimeout(function () { t.pass('cb 2') cb(new Error('oops')) }, 100) } } parallel(tasks, function (err, results) { t.ok(err instanceof Error) t.deepEqual(results, { one: 1, two: undefined }) }) }) test('array of functions that produce multiple errors', function (t) { const tasks = [ function (cb) { cb(new Error('a')) }, function (cb) { cb(new Error('b')) } ] parallel(tasks, function (err) { t.ok(err.message === 'a', 'only observes the first error') t.end() }) }) run-parallel-1.2.0/test/no-callback.js000066400000000000000000000007201401064566200175760ustar00rootroot00000000000000const parallel = require('../') const test = require('tape') test('no callback (array)', function (t) { t.plan(2) const tasks = [ function (cb) { t.pass('cb 1') }, function (cb) { t.pass('cb 2') } ] parallel(tasks) }) test('no callback (object)', function (t) { t.plan(2) const tasks = { one: function (cb) { t.pass('cb 1') }, two: function (cb) { t.pass('cb 2') } } parallel(tasks) }) run-parallel-1.2.0/test/object.js000066400000000000000000000013651401064566200167040ustar00rootroot00000000000000const parallel = require('../') const test = require('tape') test('functions run in parallel', function (t) { t.plan(4) const tasks = { one: function (cb) { t.pass('cb 1') cb(null) }, two: function (cb) { t.pass('cb 2') cb(null) }, three: function (cb) { t.pass('cb 3') cb(null) } } parallel(tasks, function (err) { t.error(err) }) }) test('functions that return results', function (t) { t.plan(4) const tasks = { one: function (cb) { t.pass('cb 1') cb(null, 1) }, two: function (cb) { t.pass('cb 2') cb(null, 2) } } parallel(tasks, function (err, results) { t.error(err) t.deepEqual(results, { one: 1, two: 2 }) }) })