{"_id":"denodeify","_rev":"94339","name":"denodeify","description":"Tool to turn functions with Node-style callback APIs into functions that return Promises","dist-tags":{"latest":"1.2.1"},"maintainers":[{"name":"mattandrews","email":"matt@mattandre.ws"}],"time":{"modified":"2021-06-03T10:31:24.000Z","created":"2014-09-09T14:21:18.701Z","1.2.1":"2015-02-14T05:35:10.362Z","1.2.0":"2014-11-19T13:28:44.958Z","1.1.2":"2014-09-20T00:54:40.560Z","1.1.1":"2014-09-19T17:45:59.853Z","1.1.0":"2014-09-09T15:05:03.441Z","1.0.0":"2014-09-09T14:21:18.701Z"},"users":{"kornel":true,"moimikey":true,"lshearer":true,"codechaotic":true,"antixrist":true,"grabantot":true,"tomi77":true},"author":{"name":"Matt Andrews"},"repository":{"type":"git","url":"https://github.com/matthew-andrews/denodeify.git"},"versions":{"1.2.1":{"name":"denodeify","version":"1.2.1","description":"Tool to turn functions with Node-style callback APIs into functions that return Promises","main":"index.js","directories":{"test":"test"},"scripts":{"files":"find . -name '*.js' ! -path './node_modules/*'","jshint":"jshint `npm run -s files`","lintspaces":"lintspaces -i js-comments -e .editorconfig `npm run -s files`","test":"mocha test/*test.js && npm run jshint && npm run lintspaces"},"repository":{"type":"git","url":"https://github.com/matthew-andrews/denodeify.git"},"author":{"name":"Matt Andrews"},"license":"MIT","bugs":{"url":"https://github.com/matthew-andrews/denodeify/issues"},"homepage":"https://github.com/matthew-andrews/denodeify","devDependencies":{"es6-promise":"^1.0.0","es6-shim":"^0.18.0","jshint":"^2.5.5","lie":"^2.7.7","lintspaces-cli":"0.0.4","mocha":"^1.21.4","native-promise-only":"^0.7.6-a"},"gitHead":"e500054eb336c748264507e9553af949981ee2c3","_id":"denodeify@1.2.1","_shasum":"3a36287f5034e699e7577901052c2e6c94251631","_from":".","_npmVersion":"2.1.14","_nodeVersion":"0.10.33","_npmUser":{"name":"mattandrews","email":"matt@mattandre.ws"},"maintainers":[{"name":"mattandrews","email":"matt@mattandre.ws"}],"dist":{"shasum":"3a36287f5034e699e7577901052c2e6c94251631","size":3881,"noattachment":false,"key":"/denodeify/-/denodeify-1.2.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/denodeify/download/denodeify-1.2.1.tgz"},"publish_time":1423892110362,"_cnpm_publish_time":1423892110362,"_hasShrinkwrap":false},"1.2.0":{"name":"denodeify","version":"1.2.0","description":"Tool to turn functions with Node-style callback APIs into functions that return Promises","main":"index.js","directories":{"test":"test"},"scripts":{"files":"find . -name '*.js' ! -path './node_modules/*'","jshint":"jshint `npm run -s files`","lintspaces":"lintspaces -i js-comments -e .editorconfig `npm run -s files`","test":"mocha test/*test.js && npm run jshint && npm run lintspaces"},"repository":{"type":"git","url":"https://github.com/matthew-andrews/denodeify.git"},"author":{"name":"Matt Andrews"},"license":"MIT","bugs":{"url":"https://github.com/matthew-andrews/denodeify/issues"},"homepage":"https://github.com/matthew-andrews/denodeify","devDependencies":{"es6-promise":"^1.0.0","es6-shim":"^0.18.0","jshint":"^2.5.5","lie":"^2.7.7","lintspaces-cli":"0.0.4","mocha":"^1.21.4","native-promise-only":"^0.7.6-a"},"_id":"denodeify@1.2.0","_shasum":"c90add34824844e4cd65937b6c8824aa1af66856","_from":".","_npmVersion":"1.4.10","_npmUser":{"name":"mattandrews","email":"matt@mattandre.ws"},"maintainers":[{"name":"mattandrews","email":"matt@mattandre.ws"}],"dist":{"shasum":"c90add34824844e4cd65937b6c8824aa1af66856","size":3782,"noattachment":false,"key":"/denodeify/-/denodeify-1.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/denodeify/download/denodeify-1.2.0.tgz"},"publish_time":1416403724958,"_cnpm_publish_time":1416403724958,"_hasShrinkwrap":false},"1.1.2":{"name":"denodeify","version":"1.1.2","description":"Tool to turn functions with Node-style callback APIs into functions that return Promises","main":"index.js","directories":{"test":"test"},"scripts":{"test":"mocha test/*test.js && ./node_modules/.bin/jshint `find . -name '*.js' ! -path './node_modules/*'`"},"repository":{"type":"git","url":"https://github.com/matthew-andrews/denodeify.git"},"author":{"name":"Matt Andrews"},"license":"MIT","bugs":{"url":"https://github.com/matthew-andrews/denodeify/issues"},"homepage":"https://github.com/matthew-andrews/denodeify","devDependencies":{"es6-promise":"^1.0.0","es6-shim":"^0.18.0","jshint":"^2.5.5","lie":"^2.7.7","mocha":"^1.21.4","native-promise-only":"^0.7.6-a"},"_id":"denodeify@1.1.2","_shasum":"e3ee239ca5a4ac74f8584b9ad82d19cf30bd1f9c","_from":".","_npmVersion":"1.4.10","_npmUser":{"name":"mattandrews","email":"matt@mattandre.ws"},"maintainers":[{"name":"mattandrews","email":"matt@mattandre.ws"}],"dist":{"shasum":"e3ee239ca5a4ac74f8584b9ad82d19cf30bd1f9c","size":3268,"noattachment":false,"key":"/denodeify/-/denodeify-1.1.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/denodeify/download/denodeify-1.1.2.tgz"},"publish_time":1411174480560,"_cnpm_publish_time":1411174480560,"_hasShrinkwrap":false},"1.1.1":{"name":"denodeify","version":"1.1.1","description":"Tool to turn functions with Node-style callback APIs into functions that return Promises","main":"index.js","directories":{"test":"test"},"scripts":{"test":"mocha test/*test.js && ./node_modules/.bin/jshint `find . -name '*.js' ! -path './node_modules/*'`"},"repository":{"type":"git","url":"https://github.com/matthew-andrews/denodeify.git"},"author":{"name":"Matt Andrews"},"license":"MIT","bugs":{"url":"https://github.com/matthew-andrews/denodeify/issues"},"homepage":"https://github.com/matthew-andrews/denodeify","devDependencies":{"es6-promise":"^1.0.0","es6-shim":"^0.18.0","jshint":"^2.5.5","lie":"^2.7.7","mocha":"^1.21.4","native-promise-only":"^0.7.6-a"},"_id":"denodeify@1.1.1","_shasum":"938110fdbc158250c0ef7bec7252717701a4182d","_from":".","_npmVersion":"1.4.10","_npmUser":{"name":"mattandrews","email":"matt@mattandre.ws"},"maintainers":[{"name":"mattandrews","email":"matt@mattandre.ws"}],"dist":{"shasum":"938110fdbc158250c0ef7bec7252717701a4182d","size":3142,"noattachment":false,"key":"/denodeify/-/denodeify-1.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/denodeify/download/denodeify-1.1.1.tgz"},"publish_time":1411148759853,"_cnpm_publish_time":1411148759853,"_hasShrinkwrap":false},"1.1.0":{"name":"denodeify","version":"1.1.0","description":"Tool to wrap functions with Node style APIs","main":"index.js","directories":{"test":"test"},"scripts":{"test":"mocha && ./node_modules/.bin/jshint"},"repository":{"type":"git","url":"https://github.com/matthew-andrews/denodeify.git"},"author":{"name":"Matt Andrews"},"license":"MIT","bugs":{"url":"https://github.com/matthew-andrews/denodeify/issues"},"homepage":"https://github.com/matthew-andrews/denodeify","devDependencies":{"es6-promise":"^1.0.0","jshint":"^2.5.5","mocha":"^1.21.4"},"gitHead":"31be71ac9e6144ed176ba106c85f60d278b4ceef","_id":"denodeify@1.1.0","_shasum":"7f08d342a5de8cc77c4596d367fd21b3bb2547c0","_from":".","_npmVersion":"1.4.20","_npmUser":{"name":"mattandrews","email":"matt@mattandre.ws"},"maintainers":[{"name":"mattandrews","email":"matt@mattandre.ws"}],"dist":{"shasum":"7f08d342a5de8cc77c4596d367fd21b3bb2547c0","size":1430,"noattachment":false,"key":"/denodeify/-/denodeify-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/denodeify/download/denodeify-1.1.0.tgz"},"publish_time":1410275103441,"_cnpm_publish_time":1410275103441,"_hasShrinkwrap":false},"1.0.0":{"name":"denodeify","version":"1.0.0","description":"denodeify [ ![Codeship Status for matthew-andrews/denodeify](https://codeship.io/projects/02ac77d0-1a58-0132-bf86-4a07366ee29d/status)](https://codeship.io/projects/34622) =========","main":"index.js","directories":{"test":"test"},"scripts":{"test":"mocha && ./node_modules/.bin/jshint"},"repository":{"type":"git","url":"https://github.com/matthew-andrews/denodeify.git"},"author":{"name":"Matt Andrews"},"license":"MIT","bugs":{"url":"https://github.com/matthew-andrews/denodeify/issues"},"homepage":"https://github.com/matthew-andrews/denodeify","devDependencies":{"es6-promise":"^1.0.0","jshint":"^2.5.5","mocha":"^1.21.4"},"gitHead":"cae0774899ac4279acb48015d8f1eb825220a32c","_id":"denodeify@1.0.0","_shasum":"9459b981061cb789a98b5699b05948ec064cdd6e","_from":".","_npmVersion":"1.4.20","_npmUser":{"name":"mattandrews","email":"matt@mattandre.ws"},"maintainers":[{"name":"mattandrews","email":"matt@mattandre.ws"}],"dist":{"shasum":"9459b981061cb789a98b5699b05948ec064cdd6e","size":1255,"noattachment":false,"key":"/denodeify/-/denodeify-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/denodeify/download/denodeify-1.0.0.tgz"},"publish_time":1410272478701,"_cnpm_publish_time":1410272478701,"_hasShrinkwrap":false}},"readme":"denodeify [ ![Codeship Status for matthew-andrews/denodeify](https://codeship.io/projects/02ac77d0-1a58-0132-bf86-4a07366ee29d/status)](https://codeship.io/projects/34622)\n=========\n\nTool to turn functions with Node-style callback APIs into functions that return [Promises](https://github.com/jakearchibald/es6-promise).\n\nInspired by and adapted from Q's [`Q.denodeify`/`Q.nfcall` function](https://github.com/kriskowal/q/wiki/API-Reference#qnfbindnodefunc-args).\n\nWarning: This micro-library doesn't force you to use any particular Promise implementation by using whatever `Promise` has been defined as globally.  This is so that you may use any ES6 standard Promise compliant library - or, of course, native ES6 Promises.\n\nIf you're running the code on a browser or node version that doesn't include native promises you will need to include a polyfill.  The following polyfills are tested as part of this module's test suite:-\n- [Jake Archibald](https://twitter.com/jaffathecake)'s [ES6 Promise library](https://github.com/jakearchibald/es6-promise) (which is actually adapted from [Stefan Penner](https://twitter.com/stefanpenner)'s [RSVP.js](https://github.com/tildeio/rsvp.js)). -  `require('es6-promise').polyfill();`\n- [Getify](https://twitter.com/getify)'s [Native Promise Only library](https://github.com/getify/native-promise-only) - `require('native-promise-only');`\n- [ES6 Shim](https://github.com/es-shims/es6-shim) - `require('es6-shim');`\n- [Calvin Metcalf](https://twitter.com/CWMma)'s [Lie](https://github.com/calvinmetcalf/lie) - `global.Promise = global.Promise || require('lie');`\n\nNote: as of v1.2.0 you can use **denodeify** in the front end.  Pull it in via CommonJS, AMD or simply add to your webpage and it'll be available on `window.denodeify`. \n\n## Installation\n\n```\nnpm install denodeify --save\n```\n\nOr:-\n\n```\nbower install denodeify --save\n```\n\n## Examples\n\nSimple example with [`readFile`](https://www.npmjs.org/package/read-file):-\n\n```js\nrequire('es6-promise').polyfill();\n\nvar denodeify = require('denodeify');\nvar readFile = denodeify(require('fs').readFile);\n\nreadFile('my-file.txt', { encoding: 'UTF-8' })\n  .then(function(text) {\n    console.log(\"My file's contents is: \" + text);\n  });\n```\n\n(Note: you will need to also install [es6-promise](https://github.com/jakearchibald/es6-promise) with `npm install es6-promise` for this code sample to work within node versions that don't have `Promise` natively available)\n\nMore complex example with `exec`:-\n\n## Advanced usage\n\nYou can also pass in a function as a second argument of `denodeify` that allows you to manipulate the data returned by the wrapped function before it gets passed to the Promise's `reject` or `resolve` functions, for example:-\n\n```js\nrequire('es6-promise').polyfill();\n\nvar denodeify = require('denodeify');\nvar exec = denodeify(require('child_process').exec, function(err, stdout, stderr) {\n\n  // Throw away stderr data\n  return [err, stdout];\n});\n\nexec('hostname')\n  .then(function(host) {\n    console.log(\"My hostname is: \" + host.replace('\\n', ''));\n  });\n```\n\nOr,\n\n```js\nrequire('es6-promise').polyfill();\n\nvar denodeify = require('denodeify');\nvar exec = denodeify(require('child_process').exec, function(err, stdout, stderr) {\n  return [err, [stdout, stderr]];\n});\n\nexec('my-command')\n  .then(function(results) {\n    console.log(\"stdout is: \" + results[0]);\n    console.log(\"stderr is: \" + results[1]);\n  });\n```\n\nUseful for functions that return multiple arguments, for example [`child_process#exec`](http://nodejs.org/api/child_process.html#child_process_child_process_exec_command_options_callback).\n\n## Credits and collaboration ##\n\nThe lead developer of **denodeify** is [Matt Andrews](http://twitter.com/andrewsmatt) at FT Labs with much help and support from [Kornel Lesiński](https://twitter.com/pornelski). All open source code released by FT Labs is licenced under the MIT licence. We welcome comments, feedback and suggestions.  Please feel free to raise an issue or pull request.\n","_attachments":{},"homepage":"https://github.com/matthew-andrews/denodeify","bugs":{"url":"https://github.com/matthew-andrews/denodeify/issues"},"license":"MIT"}