{"dist":{"shasum":"1a83a20fdc8a0d385959b48ea689b8985b5ffd63","tarball":"https://registry.npmjs.org/stak/-/stak-0.1.2.tgz","integrity":"sha512-w7JLiOhJXLlwWEAA8iOh03k1raW53FPwAJlIfNM0gvKlB9YIffuTTjYXlrKxENVk0UhEeJ+gn+JoCN8hkvXxeQ==","signatures":[{"sig":"MEQCIAJZFZN7ZGsGS1MIKm4YT2ckYC1tY4cptJW/l7KlVZO8AiBmj0NpdV2ZUUVQ0qWE7bTN17OHtVzqLaFQUSXlglA05Q==","keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA"}]},"main":"lib/stack","name":"stak","author":{"name":"Jake Verbaten","email":"raynos2@gmail.com"},"readme":"# Stak [![Build Status][1]][2]\r\n\r\nCreate re-usable stacks of code to run.\r\n\r\n## Status: beta\r\n\r\n## Example\r\n\r\n``` javascript\r\nvar stack = Stak.make(\r\n    function readSelf() {\r\n        fs.readFile(this.uri, this.next);\r\n    },\r\n    function capitalize(err, text) {\r\n        this.next(err, text.toUpperCase());\r\n    }\r\n);\r\n\r\nstack.handle({\r\n    uri: __filename,\r\n    floor: function showIt(err, newText) {\r\n        if (err) throw err;\r\n        console.log(newText);\r\n    }\r\n});\r\n```\r\n\r\n## Motivation\r\n\r\nSimilar to [Step][3] except you create a stack that can be re-used. This means you create the functions once and pass data in through the this context.\r\n\r\n## Documentation\r\n\r\n### Stak.make(...) <a name=\"make\" href=\"#make\"><small><sup>link</sup></small></a>\r\n\r\nShortcut for `Object.create(Stak).constructor(...)`\r\n\r\n``` javascript\r\nStak.make(function () {\r\n    this.next(true)\r\n}, function (value) {\r\n    assert(value === true);\r\n}).handle();\r\n```\r\n\r\n### Stak.use(...) <a name=\"use\" href=\"#use\"><small><sup>link</sup></small></a>\r\n\r\nAdd extra functions to the stack\r\n\r\n``` javascript\r\nvar s = Stak.make();\r\n\r\ns.use(function () {\r\n    console.log(\"it works\");\r\n});\r\n\r\ns.handle(); // it works\r\n```\r\n\r\n### Stak.handle(context) <a name=\"handle\" href=\"#handle\"><small><sup>link</sup></small></a>\r\n\r\nThis starts a stack. The first function in the stack will be called and the next function will be called once the first function calls this.next. The context object is passed in as `this`.\r\n\r\n``` javascript\r\nvar context = {};\r\nvar s = Stak.make(function () { assert(this === context); });\r\ns.handle(context);\r\n```\r\n\r\nThe context also has two special properties `floor` and `ceil` which form the floor and the ceiling of the stack of functions. This allows you to add a function before and after all the other functions\r\n\r\n``` javascript\r\nvar stack = Stak.make(function (data) {\r\n    this.next(data * this.multiplier);\r\n});\r\n\r\nstack.handle({\r\n    multiplier: 3,\r\n    ceil: function () {\r\n        this.next(42);\r\n    },\r\n    floor: function (data) {\r\n        assert(data === 42 * 3);\r\n    }\r\n});\r\n```\r\n\r\n### Stak.floor <a name=\"floor\" href=\"#floor\"><small><sup>link</sup></small></a>\r\n\r\nA default floor for this instance of the stack. If no floor is passed through handle then this floor will be used\r\n\r\n### Stak.ceil <a name=\"ceil\" href=\"#ceil\"><small><sup>link</sup></small></a>\r\n\r\nA default ceiling for this instance of the stack. If no ceil is passed through handle then this ceil will be used\r\n\r\n## Installation\r\n\r\n`npm install stak`\r\n\r\n## Tests\r\n\r\n`make test`\r\n\r\n## Contributors\r\n\r\n - Raynos\r\n\r\n## MIT Licenced\r\n\r\n  [1]: https://secure.travis-ci.org/Raynos/stak.png\r\n  [2]: http://travis-ci.org/Raynos/stak\r\n  [3]: https://github.com/creationix/step\r\n","engines":{"node":"0.6.x"},"scripts":{"test":"make test"},"_npmUser":{"name":"raynos","email":"raynos2@gmail.com"},"keywords":["stack","middleware","flowcontrol","flow","control","arch"],"repository":{"url":"git://github.com/Raynos/stak.git","type":"git"},"_npmVersion":"1.1.0-3","maintainers":[{"name":"raynos","email":"raynos2@gmail.com"}],"_nodeVersion":"v0.6.10","dependencies":{},"descriptions":"A flow control stack","_defaultsLoaded":true,"devDependencies":{"mocha":"0.10.2"},"_engineSupported":true,"optionalDependencies":{},"_id":"stak@0.1.2","version":"0.1.2"}