{"_id":"promise-map-limit","_rev":"5-aeaa8808d53c7bee3fda80ab9503b5ab","name":"promise-map-limit","description":"Map an array n items at a time with promises","dist-tags":{"latest":"1.0.0"},"versions":{"1.0.0":{"name":"promise-map-limit","description":"Map an array n items at a time with promises","main":"index.js","files":["index.js"],"scripts":{"test":"jest","semantic-release":"semantic-release pre && npm publish && semantic-release post"},"devDependencies":{"jest":"^16.0.2","semantic-release":"^4.3.5"},"jest":{"testEnvironment":"node"},"engines":{"node":">=4"},"repository":{"type":"git","url":"git+https://github.com/dbrockman/promise-map-limit.git"},"keywords":["promise","limit","limited","concurrency","throttle","rate","batch","ratelimit","queue","async","await","promises"],"author":{"name":"David Brockman Smoliansky @dbrckmn"},"license":"MIT","bugs":{"url":"https://github.com/dbrockman/promise-map-limit/issues"},"homepage":"https://github.com/dbrockman/promise-map-limit#readme","version":"1.0.0","gitHead":"bf0cb69d9155c6172d60f62f9bffe1f148e8715d","_id":"promise-map-limit@1.0.0","_shasum":"ee8e7f306e1547b0a0ec59f881d4e990f6506d64","_from":".","_npmVersion":"3.10.9","_nodeVersion":"4.6.1","_npmUser":{"name":"dbrockman","email":"david.bs@gmail.com"},"dist":{"shasum":"ee8e7f306e1547b0a0ec59f881d4e990f6506d64","tarball":"https://registry.npmjs.org/promise-map-limit/-/promise-map-limit-1.0.0.tgz","integrity":"sha512-1XvMQQOajiDDLt+I/trMSovUFl7N7WmlyL2EVBEOKWUWZ2Hr9ApU/8MVyNQB4N32bk4HncFT1lwONawaHyfK6A==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCn53cxwB7+5Bt7t4yN4qajGdTEP3giANLx/Iolj9HKdwIgdv2CSjXQq0u7K8bxHNNoBDLVUSH7FSVPFeDeNcg899E="}]},"maintainers":[{"name":"dbrockman","email":"david.bs@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/promise-map-limit-1.0.0.tgz_1478122790132_0.12596070300787687"}}},"readme":"# promise-map-limit\n\nMap an array n items at a time with promises\n\n\n## API\n\n### `mapLimit(iterable, limit, iteratee)`\n\n#### Parameters:\n\n- `iterable` The collection to iterate over. The iterator interface will be used if it is implemented. If the collection does not implement the iterator interface then `Object.keys()` is used and values are iterated in the order of the keys.\n- `limit` The concurrency limit. The maximum number of async operations at a time.\n- `iteratee` The function that will be called with each value in `iterable`. It can return a `Promise` or a plain value if no async operation is needed. If the `iteratee` function throws then `mapLimit` aborts and rejects with the error.\n\n#### Returns:\n\n`mapLimit` returns a `Promise<Array>` that resolves with the transformed values from `iterable`.\nIf `iteratee` throws or returns a rejected promise then `mapLimit` will abort and return a rejected promise with the same error.\n\n## Example\n\n```js\nconst mapLimit = require('promise-map-limit');\n\n// This will work on max two items in the array at a time\n// When all items are processed it will resolve with the resulting array in the same order.\nmapLimit([1, 2, 3, 4], 2, n => Promise.resolve(n * 2)).then(array => {\n  // array == [2, 4, 6, 8]\n});\n\n// The iterator function can return the result synchronous\nmapLimit([1, 2, 3, 4], 2, n => n * 2).then(array => {\n  // array == [2, 4, 6, 8]\n});\n\n// Any value that implements the iterator interface can be used, such as Array, String, Map, Set\nmapLimit('abc', 2, str => str.toUpperCase()).then(array => {\n  // array == ['A', 'B', 'C']\n});\n\n// Any value that implements the iterator interface can be used, such as Array, String, Map, Set\nmapLimit('abc', 2, str => str.toUpperCase()).then(array => {\n  // array == ['A', 'B', 'C']\n});\n\n// Iterator object also implements the iterator interface\nconst arr = ['a', 'b', 'c'];\nconst iterator = a.entries();\nmapLimit(iterator, 2, entry => entry).then(array => {\n  // array == [\n  //   [0, 'a'],\n  //   [1, 'b'],\n  //   [2, 'c']\n  // ]\n});\n\n// If the iterator is omitted, each function in the array is executed\n// This will run max two functions at a time\nmapLimit([\n  () => Promise.resolve(1),\n  () => Promise.resolve(2),\n  () => 3, // can be sync\n  () => Promise.resolve(4),\n], 2).then(array => {\n  // array == [1, 2, 3, 4]\n});\n```\n","maintainers":[{"name":"dbrockman","email":"david.bs@gmail.com"}],"time":{"modified":"2022-06-24T18:50:13.649Z","created":"2016-11-02T21:39:50.672Z","1.0.0":"2016-11-02T21:39:50.672Z"},"homepage":"https://github.com/dbrockman/promise-map-limit#readme","keywords":["promise","limit","limited","concurrency","throttle","rate","batch","ratelimit","queue","async","await","promises"],"repository":{"type":"git","url":"git+https://github.com/dbrockman/promise-map-limit.git"},"author":{"name":"David Brockman Smoliansky @dbrckmn"},"bugs":{"url":"https://github.com/dbrockman/promise-map-limit/issues"},"license":"MIT","readmeFilename":"README.md","users":{"binki":true,"ljtijhuis":true}}