{ "_args": [ [ { "raw": "after@0.8.2", "scope": null, "escapedName": "after", "name": "after", "rawSpec": "0.8.2", "spec": "0.8.2", "type": "version" }, "/Users/fzy/project/3mang/node_modules/engine.io-parser" ] ], "_from": "after@0.8.2", "_id": "after@0.8.2", "_inCache": true, "_location": "/after", "_nodeVersion": "0.10.32", "_npmOperationalInternal": { "host": "packages-12-west.internal.npmjs.com", "tmp": "tmp/after-0.8.2.tgz_1471308639186_0.9132961586583406" }, "_npmUser": { "name": "raynos", "email": "raynos2@gmail.com" }, "_npmVersion": "2.15.9", "_phantomChildren": {}, "_requested": { "raw": "after@0.8.2", "scope": null, "escapedName": "after", "name": "after", "rawSpec": "0.8.2", "spec": "0.8.2", "type": "version" }, "_requiredBy": [ "/engine.io-parser" ], "_resolved": "https://registry.npmjs.org/after/-/after-0.8.2.tgz", "_shasum": "fedb394f9f0e02aa9768e702bda23b505fae7e1f", "_shrinkwrap": null, "_spec": "after@0.8.2", "_where": "/Users/fzy/project/3mang/node_modules/engine.io-parser", "author": { "name": "Raynos", "email": "raynos2@gmail.com" }, "bugs": { "url": "https://github.com/Raynos/after/issues" }, "contributors": [ { "name": "Raynos", "email": "raynos2@gmail.com", "url": "http://raynos.org" } ], "dependencies": {}, "description": "after - tiny flow control", "devDependencies": { "mocha": "~1.8.1" }, "directories": {}, "dist": { "shasum": "fedb394f9f0e02aa9768e702bda23b505fae7e1f", "tarball": "https://registry.npmjs.org/after/-/after-0.8.2.tgz" }, "gitHead": "e8c26046f36962b90e68dc5df33a9672a54b25f5", "homepage": "https://github.com/Raynos/after#readme", "keywords": [ "flowcontrol", "after", "flow", "control", "arch" ], "license": "MIT", "maintainers": [ { "name": "raynos", "email": "raynos2@gmail.com" }, { "name": "defunctzombie", "email": "shtylman@gmail.com" } ], "name": "after", "optionalDependencies": {}, "readme": "# After [![Build Status][1]][2]\n\nInvoke callback after n calls\n\n## Status: production ready\n\n## Example\n\n```js\nvar after = require(\"after\")\nvar db = require(\"./db\") // some db.\n\nvar updateUser = function (req, res) {\n // use after to run two tasks in parallel,\n // namely get request body and get session\n // then run updateUser with the results\n var next = after(2, updateUser)\n var results = {}\n \n getJSONBody(req, res, function (err, body) {\n if (err) return next(err)\n \n results.body = body\n next(null, results)\n })\n \n getSessionUser(req, res, function (err, user) {\n if (err) return next(err)\n \n results.user = user\n next(null, results)\n })\n \n // now do the thing!\n function updateUser(err, result) {\n if (err) {\n res.statusCode = 500\n return res.end(\"Unexpected Error\")\n }\n \n if (!result.user || result.user.role !== \"admin\") {\n res.statusCode = 403\n return res.end(\"Permission Denied\")\n }\n \n db.put(\"users:\" + req.params.userId, result.body, function (err) {\n if (err) {\n res.statusCode = 500\n return res.end(\"Unexpected Error\")\n }\n \n res.statusCode = 200\n res.end(\"Ok\") \n }) \n }\n}\n```\n\n## Naive Example\n\n```js\nvar after = require(\"after\")\n , next = after(3, logItWorks)\n\nnext()\nnext()\nnext() // it works\n\nfunction logItWorks() {\n console.log(\"it works!\")\n}\n```\n\n## Example with error handling\n\n```js\nvar after = require(\"after\")\n , next = after(3, logError)\n\nnext()\nnext(new Error(\"oops\")) // logs oops\nnext() // does nothing\n\n// This callback is only called once.\n// If there is an error the callback gets called immediately\n// this avoids the situation where errors get lost.\nfunction logError(err) {\n console.log(err)\n}\n```\n\n## Installation\n\n`npm install after`\n\n## Tests\n\n`npm test`\n\n## Contributors\n\n - Raynos\n - defunctzombie\n\n## MIT Licenced\n\n [1]: https://secure.travis-ci.org/Raynos/after.png\n [2]: http://travis-ci.org/Raynos/after\n [3]: http://raynos.org/blog/2/Flow-control-in-node.js\n [4]: http://stackoverflow.com/questions/6852059/determining-the-end-of-asynchronous-operations-javascript/6852307#6852307\n [5]: http://stackoverflow.com/questions/6869872/in-javascript-what-are-best-practices-for-executing-multiple-asynchronous-functi/6870031#6870031\n [6]: http://stackoverflow.com/questions/6864397/javascript-performance-long-running-tasks/6889419#6889419\n [7]: http://stackoverflow.com/questions/6597493/synchronous-database-queries-with-node-js/6620091#6620091\n [8]: http://github.com/Raynos/iterators\n [9]: http://github.com/Raynos/composite\n", "readmeFilename": "README.md", "repository": { "type": "git", "url": "git://github.com/Raynos/after.git" }, "scripts": { "test": "mocha --ui tdd --reporter spec test/*.js" }, "version": "0.8.2" }