{"_id":"after-all","_rev":"411076","name":"after-all","description":"Execute several async functions and get a callback when they are all done","dist-tags":{"latest":"2.0.2"},"maintainers":[{"name":"sorribas","email":"eduardo@sorribas.org"}],"time":{"modified":"2021-08-04T05:08:44.000Z","created":"2014-01-29T22:08:54.694Z","2.0.2":"2015-03-24T13:33:25.206Z","2.0.1":"2014-08-29T12:25:58.193Z","2.0.0":"2014-06-30T12:12:42.456Z","1.1.0":"2014-06-23T18:21:56.867Z","1.0.0":"2014-04-25T08:31:08.183Z","0.1.1":"2014-03-17T13:51:03.400Z","0.1.0":"2014-02-24T22:17:39.033Z","0.0.4":"2014-02-24T14:11:57.288Z","0.0.3":"2014-02-03T23:49:16.613Z","0.0.2":"2014-01-29T22:18:11.895Z","0.0.1":"2014-01-29T22:08:54.694Z"},"users":{"maxgfeller":true,"nichoth":true},"author":{"name":"Eduardo Sorribas","email":"eduardo@sorribas.org","url":"http://sorribas.org/"},"repository":{"type":"git","url":"https://github.com/sorribas/after-all.git"},"versions":{"2.0.2":{"name":"after-all","version":"2.0.2","description":"Execute several async functions and get a callback when they are all done","main":"index.js","directories":{"test":"test"},"repository":{"type":"git","url":"https://github.com/sorribas/after-all.git"},"scripts":{"test":"tape test","sauce":"node test/sauce.js"},"author":{"name":"Eduardo Sorribas","email":"eduardo@sorribas.org","url":"http://sorribas.org/"},"license":"MIT","devDependencies":{"brtapsauce":"^0.4.0","tape":"^2.13.3"},"dependencies":{"once":"^1.3.0"},"gitHead":"aae529dc46733cec6377985e789ae603edf36835","bugs":{"url":"https://github.com/sorribas/after-all/issues"},"homepage":"https://github.com/sorribas/after-all","_id":"after-all@2.0.2","_shasum":"20300298ed6094b4c85c98e7c8ad4dca628f9f73","_from":".","_npmVersion":"1.4.21","_npmUser":{"name":"sorribas","email":"eduardo@sorribas.org"},"maintainers":[{"name":"sorribas","email":"eduardo@sorribas.org"}],"dist":{"shasum":"20300298ed6094b4c85c98e7c8ad4dca628f9f73","size":3867,"noattachment":false,"key":"/after-all/-/after-all-2.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/after-all/download/after-all-2.0.2.tgz"},"publish_time":1427204005206,"_cnpm_publish_time":1427204005206,"_hasShrinkwrap":false},"2.0.1":{"name":"after-all","version":"2.0.1","description":"Execute several async functions and get a callback when they are all done","main":"index.js","directories":{"test":"test"},"repository":{"type":"git","url":"https://github.com/sorribas/after-all.git"},"scripts":{"test":"tape test"},"author":{"name":"Eduardo Sorribas","email":"eduardo@sorribas.org","url":"http://sorribas.org/"},"license":"MIT","devDependencies":{"tape":"^2.13.3"},"dependencies":{"once":"^1.3.0"},"testling":{"files":"test/index.js","browsers":["ie/8..latest","firefox/17..latest","firefox/nightly","chrome/22..latest","chrome/canary","opera/12..latest","opera/next","safari/5.1..latest","ipad/6.0..latest","iphone/6.0..latest","android-browser/4.2..latest"]},"gitHead":"252f2f262162b818c279b85bc18ca52a6bfa0ced","bugs":{"url":"https://github.com/sorribas/after-all/issues"},"homepage":"https://github.com/sorribas/after-all","_id":"after-all@2.0.1","_shasum":"d6f81e15b3211990a5fc268715291f2e0be507e5","_from":".","_npmVersion":"1.4.21","_npmUser":{"name":"sorribas","email":"eduardo@sorribas.org"},"maintainers":[{"name":"sorribas","email":"eduardo@sorribas.org"}],"dist":{"shasum":"d6f81e15b3211990a5fc268715291f2e0be507e5","size":3333,"noattachment":false,"key":"/after-all/-/after-all-2.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/after-all/download/after-all-2.0.1.tgz"},"publish_time":1409315158193,"_cnpm_publish_time":1409315158193,"_hasShrinkwrap":false},"2.0.0":{"name":"after-all","version":"2.0.0","description":"Execute several async functions and get a callback when they are all done","main":"index.js","directories":{"test":"test"},"repository":{"type":"git","url":"https://github.com/sorribas/after-next.git"},"scripts":{"test":"tape test"},"author":{"name":"Eduardo Sorribas","email":"eduardo@sorribas.org","url":"http://sorribas.org/"},"license":"MIT","devDependencies":{"tape":"^2.13.3"},"dependencies":{"once":"^1.3.0"},"bugs":{"url":"https://github.com/sorribas/after-next/issues"},"homepage":"https://github.com/sorribas/after-next","_id":"after-all@2.0.0","_shasum":"9d7a7ac8c8b6d37e7a6ce18ca50dabc55826d6f3","_from":".","_npmVersion":"1.4.9","_npmUser":{"name":"sorribas","email":"eduardo@sorribas.org"},"maintainers":[{"name":"sorribas","email":"eduardo@sorribas.org"}],"dist":{"shasum":"9d7a7ac8c8b6d37e7a6ce18ca50dabc55826d6f3","size":3207,"noattachment":false,"key":"/after-all/-/after-all-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/after-all/download/after-all-2.0.0.tgz"},"publish_time":1404130362456,"_cnpm_publish_time":1404130362456,"_hasShrinkwrap":false},"1.1.0":{"name":"after-all","version":"1.1.0","description":"Execute several async functions and get a callback when they are all done","main":"index.js","directories":{"test":"test"},"repository":{"type":"git","url":"https://github.com/sorribas/after-next.git"},"scripts":{"test":"node_modules/mocha/bin/mocha"},"author":{"name":"Eduardo Sorribas","email":"eduardo@sorribas.org","url":"http://sorribas.org/"},"license":"MIT","devDependencies":{"mocha":"1.17.1","should":"3.1.2"},"bugs":{"url":"https://github.com/sorribas/after-next/issues"},"homepage":"https://github.com/sorribas/after-next","_id":"after-all@1.1.0","_shasum":"487724fb1746db77ff8f2c1c3c6472ce6e27ae5b","_from":".","_npmVersion":"1.4.9","_npmUser":{"name":"sorribas","email":"eduardo@sorribas.org"},"maintainers":[{"name":"sorribas","email":"eduardo@sorribas.org"}],"dist":{"shasum":"487724fb1746db77ff8f2c1c3c6472ce6e27ae5b","size":3105,"noattachment":false,"key":"/after-all/-/after-all-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/after-all/download/after-all-1.1.0.tgz"},"publish_time":1403547716867,"_cnpm_publish_time":1403547716867,"_hasShrinkwrap":false},"1.0.0":{"name":"after-all","version":"1.0.0","description":"Execute several async functions and get a callback when they are all done","main":"index.js","directories":{"test":"test"},"repository":{"type":"git","url":"https://github.com/sorribas/after-next.git"},"scripts":{"test":"node_modules/mocha/bin/mocha"},"author":{"name":"Eduardo Sorribas","email":"eduardo@sorribas.org","url":"http://sorribas.org/"},"license":"MIT","devDependencies":{"mocha":"1.17.1","should":"3.1.2"},"bugs":{"url":"https://github.com/sorribas/after-next/issues"},"homepage":"https://github.com/sorribas/after-next","_id":"after-all@1.0.0","dist":{"shasum":"b312e90c11f9c5c54482e3c1c345d280a91d8f3f","size":2904,"noattachment":false,"key":"/after-all/-/after-all-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/after-all/download/after-all-1.0.0.tgz"},"_from":".","_npmVersion":"1.3.25","_npmUser":{"name":"sorribas","email":"eduardo@sorribas.org"},"maintainers":[{"name":"sorribas","email":"eduardo@sorribas.org"}],"publish_time":1398414668183,"_cnpm_publish_time":1398414668183,"_hasShrinkwrap":false},"0.1.1":{"name":"after-all","version":"0.1.1","description":"Execute several async functions and get a callback when they are all done","main":"index.js","directories":{"test":"test"},"repository":{"type":"git","url":"https://github.com/sorribas/after-next.git"},"scripts":{"test":"node_modules/mocha/bin/mocha"},"author":{"name":"Eduardo Sorribas","email":"eduardo@sorribas.org","url":"http://sorribas.org/"},"license":"MIT","devDependencies":{"mocha":"1.17.1","should":"3.1.2"},"bugs":{"url":"https://github.com/sorribas/after-next/issues"},"homepage":"https://github.com/sorribas/after-next","_id":"after-all@0.1.1","dist":{"shasum":"9ff6b53559fb36b5bb7822d29bc69f7676b26211","size":2860,"noattachment":false,"key":"/after-all/-/after-all-0.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/after-all/download/after-all-0.1.1.tgz"},"_from":".","_npmVersion":"1.3.25","_npmUser":{"name":"sorribas","email":"eduardo@sorribas.org"},"maintainers":[{"name":"sorribas","email":"eduardo@sorribas.org"}],"publish_time":1395064263400,"_hasShrinkwrap":false,"_cnpm_publish_time":1395064263400},"0.1.0":{"name":"after-all","version":"0.1.0","description":"Execute several async functions and get a callback when they are all done","main":"index.js","directories":{"test":"test"},"repository":{"type":"git","url":"https://github.com/sorribas/after-next.git"},"scripts":{"test":"node_modules/mocha/bin/mocha"},"author":{"name":"Eduardo Sorribas","email":"eduardo@sorribas.org","url":"http://sorribas.org/"},"license":"MIT","devDependencies":{"mocha":"1.17.1","should":"3.1.2"},"bugs":{"url":"https://github.com/sorribas/after-next/issues"},"_id":"after-all@0.1.0","dist":{"shasum":"3b26acefff573150aae835ccca2ba9333519aa45","size":2708,"noattachment":false,"key":"/after-all/-/after-all-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/after-all/download/after-all-0.1.0.tgz"},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"sorribas","email":"eduardo@sorribas.org"},"maintainers":[{"name":"sorribas","email":"eduardo@sorribas.org"}],"publish_time":1393280259033,"_hasShrinkwrap":false,"_cnpm_publish_time":1393280259033},"0.0.4":{"name":"after-all","version":"0.0.4","description":"Execute several async functions and get a callback when they are all done","main":"index.js","directories":{"test":"test"},"repository":{"type":"git","url":"https://github.com/sorribas/after-next.git"},"scripts":{"test":"node_modules/mocha/bin/mocha"},"author":{"name":"Eduardo Sorribas","email":"eduardo@sorribas.org","url":"http://sorribas.org/"},"license":"MIT","devDependencies":{"mocha":"1.17.1","should":"3.1.2"},"bugs":{"url":"https://github.com/sorribas/after-next/issues"},"homepage":"https://github.com/sorribas/after-next","_id":"after-all@0.0.4","dist":{"shasum":"b13e6454774c9c7246ab5b3ab499c55d51d00549","size":2457,"noattachment":false,"key":"/after-all/-/after-all-0.0.4.tgz","tarball":"http://registry.cnpm.dingdandao.com/after-all/download/after-all-0.0.4.tgz"},"_from":".","_npmVersion":"1.3.25","_npmUser":{"name":"sorribas","email":"eduardo@sorribas.org"},"maintainers":[{"name":"sorribas","email":"eduardo@sorribas.org"}],"publish_time":1393251117288,"_hasShrinkwrap":false,"_cnpm_publish_time":1393251117288},"0.0.3":{"name":"after-all","version":"0.0.3","description":"Execute several async functions and get a callback when they are all done","main":"index.js","directories":{"test":"test"},"repository":{"type":"git","url":"https://github.com/sorribas/after-next.git"},"scripts":{"test":"node_modules/mocha/bin/mocha"},"author":{"name":"Eduardo Sorribas","email":"eduardo@sorribas.org","url":"http://sorribas.org/"},"license":"MIT","devDependencies":{"mocha":"1.17.1","should":"3.1.2"},"bugs":{"url":"https://github.com/sorribas/after-next/issues"},"_id":"after-all@0.0.3","dist":{"shasum":"29e96af7d010a0ceee96034cb06a38f63a406e73","size":1681,"noattachment":false,"key":"/after-all/-/after-all-0.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/after-all/download/after-all-0.0.3.tgz"},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"sorribas","email":"eduardo@sorribas.org"},"maintainers":[{"name":"sorribas","email":"eduardo@sorribas.org"}],"publish_time":1391471356613,"_hasShrinkwrap":false,"_cnpm_publish_time":1391471356613},"0.0.2":{"name":"after-all","version":"0.0.2","description":"Execute several async functions and get a callback when they are all done","main":"index.js","directories":{"test":"test"},"repository":{"type":"git","url":"https://github.com/sorribas/after-next.git"},"scripts":{"test":"node_modules/mocha/bin/mocha"},"author":{"name":"Eduardo Sorribas","email":"eduardo@sorribas.org","url":"http://sorribas.org/"},"license":"MIT","devDependencies":{"mocha":"1.17.1","should":"3.1.2"},"bugs":{"url":"https://github.com/sorribas/after-next/issues"},"_id":"after-all@0.0.2","dist":{"shasum":"086ad2195625faa9d9645c7045f6f0aa22d8b227","size":1463,"noattachment":false,"key":"/after-all/-/after-all-0.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/after-all/download/after-all-0.0.2.tgz"},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"sorribas","email":"eduardo@sorribas.org"},"maintainers":[{"name":"sorribas","email":"eduardo@sorribas.org"}],"publish_time":1391033891895,"_hasShrinkwrap":false,"_cnpm_publish_time":1391033891895},"0.0.1":{"name":"after-all","version":"0.0.1","description":"Execute several async functions and get a callback when they are all done","main":"index.js","directories":{"test":"test"},"repository":{"type":"git","url":"https://github.com/sorribas/after-next.git"},"scripts":{"test":"node_modules/mocha/bin/mocha"},"author":{"name":"Eduardo Sorribas","email":"eduardo@sorribas.org","url":"http://sorribas.org/"},"license":"MIT","devDependencies":{"mocha":"1.17.1","should":"3.1.2"},"bugs":{"url":"https://github.com/sorribas/after-next/issues"},"_id":"after-all@0.0.1","dist":{"shasum":"bac841cf333b7fc53102900b96fafcf555a1cf3c","size":1404,"noattachment":false,"key":"/after-all/-/after-all-0.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/after-all/download/after-all-0.0.1.tgz"},"_from":".","_npmVersion":"1.3.8","_npmUser":{"name":"sorribas","email":"eduardo@sorribas.org"},"maintainers":[{"name":"sorribas","email":"eduardo@sorribas.org"}],"publish_time":1391033334694,"_hasShrinkwrap":false,"_cnpm_publish_time":1391033334694}},"readme":"# after-all\n\n[![build status](https://secure.travis-ci.org/sorribas/after-all.png)](http://travis-ci.org/sorribas/after-all)\n\n[![Sauce Test Status](https://saucelabs.com/browser-matrix/after-all.svg)](https://saucelabs.com/u/after-all)\n\nCall several asynchronous functions and invoke a callback 'after all' of them are done.\n\n## Installation\n\nYou can install it with npm.\n\n```\nnpm install after-all\n```\n\n## Simple example\n\n```js\nvar afterAll = require('after-all');\n\nvar next = afterAll(function(err) {\n\tif (err) return console.log(err); // one of the asynchronous calls had an error\n\tconsole.log('Yay! Everything is done');\n});\n\n// The above inner function will only be called when all of these asynchronous calls are done\n\nsomeAsynchronousCall1({foo:'bar'}, next());\nsomeAsynchronousCall2({val:2}, next(function(err, res) {\n\t// If you want to do something with the returned value, you can pass a function\n\tif (err) return;\n\tconsole.log('This was returned: '+res);\n}));\n```\n\n## More complex example and sample use case\n\nImagine you have to create a dashboard page which has a list of customers\na list products, the total amount of sales and some more information.\n\nNow, the queries to get this information are independent, yet we tend to wait for\none to be finished to start the next. We may be able to increase the performance\nby starting some of this queries at the same time and waiting for the callbacks.\n\nWe can use after-all to do something like this.\n\n```js\n\napp.get('/dashboard.json', function(req, res) {\n  var resp = {};\n  var next = afterAll(function() {\n    res.end(resp);\n  });\n\n  db.findCustomers(next(function(err, docs) {\n    resp.customers = docs;\n  }));\n\n  var cb = next(); // wrapping the callback is optional\n  db.findProducts(function(err, docs) {\n    db.findProductsSales(function(sales) {\n      resp.products = docs;\n      resp.productsSales = sales;\n      cb();\n    });\n  });\n\n  db.findTodaySalesAmount(next(function(err, amount) {\n    resp.todaySales = amount;\n  }));\n\n  db.findLastMonthSalesAmount(next(function(err, amount) {\n    resp.lastMonthSales = amount;\n  }));\n});\n```\n\nAs you can see, passing a callback to the `next` function is optional and it can be\nuseful to not pass any when you are doing more than one sequetial async operations as\nin the example above.\n\nAlso notice that all the calls to `next` must be done on the same tick.\n\n## Error handling\n\nIf an error is passed as the first parameter to the `next` callback, the \nfinal callback will be called immediately and the error will be passed to\nit as the first argument.\n\n## License\n\nMIT\n","_attachments":{},"homepage":"https://github.com/sorribas/after-all","bugs":{"url":"https://github.com/sorribas/after-all/issues"},"license":"MIT"}