{"_id":"execify","_rev":"72007","name":"execify","description":"A module for shimmimg between execution modes: streams, promises, and callbacks","dist-tags":{"latest":"0.0.3"},"maintainers":[{"name":"robrich","email":"robrich@robrich.org"}],"time":{"modified":"2021-06-03T10:23:39.000Z","created":"2013-12-06T22:40:56.321Z","0.0.3":"2014-01-03T20:04:35.970Z","0.0.2":"2013-12-15T06:38:28.482Z","0.0.1":"2013-12-06T22:40:56.321Z"},"users":{},"author":{"name":"Rob Richardson","url":"http://robrich.org/"},"repository":{"type":"git","url":"git://github.com/robrich/execify.git"},"versions":{"0.0.3":{"name":"execify","description":"A module for shimmimg between execution modes: streams, promises, and callbacks","version":"0.0.3","homepage":"https://github.com/robrich/execify","repository":{"type":"git","url":"git://github.com/robrich/execify.git"},"author":{"name":"Rob Richardson","url":"http://robrich.org/"},"main":"./index.js","keywords":["task","exec","stream","promise"],"dependencies":{"q":"~0.9.7","map-stream":"~0.0.4"},"devDependencies":{"mocha":"~1.16.2","should":"~2.1.1","event-stream":"~3.0.20"},"scripts":{"test":"mocha"},"engines":{"node":">= 0.8"},"licenses":[{"type":"MIT","url":"http://github.com/robrich/execify/raw/master/LICENSE"}],"readmeFilename":"README.md","bugs":{"url":"https://github.com/robrich/execify/issues"},"_id":"execify@0.0.3","dist":{"shasum":"f163d4accf381180f1873d5a1d0aafc3506c4569","size":3465,"noattachment":false,"key":"/execify/-/execify-0.0.3.tgz","tarball":"http://registry.cnpm.dingdandao.com/execify/download/execify-0.0.3.tgz"},"_from":".","_npmVersion":"1.3.15","_npmUser":{"name":"robrich","email":"robrich@robrich.org"},"maintainers":[{"name":"robrich","email":"robrich@robrich.org"}],"directories":{},"publish_time":1388779475970,"_cnpm_publish_time":1388779475970,"_hasShrinkwrap":false},"0.0.2":{"name":"execify","description":"A module for shimmimg between execution modes: streams, promises, and callbacks","version":"0.0.2","homepage":"https://github.com/robrich/execify","repository":{"type":"git","url":"git://github.com/robrich/execify.git"},"author":{"name":"Rob Richardson","url":"http://robrich.org/"},"main":"./index.js","keywords":["task","exec","stream","promise"],"dependencies":{"q":"~0.9.7","event-stream":"~3.0.18"},"devDependencies":{"mocha":"~1.15.1","should":"~2.1.1"},"scripts":{"test":"mocha"},"engines":{"node":">= 0.8"},"licenses":[{"type":"MIT","url":"http://github.com/robrich/execify/raw/master/LICENSE"}],"readmeFilename":"README.md","bugs":{"url":"https://github.com/robrich/execify/issues"},"_id":"execify@0.0.2","dist":{"shasum":"3054aae129f79557ddd870d74bfef9feaf5bc314","size":3457,"noattachment":false,"key":"/execify/-/execify-0.0.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/execify/download/execify-0.0.2.tgz"},"_from":".","_npmVersion":"1.3.15","_npmUser":{"name":"robrich","email":"robrich@robrich.org"},"maintainers":[{"name":"robrich","email":"robrich@robrich.org"}],"directories":{},"publish_time":1387089508482,"_cnpm_publish_time":1387089508482,"_hasShrinkwrap":false},"0.0.1":{"name":"execify","description":"A module for shimmimg between execution modes: streams, promises, and callbacks","version":"0.0.1","homepage":"https://github.com/robrich/execify","repository":{"type":"git","url":"git://github.com/robrich/execify.git"},"author":{"name":"Rob Richardson","url":"http://robrich.org/"},"main":"./index.js","keywords":["task","exec","stream","promise"],"dependencies":{"q":"0.9.7","event-stream":"3.0.18"},"devDependencies":{"mocha":"~1.15.1","should":"~2.1.1"},"scripts":{"test":"mocha"},"engines":{"node":">= 0.8"},"licenses":[{"type":"MIT","url":"http://github.com/robrich/execify/raw/master/LICENSE"}],"readmeFilename":"README.md","bugs":{"url":"https://github.com/robrich/execify/issues"},"_id":"execify@0.0.1","dist":{"shasum":"cfd5732730001e74db278c9fdd61aa57028106da","size":3444,"noattachment":false,"key":"/execify/-/execify-0.0.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/execify/download/execify-0.0.1.tgz"},"_from":".","_npmVersion":"1.3.15","_npmUser":{"name":"robrich","email":"robrich@robrich.org"},"maintainers":[{"name":"robrich","email":"robrich@robrich.org"}],"directories":{},"publish_time":1386369656321,"_cnpm_publish_time":1386369656321,"_hasShrinkwrap":false}},"readme":"[![Build Status](https://secure.travis-ci.org/robrich/execify.png?branch=master)](https://travis-ci.org/robrich/execify)\r\n[![Dependency Status](https://david-dm.org/robrich/execify.png)](https://david-dm.org/robrich/execify)\r\n\r\nExec-ify\r\n========\r\n\r\nA module for shimmimg between execution modes: streams, promises, and callbacks\r\n\r\nAbout\r\n-----\r\n\r\nHave you ever used a library that worked in callbacks when you wanted to work in promises?  Or did it want promises\r\nand you just wanted a simple callback?  This library shims between callbacks, promises, and event streams.\r\nPass it a function that does any of the 3, and it'll return the results the way you wanted.\r\n\r\nUsage\r\n-----\r\n\r\n```javascript\r\nvar execify = require('execify');\r\n\r\nvar functionToRun = function () {\r\n  // this function could do anything:\r\n  // - take a callback\r\n  // - return a promise\r\n  // - return a stream\r\n  // - execute synchronously\r\n};\r\n\r\n// Return the results as a callback\r\nexecify.asCallback(functionToRun, ['optional','array','of','args'], function (err, results) {\r\n  //...\r\n});\r\n\r\n// Return the results as a promise\r\nvar p = execify.asPromise(functionToRun, ['optional','array','of','args']);\r\np.then(function (results) {\r\n  // success\r\n}, function (err) {\r\n  // fail\r\n});\r\n\r\n// Return the results as an event stream\r\nvar s = execify.asStream(functionToRun);\r\ns.on('error', function (err) {\r\n  // fail\r\n});\r\ns.on('end', function () {\r\n  // done: good or bad\r\n});\r\ns.write(['optional','array','of','args']);\r\ns.end();\r\n```\r\n\r\nTheory\r\n------\r\n\r\nHow does it know what the `functionToRun` will do?\r\n\r\n- It always appends a callback to the args you gave it\r\n- It examines the results returned from the function\r\n- Does the results have a `then` function? assume it's a promise, see [Promises/A+](http://promises-aplus.github.io/promises-spec/)\r\n- Does the results have a `pipe` function, an `on` function, a `once` function, and an `end` function? assume it's a stream\r\n- Does the function take in more parameters than you passed or was the callback called already? assume it's a callback\r\n- If all else fails, assume synchronous\r\n\r\nDoes it change `this`?  No.\r\n\r\nWhat if my `functionToRun` doesn't work this way? [let us know](https://github.com/robrich/execify/issues)\r\n\r\nFine print\r\n----------\r\n\r\nFRAGILE: Execify catches exceptions on sync runs to pass to your callback\r\nbut doesn't hook to process.uncaughtException so it can't pass those exceptions\r\nto your callback\r\n\r\nLICENSE\r\n-------\r\n\r\n(MIT License)\r\n\r\nCopyright (c) 2013 [Richardson & Sons, LLC](http://richardsonandsons.com/)\r\n\r\nPermission is hereby granted, free of charge, to any person obtaining\r\na copy of this software and associated documentation files (the\r\n\"Software\"), to deal in the Software without restriction, including\r\nwithout limitation the rights to use, copy, modify, merge, publish,\r\ndistribute, sublicense, and/or sell copies of the Software, and to\r\npermit persons to whom the Software is furnished to do so, subject to\r\nthe following conditions:\r\n\r\nThe above copyright notice and this permission notice shall be\r\nincluded in all copies or substantial portions of the Software.\r\n\r\nTHE SOFTWARE IS PROVIDED \"AS IS\", WITHOUT WARRANTY OF ANY KIND,\r\nEXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF\r\nMERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND\r\nNONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE\r\nLIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION\r\nOF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION\r\nWITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.\r\n","_attachments":{},"readmeFilename":"README.md","homepage":"https://github.com/robrich/execify","bugs":{"url":"https://github.com/robrich/execify/issues"}}