{"name":"throwback","version":"2.0.1","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/serviejs/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/serviejs/throwback/issues"},"homepage":"https://github.com/serviejs/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":"8a718c06a3fbbfbe1297159b6ec723e277beaa92","_id":"throwback@2.0.1","_shasum":"12db580310ef2030e39903513ea3c55273b5e183","_from":".","_npmVersion":"3.10.10","_nodeVersion":"7.3.0","_npmUser":{"name":"blakeembrey","email":"hello@blakeembrey.com"},"dist":{"shasum":"12db580310ef2030e39903513ea3c55273b5e183","tarball":"http://registry-npm.ywwl.com/throwback/download/throwback-2.0.1.tgz","integrity":"sha512-LPAeh7kzHkAPeEudDYCHM3W7MbVu0luQzF7u7yD2jRPjuLp7XY6mbBiuQWKri1aX4V1GdCIgWP3yTQgjPAm3Dw==","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIQCHr/FOys//VvvKvXrEyPivN4VJyHrZw56okmSTHHopuQIgIsPsFlX72id+wwaiFpxVU8IsQNMCcXY1bfJT/60LEuM="}],"size":5211,"noattachment":false,"key":"/throwback/-/throwback-2.0.1.tgz"},"maintainers":[{"name":"blakeembrey","email":"hello@blakeembrey.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/throwback-2.0.1.tgz_1494278781451_0.3121768571436405"},"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":1494278783480,"_cnpm_publish_time":1494278783480,"dist-tags":{"latest":"4.1.0"}}