{"_id":"async-reduce","_rev":"6-23b1b7d86321f75aa8187d60aa2e6cd3","name":"async-reduce","description":"`reduce` function for async reductions on arrays.","dist-tags":{"latest":"0.0.1"},"versions":{"0.0.1":{"name":"async-reduce","version":"0.0.1","descirption":"function for async reductions on arrays with concurrency support as well","keywords":["reduce","async","array","parallel"],"author":{"name":"Eldar Gabdullin","email":"eldargab@gmail.com"},"repository":{"type":"git","url":"git://github.com/eldargab/async-reduce"},"devDependencies":{"mocha":"*","should":"*"},"scripts":{"test":"mocha -R spec"},"license":"MIT","readme":"#async-reduce\n\n`reduce` function for async reductions on arrays.\n\n##Examples\n\n```javascript\nvar reduce = require('async-reduce')\n\nfunction sum(a, b, cb) {\n  setTimeout(function() {\n    cb(null, a + b)\n  })\n}\n\nreduce([1, 2, 3], 1, sum, function(err, result) {\n  result.should.equal(7)\n})\n```\n\nConcurrent reductions are also supported\n\n```javascript\nvar reduce = require('async-reduce').concurrent(2, 0, function(a, b) {\n  return a + b\n})\n\nreduce([1, 2, 3], 1, sum, function(err, result) {\n  result.should.equal(7) // still the same result\n})\n```\n\nDuring such reduction the given array is splitted into several\nchunks with total chunks number equal to concurrency level (it is\nthe first arg to `.concurrent()`).\nThat chunks are reduced in parallel. That means that we need a\n`combine` function to assembel results from that independent reductions\n(third arg). We also need some sort of `unit` value to seed our\nreductions (second arg). But we can omit `unit` and `combine`\nif we only interested in side effects:\n\n```javascript\nvar reduce = require('async-reduce').concurrent(5)\nvar items = []\n\nreduce([1, 2, 3], null, function(_, item, cb) {\n  items.push(item)\n  cb()\n}, function(err) {\n  items.should.include(1)\n  items.should.include(2)\n  items.should.include(3)\n})\n```\n\nThis lib takes care about sync callback calls. They do not cause stack overflows.\n\n##Installation\n\nvia component\n\n```\ncomponent install eldargab/async-reduce\n```\n\nvia npm\n\n```\nnpm install async-reduce\n```\n\n##License\n\nMIT\n","readmeFilename":"README.md","description":"`reduce` function for async reductions on arrays.","bugs":{"url":"https://github.com/eldargab/async-reduce/issues"},"_id":"async-reduce@0.0.1","dist":{"shasum":"b236b5f376d6fae381cded9006aa7f2c73b17f31","tarball":"https://registry.npmjs.org/async-reduce/-/async-reduce-0.0.1.tgz","integrity":"sha512-V+++J60MmOEe3+W5RS1O/3QrRjs846F90AJlRQKUou+I9XqVeXZ5z+9qxipCQnXZNjQ7da9sFSE1u4wXey7KMQ==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEYCIQCKTl95Nd9ugZ450bciH9L+1s2DCC7b88j4GFpTRpdudwIhAI6oQ/3ChLSAq2nFoy7arYRyJoyMT299Lv282hZzi1KL"}]},"_from":".","_npmVersion":"1.2.32","_npmUser":{"name":"eldar","email":"eldargab@gmail.com"},"maintainers":[{"name":"eldar","email":"eldargab@gmail.com"}]}},"readme":"#async-reduce\n\n`reduce` function for async reductions on arrays.\n\n##Examples\n\n```javascript\nvar reduce = require('async-reduce')\n\nfunction sum(a, b, cb) {\n  setTimeout(function() {\n    cb(null, a + b)\n  })\n}\n\nreduce([1, 2, 3], 1, sum, function(err, result) {\n  result.should.equal(7)\n})\n```\n\nConcurrent reductions are also supported\n\n```javascript\nvar reduce = require('async-reduce').concurrent(2, 0, function(a, b) {\n  return a + b\n})\n\nreduce([1, 2, 3], 1, sum, function(err, result) {\n  result.should.equal(7) // still the same result\n})\n```\n\nDuring such reduction the given array is splitted into several\nchunks with total chunks number equal to concurrency level (it is\nthe first arg to `.concurrent()`).\nThat chunks are reduced in parallel. That means that we need a\n`combine` function to assembel results from that independent reductions\n(third arg). We also need some sort of `unit` value to seed our\nreductions (second arg). But we can omit `unit` and `combine`\nif we only interested in side effects:\n\n```javascript\nvar reduce = require('async-reduce').concurrent(5)\nvar items = []\n\nreduce([1, 2, 3], null, function(_, item, cb) {\n  items.push(item)\n  cb()\n}, function(err) {\n  items.should.include(1)\n  items.should.include(2)\n  items.should.include(3)\n})\n```\n\nThis lib takes care about sync callback calls. They do not cause stack overflows.\n\n##Installation\n\nvia component\n\n```\ncomponent install eldargab/async-reduce\n```\n\nvia npm\n\n```\nnpm install async-reduce\n```\n\n##License\n\nMIT\n","maintainers":[{"name":"eldar","email":"eldargab@gmail.com"}],"time":{"modified":"2022-06-13T03:37:38.225Z","created":"2013-07-03T10:15:35.777Z","0.0.1":"2013-07-03T10:15:39.585Z"},"author":{"name":"Eldar Gabdullin","email":"eldargab@gmail.com"},"repository":{"type":"git","url":"git://github.com/eldargab/async-reduce"},"users":{"vak":true}}