{
  "name": "after",
  "description": "after - tiny flow control",
  "version": "0.8.2",
  "author": {
    "name": "Raynos",
    "email": "raynos2@gmail.com"
  },
  "contributors": [
    {
      "name": "Raynos",
      "email": "raynos2@gmail.com",
      "url": "http://raynos.org"
    }
  ],
  "scripts": {
    "test": "mocha --ui tdd --reporter spec test/*.js"
  },
  "devDependencies": {
    "mocha": "~1.8.1"
  },
  "keywords": [
    "flowcontrol",
    "after",
    "flow",
    "control",
    "arch"
  ],
  "license": "MIT",
  "repository": {
    "type": "git",
    "url": "git://github.com/Raynos/after.git"
  },
  "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",
  "bugs": {
    "url": "https://github.com/Raynos/after/issues"
  },
  "homepage": "https://github.com/Raynos/after",
  "_id": "after@0.8.2",
  "_shasum": "fedb394f9f0e02aa9768e702bda23b505fae7e1f",
  "_from": "after@0.8.2",
  "_resolved": "https://registry.npmjs.org/after/-/after-0.8.2.tgz"
}
