{"name":"throwback","version":"2.0.0","description":"An asynchronous middleware pattern","main":"dist/index.js","typings":"dist/index.d.ts","files":["dist/","README.md","LICENSE"],"scripts":{"lint":"tslint \"src/**/*.ts\"","build":"rm -rf dist && tsc","test-spec":"blue-tape 'dist/**/*.spec.js' | tap-spec","test-cov":"istanbul cover --print none -x '*.spec.js' node_modules/blue-tape/bin/blue-tape.js -- 'dist/**/*.spec.js' | tap-spec","test":"npm run build && npm run lint && npm run test-cov","prepublish":"typings install && npm run build"},"repository":{"type":"git","url":"git://github.com/blakeembrey/throwback.git"},"keywords":["middleware","async","compose","promise","ware","layer"],"author":{"name":"Blake Embrey","email":"hello@blakeembrey.com","url":"http://blakeembrey.me"},"license":"MIT","bugs":{"url":"https://github.com/blakeembrey/throwback/issues"},"homepage":"https://github.com/blakeembrey/throwback","devDependencies":{"blue-tape":"^1.0.0","bluebird":"^3.3.5","chai":"^3.2.0","istanbul":"^0.4.4","tap-spec":"^4.1.1","tslint":"^4.3.1","tslint-config-standard":"^2.0.0","typescript":"^2.0.3","typings":"^2.1.0"},"gitHead":"ae1db957b722c2234b062fcd452ccfe411d4df45","_id":"throwback@2.0.0","_shasum":"3a8669f4778ba4972ad88ca144a49f43c441b125","_from":".","_npmVersion":"3.10.10","_nodeVersion":"7.3.0","_npmUser":{"name":"blakeembrey","email":"hello@blakeembrey.com"},"dist":{"shasum":"3a8669f4778ba4972ad88ca144a49f43c441b125","tarball":"http://registry-npm.ywwl.com/throwback/download/throwback-2.0.0.tgz","integrity":"sha512-b1Bynhwhk9IgN+n/Vs7/7CuXBH+6NbOD+481hhgNMN4Vyg7A3PVb3HAd/yI9LfN8yrJGoi4FbyoWXrQoRB8E7w==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCXU7snuk0NYtOzais6fnvrVvYlKCMDJoJjmqRSu/HgZAIgVqo/KsqFl9ViqE3Ixi3HgAkV1UM8OCdBqrkjIiQ087g="}],"size":5237,"noattachment":false,"key":"/throwback/-/throwback-2.0.0.tgz"},"maintainers":[{"name":"blakeembrey","email":"hello@blakeembrey.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/throwback-2.0.0.tgz_1484764113270_0.2886425368487835"},"directories":{},"readme":"# Throwback\n\n[![NPM version](https://img.shields.io/npm/v/throwback.svg?style=flat)](https://npmjs.org/package/throwback)\n[![NPM downloads](https://img.shields.io/npm/dm/throwback.svg?style=flat)](https://npmjs.org/package/throwback)\n[![Build status](https://img.shields.io/travis/serviejs/throwback.svg?style=flat)](https://travis-ci.org/serviejs/throwback)\n[![Test coverage](https://img.shields.io/coveralls/serviejs/throwback.svg?style=flat)](https://coveralls.io/r/serviejs/throwback?branch=master)\n\n> Simple asynchronous middleware pattern.\n\n## Installation\n\n```\nnpm install throwback --save\n```\n\n## Usage\n\nCompose asynchronous (promise-returning) functions.\n\n```js\nconst { compose } = require(\"throwback\");\n\nconst fn = compose([\n  async function(ctx, next) {\n    console.log(1);\n\n    try {\n      await next();\n    } catch (err) {\n      console.log(\"throwback\", err);\n    }\n\n    console.log(4);\n  },\n  async function(ctx, next) {\n    console.log(2);\n\n    return next();\n  }\n]);\n\n// Callback runs at the end of the stack, before\n// the middleware bubbles back to the beginning.\nfn({}, function(ctx) {\n  console.log(3);\n\n  ctx.status = 404;\n});\n```\n\n**Tip:** In development (`NODE_ENV !== \"production\"`), `compose` will throw errors when you do something unexpected. In production, the faster non-error code paths are used.\n\n### Example\n\nBuild a micro HTTP server!\n\n```js\nconst { createServer } = require(\"http\");\nconst finalhandler = require(\"finalhandler\"); // Example only, not compatible with single `ctx` arg.\nconst { compose } = require(\"throwback\");\n\nconst app = compose([\n  function({ req, res }, next) {\n    res.end(\"Hello world!\");\n  }\n]);\n\ncreateServer(function(req, res) {\n  return app({ req, res }, finalhandler());\n}).listen(3000);\n```\n\n## Use Cases\n\n- HTTP requests (e.g. [`popsicle`](https://github.com/serviejs/popsicle))\n- HTTP servers (e.g. [`servie`](https://github.com/serviejs/servie))\n- Processing pipelines (e.g. [`scrappy`](https://github.com/blakeembrey/node-scrappy))\n\n## Inspiration\n\nBuilt for [`servie`](https://github.com/serviejs) and inspired by [`koa-compose`](https://github.com/koajs/compose).\n\n## License\n\nMIT\n","publish_time":1484764115179,"_cnpm_publish_time":1484764115179,"dist-tags":{"latest":"4.1.0"}}