{"_id":"thenify","_rev":"1789","name":"thenify","description":"Promisify a callback-based function","dist-tags":{"latest":"3.3.1"},"maintainers":[{"name":"dead-horse","email":""},{"name":"dead_horse","email":"dead_horse@qq.com"},{"name":"jongleberry","email":"jonathanrichardong@gmail.com"}],"time":{"modified":"2021-06-03T09:56:02.000Z","created":"2014-08-09T23:34:21.073Z","3.3.1":"2020-06-17T17:30:57.152Z","3.3.0":"2017-05-19T09:58:32.296Z","3.2.1":"2016-10-10T10:48:16.435Z","3.2.0":"2016-02-01T20:29:26.986Z","3.1.1":"2015-10-20T18:22:01.954Z","3.1.0":"2015-01-06T03:32:20.600Z","3.0.0":"2014-12-25T08:18:14.350Z","2.0.0":"2014-12-17T06:23:24.197Z","1.0.0":"2014-08-09T23:34:21.073Z"},"users":{"shumkov":true,"icflorescu":true,"brooksn":true,"moimikey":true,"sylchamber":true,"9joneg":true,"tobiasnickel":true,"nickeltobias":true,"david-ruzicka":true,"stevenvachon":true,"cljames":true,"jochemstoel":true,"zhangaz1":true},"author":{"name":"Jonathan Ong","email":"me@jongleberry.com","url":"http://jongleberry.com"},"repository":{"type":"git","url":"git+https://github.com/thenables/thenify.git"},"versions":{"3.3.1":{"name":"thenify","description":"Promisify a callback-based function","version":"3.3.1","author":{"name":"Jonathan Ong","email":"me@jongleberry.com","url":"http://jongleberry.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/thenables/thenify.git"},"dependencies":{"any-promise":"^1.0.0"},"devDependencies":{"bluebird":"^3.1.1","istanbul":"^0.4.0","mocha":"^3.0.2"},"scripts":{"test":"mocha --reporter spec","test-cov":"istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot","test-travis":"istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot"},"keywords":["promisify","promise","thenify","then","es6"],"gitHead":"1d054b4d60e72087f4e804565e540258ecee7f0b","bugs":{"url":"https://github.com/thenables/thenify/issues"},"homepage":"https://github.com/thenables/thenify#readme","_id":"thenify@3.3.1","_nodeVersion":"10.16.0","_npmVersion":"6.12.0","dist":{"shasum":"8932e686a4066038a016dd9e2ca46add9838a95f","size":3072,"noattachment":false,"key":"/thenify/-/thenify-3.3.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/thenify/download/thenify-3.3.1.tgz"},"maintainers":[{"name":"dead-horse","email":""},{"name":"dead_horse","email":"dead_horse@qq.com"},{"name":"jongleberry","email":"jonathanrichardong@gmail.com"}],"_npmUser":{"name":"dead_horse","email":"dead_horse@qq.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/thenify_3.3.1_1592415057057_0.23597744543410548"},"_hasShrinkwrap":false,"publish_time":1592415057152,"_cnpm_publish_time":1592415057152},"3.3.0":{"name":"thenify","description":"Promisify a callback-based function","version":"3.3.0","author":{"name":"Jonathan Ong","email":"me@jongleberry.com","url":"http://jongleberry.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/thenables/thenify.git"},"dependencies":{"any-promise":"^1.0.0"},"devDependencies":{"bluebird":"^3.1.1","istanbul":"^0.4.0","mocha":"^3.0.2"},"scripts":{"test":"mocha --reporter spec","test-cov":"istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot","test-travis":"istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot"},"keywords":["promisify","promise","thenify","then","es6"],"files":["index.js"],"gitHead":"aa21cfb64f47238c764d258d0faf7366a8487e36","bugs":{"url":"https://github.com/thenables/thenify/issues"},"homepage":"https://github.com/thenables/thenify#readme","_id":"thenify@3.3.0","_shasum":"e69e38a1babe969b0108207978b9f62b88604839","_from":".","_npmVersion":"3.10.3","_nodeVersion":"6.10.2","_npmUser":{"name":"dead_horse","email":"dead_horse@qq.com"},"dist":{"shasum":"e69e38a1babe969b0108207978b9f62b88604839","size":3061,"noattachment":false,"key":"/thenify/-/thenify-3.3.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/thenify/download/thenify-3.3.0.tgz"},"maintainers":[{"name":"dead-horse","email":""},{"name":"dead_horse","email":"dead_horse@qq.com"},{"name":"jongleberry","email":"jonathanrichardong@gmail.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/thenify-3.3.0.tgz_1495187910351_0.656304276548326"},"directories":{},"publish_time":1495187912296,"_cnpm_publish_time":1495187912296,"_hasShrinkwrap":false},"3.2.1":{"name":"thenify","description":"Promisify a callback-based function","version":"3.2.1","author":{"name":"Jonathan Ong","email":"me@jongleberry.com","url":"http://jongleberry.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/thenables/thenify.git"},"dependencies":{"any-promise":"^1.0.0"},"devDependencies":{"bluebird":"^3.1.1","istanbul":"^0.4.0","mocha":"^3.0.2"},"scripts":{"test":"mocha --reporter spec","test-cov":"istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot","test-travis":"istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot"},"keywords":["promisify","promise","thenify","then","es6"],"files":["index.js"],"gitHead":"42e93a084347eed9ad34cd3f77728e7fe9b2c1c5","bugs":{"url":"https://github.com/thenables/thenify/issues"},"homepage":"https://github.com/thenables/thenify#readme","_id":"thenify@3.2.1","_shasum":"251fd1c80aff6e5cf57cb179ab1fcb724269bd11","_from":".","_npmVersion":"3.10.3","_nodeVersion":"4.4.7","_npmUser":{"name":"dead_horse","email":"dead_horse@qq.com"},"maintainers":[{"name":"dead-horse","email":""},{"name":"dead_horse","email":"dead_horse@qq.com"},{"name":"jongleberry","email":"jonathanrichardong@gmail.com"}],"dist":{"shasum":"251fd1c80aff6e5cf57cb179ab1fcb724269bd11","size":2499,"noattachment":false,"key":"/thenify/-/thenify-3.2.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/thenify/download/thenify-3.2.1.tgz"},"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/thenify-3.2.1.tgz_1476096494606_0.22121428861282766"},"directories":{},"publish_time":1476096496435,"_cnpm_publish_time":1476096496435,"_hasShrinkwrap":false},"3.2.0":{"name":"thenify","description":"Promisify a callback-based function","version":"3.2.0","author":{"name":"Jonathan Ong","email":"me@jongleberry.com","url":"http://jongleberry.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/thenables/thenify.git"},"dependencies":{"any-promise":"^1.0.0"},"devDependencies":{"bluebird":"^3.1.1","istanbul":"^0.4.0","mocha":"^2.0.0"},"scripts":{"test":"mocha --reporter spec","test-cov":"istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot","test-travis":"istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot"},"keywords":["promisify","promise","thenify","then","es6"],"files":["index.js"],"gitHead":"89bdcb82809dfa46a157b25c5d2bac36ed429b9b","bugs":{"url":"https://github.com/thenables/thenify/issues"},"homepage":"https://github.com/thenables/thenify#readme","_id":"thenify@3.2.0","_shasum":"40b902b1bc4416dc08d86f10ffff3586f0ec71b9","_from":".","_npmVersion":"3.3.12","_nodeVersion":"5.5.0","_npmUser":{"name":"jongleberry","email":"jonathanrichardong@gmail.com"},"dist":{"shasum":"40b902b1bc4416dc08d86f10ffff3586f0ec71b9","size":2495,"noattachment":false,"key":"/thenify/-/thenify-3.2.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/thenify/download/thenify-3.2.0.tgz"},"maintainers":[{"name":"dead-horse","email":""},{"name":"dead_horse","email":"dead_horse@qq.com"},{"name":"jongleberry","email":"jonathanrichardong@gmail.com"}],"_npmOperationalInternal":{"host":"packages-8-eu.internal.npmjs.com","tmp":"tmp/thenify-3.2.0.tgz_1454358563746_0.7461334459949285"},"directories":{},"publish_time":1454358566986,"_cnpm_publish_time":1454358566986,"_hasShrinkwrap":false},"3.1.1":{"name":"thenify","description":"Promisify a callback-based function","version":"3.1.1","author":{"name":"Jonathan Ong","email":"me@jongleberry.com","url":"http://jongleberry.com"},"license":"MIT","repository":{"type":"git","url":"git+https://github.com/thenables/thenify.git"},"dependencies":{"native-or-bluebird":"1"},"devDependencies":{"bluebird":"2","istanbul":"0","mocha":"2"},"scripts":{"test":"mocha --reporter spec","test-cov":"istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot","test-travis":"istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot"},"keywords":["promisify","promise","thenify","then","es6"],"files":["index.js"],"gitHead":"3c2af64fd708a33b969c05757bee8a12038eb211","bugs":{"url":"https://github.com/thenables/thenify/issues"},"homepage":"https://github.com/thenables/thenify#readme","_id":"thenify@3.1.1","_shasum":"f25114ce444dfa52fe5b39170baf5d3a05a63f06","_from":".","_npmVersion":"2.14.7","_nodeVersion":"4.2.1","_npmUser":{"name":"jongleberry","email":"jonathanrichardong@gmail.com"},"dist":{"shasum":"f25114ce444dfa52fe5b39170baf5d3a05a63f06","size":2428,"noattachment":false,"key":"/thenify/-/thenify-3.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/thenify/download/thenify-3.1.1.tgz"},"maintainers":[{"name":"dead-horse","email":""},{"name":"dead_horse","email":"dead_horse@qq.com"},{"name":"jongleberry","email":"jonathanrichardong@gmail.com"}],"directories":{},"publish_time":1445365321954,"_cnpm_publish_time":1445365321954,"_hasShrinkwrap":false},"3.1.0":{"name":"thenify","description":"Promisify a callback-based function","version":"3.1.0","author":{"name":"Jonathan Ong","email":"me@jongleberry.com","url":"http://jongleberry.com"},"license":"MIT","repository":{"type":"git","url":"https://github.com/thenables/thenify"},"dependencies":{"native-or-bluebird":"1"},"devDependencies":{"bluebird":"2","istanbul":"0","mocha":"2"},"scripts":{"test":"mocha --reporter spec","test-cov":"istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot","test-travis":"istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot"},"keywords":["promisify","promise","thenify","then","es6"],"files":["index.js"],"gitHead":"4c093c3583662f20f3342d59f73d61bb96f7d826","bugs":{"url":"https://github.com/thenables/thenify/issues"},"homepage":"https://github.com/thenables/thenify","_id":"thenify@3.1.0","_shasum":"c27cbbc62b7c287edf1a1a3d5cc8426d8aed49f0","_from":".","_npmVersion":"2.1.12","_nodeVersion":"0.11.14","_npmUser":{"name":"dead_horse","email":"dead_horse@qq.com"},"maintainers":[{"name":"dead-horse","email":""},{"name":"dead_horse","email":"dead_horse@qq.com"},{"name":"jongleberry","email":"jonathanrichardong@gmail.com"}],"dist":{"shasum":"c27cbbc62b7c287edf1a1a3d5cc8426d8aed49f0","size":2461,"noattachment":false,"key":"/thenify/-/thenify-3.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/thenify/download/thenify-3.1.0.tgz"},"directories":{},"publish_time":1420515140600,"_cnpm_publish_time":1420515140600,"_hasShrinkwrap":false},"3.0.0":{"name":"thenify","description":"Promisify a callback-based function","version":"3.0.0","author":{"name":"Jonathan Ong","email":"me@jongleberry.com","url":"http://jongleberry.com"},"license":"MIT","repository":{"type":"git","url":"https://github.com/thenables/thenify"},"dependencies":{"native-or-bluebird":"1"},"devDependencies":{"bluebird":"2","istanbul":"0","mocha":"2"},"scripts":{"test":"mocha --reporter spec","test-cov":"istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot","test-travis":"istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot"},"keywords":["promisify","promise","thenify","then","es6"],"files":["index.js"],"gitHead":"27fa50bad00b65a1e664ca085c65acd8c5988572","bugs":{"url":"https://github.com/thenables/thenify/issues"},"homepage":"https://github.com/thenables/thenify","_id":"thenify@3.0.0","_shasum":"7de788acfb33bcc0dae8280c98cda7e17e9cf9ee","_from":".","_npmVersion":"2.1.12","_nodeVersion":"0.11.14","_npmUser":{"name":"jongleberry","email":"jonathanrichardong@gmail.com"},"maintainers":[{"name":"dead-horse","email":""},{"name":"dead_horse","email":"dead_horse@qq.com"},{"name":"jongleberry","email":"jonathanrichardong@gmail.com"}],"dist":{"shasum":"7de788acfb33bcc0dae8280c98cda7e17e9cf9ee","size":2208,"noattachment":false,"key":"/thenify/-/thenify-3.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/thenify/download/thenify-3.0.0.tgz"},"directories":{},"publish_time":1419495494350,"_cnpm_publish_time":1419495494350,"_hasShrinkwrap":false},"2.0.0":{"name":"thenify","description":"Promisify a callback-based function","version":"2.0.0","author":{"name":"Jonathan Ong","email":"me@jongleberry.com","url":"http://jongleberry.com"},"license":"MIT","repository":{"type":"git","url":"https://github.com/thenables/thenify"},"dependencies":{"native-or-bluebird":"1"},"devDependencies":{"bluebird":"2","istanbul":"0","mocha":"2"},"scripts":{"test":"mocha --reporter spec","test-cov":"istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot","test-travis":"istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot"},"keywords":["promisify","promise","thenify","then","es6"],"files":["index.js"],"gitHead":"db03bb73f7b5e22bc6e1b268d89a50781f1bea0d","bugs":{"url":"https://github.com/thenables/thenify/issues"},"homepage":"https://github.com/thenables/thenify","_id":"thenify@2.0.0","_shasum":"a1c6a07b4274787c412289d4f8679b545205f186","_from":".","_npmVersion":"2.1.12","_nodeVersion":"0.11.14","_npmUser":{"name":"jongleberry","email":"jonathanrichardong@gmail.com"},"maintainers":[{"name":"dead-horse","email":""},{"name":"dead_horse","email":"dead_horse@qq.com"},{"name":"jongleberry","email":"jonathanrichardong@gmail.com"}],"dist":{"shasum":"a1c6a07b4274787c412289d4f8679b545205f186","size":2264,"noattachment":false,"key":"/thenify/-/thenify-2.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/thenify/download/thenify-2.0.0.tgz"},"directories":{},"publish_time":1418797404197,"_cnpm_publish_time":1418797404197,"_hasShrinkwrap":false},"1.0.0":{"name":"thenify","description":"Globally make everything a promise!","version":"1.0.0","author":{"name":"Jonathan Ong","email":"me@jongleberry.com","url":"http://jongleberry.com"},"license":"MIT","repository":{"type":"git","url":"https://github.com/thenables/thenify"},"dependencies":{},"devDependencies":{"mocha":"1","istanbul":"0"},"scripts":{"test":"mocha --reporter spec","test-cov":"istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot","test-travis":"istanbul cover node_modules/mocha/bin/_mocha --report lcovonly -- --reporter dot"},"keywords":["then","array","promise","promises","await"],"files":["index.js"],"gitHead":"5d5303a6c866da59693ab41996e7f4fff66e50d0","bugs":{"url":"https://github.com/thenables/thenify/issues"},"homepage":"https://github.com/thenables/thenify","_id":"thenify@1.0.0","_shasum":"bdd58503e7e2590f9c4cf237eec1d5cdcae050ed","_from":".","_npmVersion":"1.4.21","_npmUser":{"name":"jongleberry","email":"jonathanrichardong@gmail.com"},"maintainers":[{"name":"dead-horse","email":""},{"name":"dead_horse","email":"dead_horse@qq.com"},{"name":"jongleberry","email":"jonathanrichardong@gmail.com"}],"dist":{"shasum":"bdd58503e7e2590f9c4cf237eec1d5cdcae050ed","size":1683,"noattachment":false,"key":"/thenify/-/thenify-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/thenify/download/thenify-1.0.0.tgz"},"directories":{},"publish_time":1407627261073,"_cnpm_publish_time":1407627261073,"_hasShrinkwrap":false}},"readme":"\n# thenify\n\n[![NPM version][npm-image]][npm-url]\n[![Build status][travis-image]][travis-url]\n[![Test coverage][coveralls-image]][coveralls-url]\n[![Dependency Status][david-image]][david-url]\n[![License][license-image]][license-url]\n[![Downloads][downloads-image]][downloads-url]\n\nPromisify a callback-based function using [`any-promise`](https://github.com/kevinbeaty/any-promise).\n\n- Preserves function names\n- Uses a native promise implementation if available and tries to fall back to a promise implementation such as `bluebird`\n- Converts multiple arguments from the callback into an `Array`, also support change the behavior by `options.multiArgs`\n- Resulting function never deoptimizes\n- Supports both callback and promise style\n\nAn added benefit is that `throw`n errors in that async function will be caught by the promise!\n\n## API\n\n### fn = thenify(fn, options)\n\nPromisifies a function.\n\n### Options\n\n`options` are optional.\n\n- `options.withCallback` - support both callback and promise style, default to `false`.\n- `options.multiArgs` - change the behavior when callback have multiple arguments. default to `true`.\n  - `true` - converts multiple arguments to an array\n  - `false`- always use the first argument\n  - `Array` - converts multiple arguments to an object with keys provided in `options.multiArgs`\n\n- Turn async functions into promises\n\n```js\nvar thenify = require('thenify');\n\nvar somethingAsync = thenify(function somethingAsync(a, b, c, callback) {\n  callback(null, a, b, c);\n});\n```\n\n- Backward compatible with callback\n\n```js\nvar thenify = require('thenify');\n\nvar somethingAsync = thenify(function somethingAsync(a, b, c, callback) {\n  callback(null, a, b, c);\n}, { withCallback: true });\n\n// somethingAsync(a, b, c).then(onFulfilled).catch(onRejected);\n// somethingAsync(a, b, c, function () {});\n```\n\nor use `thenify.withCallback()`\n\n```js\nvar thenify = require('thenify').withCallback;\n\nvar somethingAsync = thenify(function somethingAsync(a, b, c, callback) {\n  callback(null, a, b, c);\n});\n\n// somethingAsync(a, b, c).then(onFulfilled).catch(onRejected);\n// somethingAsync(a, b, c, function () {});\n```\n\n- Always return the first argument in callback\n\n```js\nvar thenify = require('thenify');\n\nvar promise = thenify(function (callback) {\n  callback(null, 1, 2, 3);\n}, { multiArgs: false });\n\n// promise().then(function onFulfilled(value) {\n//   assert.equal(value, 1);\n// });\n```\n\n- Converts callback arguments to an object\n\n```js\nvar thenify = require('thenify');\n\nvar promise = thenify(function (callback) {\n  callback(null, 1, 2, 3);\n}, { multiArgs: [ 'one', 'tow', 'three' ] });\n\n// promise().then(function onFulfilled(value) {\n//   assert.deepEqual(value, {\n//     one: 1,\n//     tow: 2,\n//     three: 3\n//   });\n// });\n```\n\n[gitter-image]: https://badges.gitter.im/thenables/thenify.png\n[gitter-url]: https://gitter.im/thenables/thenify\n[npm-image]: https://img.shields.io/npm/v/thenify.svg?style=flat-square\n[npm-url]: https://npmjs.org/package/thenify\n[github-tag]: http://img.shields.io/github/tag/thenables/thenify.svg?style=flat-square\n[github-url]: https://github.com/thenables/thenify/tags\n[travis-image]: https://img.shields.io/travis/thenables/thenify.svg?style=flat-square\n[travis-url]: https://travis-ci.org/thenables/thenify\n[coveralls-image]: https://img.shields.io/coveralls/thenables/thenify.svg?style=flat-square\n[coveralls-url]: https://coveralls.io/r/thenables/thenify\n[david-image]: http://img.shields.io/david/thenables/thenify.svg?style=flat-square\n[david-url]: https://david-dm.org/thenables/thenify\n[license-image]: http://img.shields.io/npm/l/thenify.svg?style=flat-square\n[license-url]: LICENSE\n[downloads-image]: http://img.shields.io/npm/dm/thenify.svg?style=flat-square\n[downloads-url]: https://npmjs.org/package/thenify\n","_attachments":{},"homepage":"https://github.com/thenables/thenify#readme","bugs":{"url":"https://github.com/thenables/thenify/issues"},"license":"MIT"}