{"_id":"@async-generators/parallel","_rev":"2-def3425d0c1a1e8af0c5cced26adb589","name":"@async-generators/parallel","description":"execute an async transform and yield in order of completion","dist-tags":{"latest":"0.2.0"},"versions":{"0.1.0":{"name":"@async-generators/parallel","description":"execute an async transform and yield in order of completion","version":"0.1.0","author":{"name":"Meirion Hughes","email":"crakinshot@yahoo.com","url":"https://github.com/MeirionHughes"},"keywords":["map","select","async","iterator","generator","esnext","typescript","linq"],"license":"MIT","main":"./dist/commonjs/index.js","typings":"./dist/commonjs/index.d.ts","module":"./dist/es2015/index.js","repository":{"type":"git","url":"git+https://github.com/async-generators/parallel.git"},"bugs":{"url":"https://github.com/async-generators/parallel/issues"},"dependencies":{"@async-generators/iterable":"^0.2.0","events":"^1.1.1"},"devDependencies":{"@async-generators/equal":"^0.4.0","@types/chai":"^4.0.4","@types/mocha":"^2.2.43","@types/node":"^8.0.28","chai":"^4.1.2","chai-as-promised":"^7.1.1","codecov":"^2.3.0","mocha":"^3.5.3","nyc":"^11.2.1","ts-node":"^3.3.0","typescript":"^2.5.2"},"scripts":{"test":"nyc node_modules/mocha/bin/mocha --harmony-async-iteration --require source-map-support/register --compilers ts:ts-node/register test/*.ts","build":"npm run build:commonjs && npm run build:es2015","build:commonjs":"tsc --project tsconfig.build.json --rootDir src/ --outDir ./dist/commonjs","build:es2015":"tsc --project tsconfig.build.json --rootDir src/ --outDir ./dist/es2015 --module es2015","cover":"codecov"},"engines":{"node":">=8.5.0"},"nyc":{"exclude":["node_modules/","test/","coverage/"],"extension":[".ts"],"require":["ts-node/register"],"reporter":["text-summary","lcov"],"sourceMap":true,"instrument":true},"gitHead":"fd39c4d75f5e25632453ededebe22a70bfb970e6","homepage":"https://github.com/async-generators/parallel#readme","_id":"@async-generators/parallel@0.1.0","_npmVersion":"5.0.3","_nodeVersion":"8.5.0","_npmUser":{"name":"meirionhughes","email":"crakinshot@yahoo.com"},"dist":{"integrity":"sha512-AvhRCYRSRWyo/mrAYXbhy+4yZyS1/o1RSAdYOdqT0CC83VhEDSoiAj2TeQprcfgJigNqhBZDcKEkSl8HUEFyug==","shasum":"43a4558413985afc6fb7e59714d7ad79fa3b9ba7","tarball":"https://registry.npmjs.org/@async-generators/parallel/-/parallel-0.1.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIEiQ1P1iL5b5/QzB+vBglB7w0tEm4BTVsZxjGxahLG92AiEAjD2cdNHAPy2xFD2XUOFR4Vuf7SuCVwXvjX40G91wO2c="}]},"maintainers":[{"name":"meirionhughes","email":"crakinshot@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/parallel-0.1.0.tgz_1505955785953_0.7773022407200187"}},"0.2.0":{"name":"@async-generators/parallel","description":"execute an async transform and yield in order of completion","version":"0.2.0","author":{"name":"Meirion Hughes","email":"crakinshot@yahoo.com","url":"https://github.com/MeirionHughes"},"keywords":["map","select","async","iterator","generator","esnext","typescript","linq"],"license":"MIT","main":"./dist/commonjs/index.js","typings":"./dist/commonjs/index.d.ts","module":"./dist/es2015/index.js","repository":{"type":"git","url":"git+https://github.com/async-generators/parallel.git"},"bugs":{"url":"https://github.com/async-generators/parallel/issues"},"dependencies":{"@async-generators/iterable":"^0.2.0","events":"^1.1.1"},"devDependencies":{"@async-generators/equal":"^0.4.0","@types/chai":"^4.0.4","@types/mocha":"^2.2.43","@types/node":"^8.0.28","chai":"^4.1.2","chai-as-promised":"^7.1.1","codecov":"^2.3.0","mocha":"^3.5.3","nyc":"^11.2.1","ts-node":"^3.3.0","typescript":"^2.5.2"},"scripts":{"test":"nyc node_modules/mocha/bin/mocha --harmony-async-iteration --require source-map-support/register --compilers ts:ts-node/register test/*.ts","build":"npm run build:commonjs && npm run build:es2015","build:commonjs":"tsc --project tsconfig.build.json --rootDir src/ --outDir ./dist/commonjs","build:es2015":"tsc --project tsconfig.build.json --rootDir src/ --outDir ./dist/es2015 --module es2015","cover":"codecov"},"engines":{"node":">=8.5.0"},"nyc":{"exclude":["node_modules/","test/","coverage/"],"extension":[".ts"],"require":["ts-node/register"],"reporter":["text-summary","lcov"],"sourceMap":true,"instrument":true},"gitHead":"c8405ca661df4e8e24bcffa8e7d8dcb621ea1e33","homepage":"https://github.com/async-generators/parallel#readme","_id":"@async-generators/parallel@0.2.0","_npmVersion":"5.3.0","_nodeVersion":"8.5.0","_npmUser":{"name":"meirionhughes","email":"crakinshot@yahoo.com"},"dist":{"integrity":"sha512-MQG4nFIto5zpzPtBcoqHbcarHN6r11v9FSPLa6aCBQJJGC1YTpaXlgRsFkxdqQ81jBFddEHG/E+9iXABL0id4w==","shasum":"14fdb6e7a43ba314c585aab16152b9a56b969045","tarball":"https://registry.npmjs.org/@async-generators/parallel/-/parallel-0.2.0.tgz","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCB7kOIDvxz6Rn1x940V/C+XOiwiwBEBUFKurA2WcaNAQIgGsmDQejwA70QkdIzuJNnFH8WVsOTr/5fVey6zqD8HDU="}]},"maintainers":[{"name":"meirionhughes","email":"crakinshot@yahoo.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/parallel-0.2.0.tgz_1506093600936_0.9717069799080491"}}},"readme":"# parallel\n![logo](https://avatars1.githubusercontent.com/u/31987273?v=4&s=100)\n\nexecute an async transform and yield in order of completion\n\n[![NPM version][npm-image]][npm-url]\n[![Travis Status][travis-image]][travis-url]\n[![Travis Status][codecov-image]][codecov-url]\n\n## Usage\n\n_package requires a system that supports async-iteration, either natively or via down-compiling_\n\n### Install\n```\nnpm install @async-generators/parallel --save\nyarn add @async-generators/parallel\n```\n\nThis package's `main` entry points to a `commonjs` distribution. \n\nAdditionally, the `module` entry points to a `es2015` distribution, which can be used by build systems, such as webpack, to directly use es2015 modules. \n\n## Api\n\n### parallel(source, selector [,limit=20] [,limited])\n\n<code>parallel()</code> iterates `source` and executes `selector(item, index)` concurrently. Upon resolution of selector promise, the result is yielded. \n\n`selector(item)` is awaited in a non-blocking fashion and `parallel` results are yielded in the _order of completion_. \n\nIf the the number of concurrent tasks is greater-than or equal-to `limit` further iteration of `source` is halted until other tasks complete. Upon halting, the `limited(item, index)` method is called (sync). If `limited` returns `true` the item is ignored not _not_ passed to   `selector`\n\n`source` must have a `[Symbol.asyncIterator]` or `[Symbol.iterator]` property. If both are present only `[Symbol.asyncIterator]` is used. \n\n\n\n### parallel(source [,limit=20] [,limited])\n\n<code>parallel()</code> iterates `source` and awaits each item concurrently. Upon resolve, the result is yielded. `source` items are awaited in a non-blocking fashion and the results are yielded in the _order of completion_. \n\n`source` must have a `[Symbol.asyncIterator]` or `[Symbol.iterator]` property. If both are present only `[Symbol.asyncIterator]` is used. `source` should _ideally_ yield executing promises, but technically can yield an object - although this makes the call to `parallel` entirely redundant. \n\n## Example\n\nexample.js\n```js\nconst parallel = require('@async-generators/parallel').default;\n\nasync function* source() {\n  yield 1; yield 2; yield 3; yield 4;\n}\n\nfunction delay(item) {\n  let duration = {\n    1: 500,\n    2: 200,\n    3: 1000,\n    4: 700\n  }\n  return new Promise(r => setTimeout(r, duration[item ]));\n}\n\nasync function main() {\n  for await (let item of\n    parallel(source(), async (value) => {\n      await delay(value);\n      return value;\n    })\n  ) {\n    console.log(item);\n  }\n}\n\nmain();\n\n```\n\nExecute with the latest node.js: \n\n```\nnode --harmony-async-iteration example.js\n```\n\n\noutput:\n```\n2\n1\n4\n3\n```\n## Typescript\n\nThis library is fully typed and can be imported using: \n\n```ts\nimport parallel from '@async-generators/parallel');\n```\n\nIt is also possible to directly execute your [properly configured](https://stackoverflow.com/a/43694282/1657476) typescript with [ts-node](https://www.npmjs.com/package/ts-node):\n\n```\nts-node --harmony_async_iteration example.ts\n```\n\n[npm-url]: https://npmjs.org/package/@async-generators/parallel\n[npm-image]: https://img.shields.io/npm/v/@async-generators/parallel.svg\n[npm-downloads]: https://img.shields.io/npm/dm/@async-generators/parallel.svg\n[travis-url]: https://travis-ci.org/async-generators/parallel\n[travis-image]: https://img.shields.io/travis/async-generators/parallel/master.svg\n[codecov-url]: https://codecov.io/gh/async-generators/parallel\n[codecov-image]: https://codecov.io/gh/async-generators/parallel/branch/master/graph/badge.svg\n","maintainers":[{"name":"meirionhughes","email":"crakinshot@yahoo.com"}],"time":{"modified":"2022-04-04T16:01:22.367Z","created":"2017-09-21T01:03:06.932Z","0.1.0":"2017-09-21T01:03:06.932Z","0.2.0":"2017-09-22T15:20:01.873Z"},"homepage":"https://github.com/async-generators/parallel#readme","keywords":["map","select","async","iterator","generator","esnext","typescript","linq"],"repository":{"type":"git","url":"git+https://github.com/async-generators/parallel.git"},"author":{"name":"Meirion Hughes","email":"crakinshot@yahoo.com","url":"https://github.com/MeirionHughes"},"bugs":{"url":"https://github.com/async-generators/parallel/issues"},"license":"MIT","readmeFilename":"README.md"}