{"maintainers":[{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"}],"keywords":["promise","aplus","then","throttle","concurrency","parallelism","limit"],"dist-tags":{"latest":"3.0.0"},"author":{"name":"ForbesLindesay"},"description":"Throttle the parallelism of an asynchronous (promise returning) function / functions","readme":"# throat\n\nThrottle the parallelism of an asynchronous, promise returning, function / functions.  This has special utility when you set the concurrency to `1`.  That way you get a mutually exclusive lock.\n\n[![Build Status](https://img.shields.io/travis/ForbesLindesay/throat/master.svg)](https://travis-ci.org/ForbesLindesay/throat)\n[![Coverage Status](https://img.shields.io/coveralls/ForbesLindesay/throat/master.svg?style=flat)](https://coveralls.io/r/ForbesLindesay/throat?branch=master)\n[![Dependency Status](https://img.shields.io/david/ForbesLindesay/throat.svg)](https://david-dm.org/ForbesLindesay/throat)\n[![NPM version](https://img.shields.io/npm/v/throat.svg)](https://www.npmjs.com/package/throat)\n\n[![Sauce Test Status](https://saucelabs.com/browser-matrix/throat.svg)](https://saucelabs.com/u/throat)\n\n## Installation\n\n    npm install throat\n\n## API\n\n### throat(concurrency)\n\nThis returns a function that acts a bit like a lock (exactly as a lock if concurrency is 1).\n\nExample, only 2 of the following functions will execute at any one time:\n\n```js\n// with polyfill or in iojs\nrequire('promise/polyfill')\nvar throat = require('throat')(2)\n// alternatively provide your own promise implementation\nvar throat = require('throat')(require('promise'))(2)\n\nvar resA = throat(function () {\n  //async stuff\n  return promise\n})\nvar resA = throat(function () {\n  //async stuff\n  return promise\n})\nvar resA = throat(function () {\n  //async stuff\n  return promise\n})\nvar resA = throat(function () {\n  //async stuff\n  return promise\n})\nvar resA = throat(function () {\n  //async stuff\n  return promise\n})\n```\n\n### throat(concurrency, worker)\n\nThis returns a function that is an exact copy of `worker` except that it will only execute up to `concurrency` times in parallel before further requests are queued:\n\n```js\n// with polyfill or in iojs\nrequire('promise/polyfill')\nvar throat = require('throat')\n// alternatively provide your own promise implementation\nvar throat = require('throat')(require('promise'))\n\nvar input = ['fileA.txt', 'fileB.txt', 'fileC.txt', 'fileD.txt']\nvar data = Promise.all(input.map(throat(2, function (fileName) {\n  return readFile(fileName)\n})))\n```\n\nOnly 2 files will be read at a time, sometimes limiting parallelism in this way can improve scalability.\n\n## License\n\n  MIT\n","repository":{"type":"git","url":"git+https://github.com/ForbesLindesay/throat.git"},"users":{"icflorescu":true,"timdp":true,"cmtegner":true},"bugs":{"url":"https://github.com/ForbesLindesay/throat/issues"},"license":"MIT","versions":{"0.0.0":{"name":"throat","version":"0.0.0","description":"Throttle a collection of promise returning functions","main":"index.js","scripts":{"test":"mocha -R spec"},"repository":{"type":"git","url":"https://github.com/ForbesLindesay/throat.git"},"keywords":["promise","aplus","then","throttle","concurrency","limit"],"author":{"name":"ForbesLindesay"},"license":"MIT","dependencies":{"promises-a":"~2"},"devDependencies":{"mocha":"~1","better-assert":"~0.1.0"},"_id":"throat@0.0.0","dist":{"shasum":"2bf638b8824510e14b1348f318deb01c06bd9478","tarball":"http://nexus.dui88.com:8081/nexus/content/groups/npm-all/throat/-/throat-0.0.0.tgz"},"_npmVersion":"1.1.59","_npmUser":{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"},"maintainers":[{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"}],"directories":{}},"1.0.0":{"name":"throat","version":"1.0.0","description":"Throttle the parallelism of an asynchronous (promise returning) function / functions","keywords":["promise","aplus","then","throttle","concurrency","parallelism","limit"],"dependencies":{"promise":"~3.2.0"},"devDependencies":{"mocha":"*"},"scripts":{"test":"mocha -R spec"},"repository":{"type":"git","url":"https://github.com/ForbesLindesay/throat.git"},"author":{"name":"ForbesLindesay"},"license":"MIT","_id":"throat@1.0.0","dist":{"shasum":"04c9e0f9ce88e250db630fdeabc2e5bb152a0625","tarball":"http://nexus.dui88.com:8081/nexus/content/groups/npm-all/throat/-/throat-1.0.0.tgz"},"_from":".","_npmVersion":"1.2.10","_npmUser":{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"},"maintainers":[{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"}],"directories":{}},"2.0.0":{"name":"throat","version":"2.0.0","description":"Throttle the parallelism of an asynchronous (promise returning) function / functions","keywords":["promise","aplus","then","throttle","concurrency","parallelism","limit"],"dependencies":{},"devDependencies":{"coveralls":"^2.11.2","istanbul":"^0.3.5","promise":"^6.1.0","sauce-test":"^1.0.0","test-result":"^2.0.0","testit":"^2.0.2"},"scripts":{"test":"node test/index.js && node test/browser.js","coverage":"istanbul cover test/index.js","coveralls":"npm run coverage && cat ./coverage/lcov.info | coveralls"},"repository":{"type":"git","url":"https://github.com/ForbesLindesay/throat.git"},"author":{"name":"ForbesLindesay"},"license":"MIT","gitHead":"77a3106be863d0167d30317e8efd87ed40230161","bugs":{"url":"https://github.com/ForbesLindesay/throat/issues"},"homepage":"https://github.com/ForbesLindesay/throat","_id":"throat@2.0.0","_shasum":"720d03e0f270e4452d87a345025412e35883e24c","_from":".","_npmVersion":"2.5.1","_nodeVersion":"0.12.0","_npmUser":{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"},"maintainers":[{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"}],"dist":{"shasum":"720d03e0f270e4452d87a345025412e35883e24c","tarball":"http://nexus.dui88.com:8081/nexus/content/groups/npm-all/throat/-/throat-2.0.0.tgz"},"directories":{}},"2.0.1":{"name":"throat","version":"2.0.1","description":"Throttle the parallelism of an asynchronous (promise returning) function / functions","keywords":["promise","aplus","then","throttle","concurrency","parallelism","limit"],"dependencies":{},"devDependencies":{"coveralls":"^2.11.2","istanbul":"^0.3.5","promise":"^6.1.0","sauce-test":"^1.0.0","test-result":"^2.0.0","testit":"^2.0.2"},"scripts":{"test":"node test/index.js && node test/browser.js","coverage":"istanbul cover test/index.js","coveralls":"npm run coverage && cat ./coverage/lcov.info | coveralls"},"repository":{"type":"git","url":"https://github.com/ForbesLindesay/throat.git"},"author":{"name":"ForbesLindesay"},"license":"MIT","gitHead":"e6881d62970a8d4abef4ea9e34815b2ba3d5f067","bugs":{"url":"https://github.com/ForbesLindesay/throat/issues"},"homepage":"https://github.com/ForbesLindesay/throat","_id":"throat@2.0.1","_shasum":"ae9034aeb023cfee3c2d080653f20936b15711e8","_from":".","_npmVersion":"2.5.1","_nodeVersion":"0.12.0","_npmUser":{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"},"maintainers":[{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"}],"dist":{"shasum":"ae9034aeb023cfee3c2d080653f20936b15711e8","tarball":"http://nexus.dui88.com:8081/nexus/content/groups/npm-all/throat/-/throat-2.0.1.tgz"},"directories":{}},"2.0.2":{"name":"throat","version":"2.0.2","description":"Throttle the parallelism of an asynchronous (promise returning) function / functions","keywords":["promise","aplus","then","throttle","concurrency","parallelism","limit"],"dependencies":{},"devDependencies":{"coveralls":"^2.11.2","istanbul":"^0.3.5","promise":"^6.1.0","sauce-test":"^1.0.0","test-result":"^2.0.0","testit":"^2.0.2"},"scripts":{"test":"node test/index.js && node test/browser.js","coverage":"istanbul cover test/index.js","coveralls":"npm run coverage && cat ./coverage/lcov.info | coveralls"},"repository":{"type":"git","url":"https://github.com/ForbesLindesay/throat.git"},"author":{"name":"ForbesLindesay"},"license":"MIT","gitHead":"4cb485f83e0521d661aaaac02162138686bc3908","bugs":{"url":"https://github.com/ForbesLindesay/throat/issues"},"homepage":"https://github.com/ForbesLindesay/throat","_id":"throat@2.0.2","_shasum":"a9fce808b69e133a632590780f342c30a6249b02","_from":".","_npmVersion":"1.4.28","_npmUser":{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"},"maintainers":[{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"}],"dist":{"shasum":"a9fce808b69e133a632590780f342c30a6249b02","tarball":"http://nexus.dui88.com:8081/nexus/content/groups/npm-all/throat/-/throat-2.0.2.tgz"},"directories":{}},"3.0.0":{"name":"throat","version":"3.0.0","description":"Throttle the parallelism of an asynchronous (promise returning) function / functions","keywords":["promise","aplus","then","throttle","concurrency","parallelism","limit"],"dependencies":{},"devDependencies":{"coveralls":"^2.11.2","istanbul":"^0.3.5","promise":"^6.1.0","sauce-test":"^1.0.0","test-result":"^2.0.0","testit":"^2.0.5"},"scripts":{"test":"node test/index.js && node test/browser.js","coverage":"istanbul cover test/index.js","coveralls":"npm run coverage && cat ./coverage/lcov.info | coveralls"},"repository":{"type":"git","url":"git+https://github.com/ForbesLindesay/throat.git"},"author":{"name":"ForbesLindesay"},"license":"MIT","gitHead":"d77de8defd2d8049c06ccf314587890f9e620ac3","bugs":{"url":"https://github.com/ForbesLindesay/throat/issues"},"homepage":"https://github.com/ForbesLindesay/throat#readme","_id":"throat@3.0.0","_shasum":"e7c64c867cbb3845f10877642f7b60055b8ec0d6","_from":".","_npmVersion":"3.8.9","_nodeVersion":"6.2.0","_npmUser":{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"},"dist":{"shasum":"e7c64c867cbb3845f10877642f7b60055b8ec0d6","tarball":"http://nexus.dui88.com:8081/nexus/content/groups/npm-all/throat/-/throat-3.0.0.tgz"},"maintainers":[{"name":"forbeslindesay","email":"forbes@lindesay.co.uk"}],"_npmOperationalInternal":{"host":"packages-16-east.internal.npmjs.com","tmp":"tmp/throat-3.0.0.tgz_1464777827074_0.20422574575059116"},"directories":{}}},"name":"throat","time":{"modified":"2017-01-24T12:59:41.598Z","created":"2012-12-23T00:17:08.786Z","0.0.0":"2012-12-23T00:17:11.379Z","1.0.0":"2013-07-27T01:28:08.597Z","2.0.0":"2015-02-14T11:40:40.469Z","2.0.1":"2015-02-14T12:55:25.270Z","2.0.2":"2015-02-16T09:39:45.954Z","3.0.0":"2016-06-01T10:43:48.228Z"},"readmeFilename":"README.md","homepage":"https://github.com/ForbesLindesay/throat#readme"}