{"name":"throwback","version":"4.0.0","description":"Simple asynchronous middleware pattern","main":"dist/index.js","typings":"dist/index.d.ts","scripts":{"lint":"tslint \"src/**/*.ts\" --project tsconfig.json","build":"rimraf dist && tsc","specs":"jest --coverage","test":"npm run build && npm run lint && npm run specs","prepublish":"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","jest":{"roots":["<rootDir>/src/"],"transform":{"\\.tsx?$":"ts-jest"},"testRegex":"(/__tests__/.*|\\.(test|spec))\\.(tsx?|jsx?)$","moduleFileExtensions":["ts","tsx","js","jsx","json","node"]},"devDependencies":{"@types/jest":"^23.3.2","@types/node":"^10.1.2","jest":"^23.6.0","rimraf":"^2.6.2","ts-jest":"^23.10.0","tslint":"^5.10.0","tslint-config-standard":"^8.0.1","typescript":"^3.0.3"},"gitHead":"060dd41350f2516549c8ee1fa41e75cd585e65db","_id":"throwback@4.0.0","_npmVersion":"6.4.1","_nodeVersion":"10.10.0","_npmUser":{"name":"blakeembrey","email":"hello@blakeembrey.com"},"dist":{"integrity":"sha512-4XQH6+K3XmJSQ805KyoE2OwLEWsIHMAa0ysLDoOqRvSguGlHoM6wDuUi/qvwogj5eGtZfrqGwNJNCXZV9esqkQ==","shasum":"128f96dcea5308df01fe7c99d50e33f77a7a2230","tarball":"http://registry-npm.ywwl.com/throwback/download/throwback-4.0.0.tgz","fileCount":9,"unpackedSize":25762,"npm-signature":"-----BEGIN PGP SIGNATURE-----\r\nVersion: OpenPGP.js v3.0.4\r\nComment: https://openpgpjs.org\r\n\r\nwsFcBAEBCAAQBQJbzOO1CRA9TVsSAnZWagAAmwgQAJ66iFW1YRLFkrtiUj1P\nAgnNk4JNexKijmCKn4ZkCBKdDLeU3WMR7shI9K1ODoyi6xnvH+FhGFgV00wy\n9BpNLbdxUmyCB5Qzgj6ljcZ1y/3yzosMYhIbq8cuuD/6Qh6ltgkpB923sw7g\nT/rEcNb80HfpgqVjtJa1sdRt0i5vXerVQYRbX4oDvI53LV0xbQMsewQ0O4cv\nwWEoUTyiSGj/gpa8eQtoebNBkhNlctPIX80alLPH1h01XqaCvO51dsq3vJ5k\nw3hIMotrXLEmyTNb/X/8lUhM5v1zISqnYhw/6bYJ7LFXYfR6CXjSJ1x0rnZd\n+TBKxPRFldhM6VN06/DsGLZtiS0zrpP1lDKO93W1QBO7RRtUA7yjQ9v5QT8e\nqMfWQXu12xxwfDMqNg6dUutB94RZ1bAtRbwbValKsnAJOuPuxTT7/fMXUAcj\nK3Sd3l7DHXRXWgAbPd+5uIZE0IRW51ChwIAeoPLOOlEs175grbaMxOVoRGcF\n88lBLCoD+6h6/TnSeKPpnAcBwrPrGxSiKESWg6U3suX2MCWAvlfgOoIRUmeW\n6cjv5/79frO3ClRhSLhd97//CDH06KdC0e3Be+kA56TpiHUaJSbzYmUpSzsB\n+BkLt21c1k3J4vBJf4LUrzRBWw/rOn/lWPZV8Fj0mJqFpEkDPUVViYjABaxh\nR0kK\r\n=2hPu\r\n-----END PGP SIGNATURE-----\r\n","signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIFpvmx9yRMhqZSwu9OKgwh8u/W8EAjao9rK0NMLHDz+WAiEAxGvFg/KQF78fzXewkvj29e9KPCcBCEgSEZN2k7nP+Dw="}],"size":6567,"noattachment":false,"key":"/throwback/-/throwback-4.0.0.tgz"},"maintainers":[{"name":"blakeembrey","email":"hello@blakeembrey.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/throwback_4.0.0_1540154292261_0.07861322086289602"},"_hasShrinkwrap":false,"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":1540154292354,"_cnpm_publish_time":1540154292354,"dist-tags":{"latest":"4.1.0"}}