{"_id":"callbackify","_rev":"118940","name":"callbackify","description":"backwards compatibilify your callback functions while migrating apis to promises","dist-tags":{"latest":"1.1.0"},"maintainers":[{"name":"jden","email":"jason@denizac.org"}],"time":{"modified":"2021-06-03T10:54:41.000Z","created":"2013-08-14T19:26:27.273Z","1.1.0":"2015-03-10T21:29:24.202Z","1.0.0":"2014-07-13T18:54:25.916Z","0.1.2":"2014-04-28T21:05:48.340Z","0.1.1":"2013-12-10T21:01:25.704Z","0.1.0":"2013-08-14T19:26:27.273Z"},"users":{"allain":true,"guumaster":true,"andrewconnell":true,"shakakira":true},"author":{"name":"jden","email":"jason@denizac.org"},"repository":{"type":"git","url":"git@github.com:jden/callbackify.git"},"versions":{"1.1.0":{"name":"callbackify","author":{"name":"jden","email":"jason@denizac.org"},"version":"1.1.0","description":"backwards compatibilify your callback functions while migrating apis to promises","keywords":["promises","promisesaplus"],"main":"index.js","scripts":{"test":"node node_modules/mocha/bin/mocha"},"repository":{"type":"git","url":"git@github.com:jden/callbackify.git"},"license":"MIT","devDependencies":{"chai":"^1.9.1","mocha":"^1.20.1","bluebird":"^2.2.1"},"gitHead":"f36d4ed6e905dc400746c17c4b02ad5c23e6bf71","bugs":{"url":"https://github.com/jden/callbackify/issues"},"homepage":"https://github.com/jden/callbackify","_id":"callbackify@1.1.0","_shasum":"d2a36986d28aa69714526c111209beeb9979d31e","_from":".","_npmVersion":"2.5.0","_nodeVersion":"0.10.36","_npmUser":{"name":"jden","email":"jason@denizac.org"},"maintainers":[{"name":"jden","email":"jason@denizac.org"}],"dist":{"shasum":"d2a36986d28aa69714526c111209beeb9979d31e","size":2813,"noattachment":false,"key":"/callbackify/-/callbackify-1.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/callbackify/download/callbackify-1.1.0.tgz"},"directories":{},"publish_time":1426022964202,"_cnpm_publish_time":1426022964202,"_hasShrinkwrap":false},"1.0.0":{"name":"callbackify","author":{"name":"jden","email":"jason@denizac.org"},"version":"1.0.0","description":"backwards compatibilify your callback functions while migrating apis to promises","keywords":["promises","promisesaplus"],"main":"index.js","scripts":{"test":"node node_modules/mocha/bin/mocha"},"repository":{"type":"git","url":"git@github.com:jden/callbackify.git"},"license":"MIT","devDependencies":{"chai":"^1.9.1","mocha":"^1.20.1","bluebird":"^2.2.1"},"bugs":{"url":"https://github.com/jden/callbackify/issues"},"homepage":"https://github.com/jden/callbackify","_id":"callbackify@1.0.0","dist":{"shasum":"424b3eedc7ce89de485ae7754aa8aa6593c6a23c","size":2548,"noattachment":false,"key":"/callbackify/-/callbackify-1.0.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/callbackify/download/callbackify-1.0.0.tgz"},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"jden","email":"jason@denizac.org"},"maintainers":[{"name":"jden","email":"jason@denizac.org"}],"directories":{},"publish_time":1405277665916,"_cnpm_publish_time":1405277665916,"_hasShrinkwrap":false},"0.1.2":{"name":"callbackify","author":{"name":"jden","email":"jason@denizac.org"},"version":"0.1.2","description":"backwards compatibilify your callback functions while migrating apis to promises","keywords":["promises","promisesaplus"],"main":"index.js","scripts":{"test":"node node_modules/mocha/bin/mocha"},"repository":{"type":"git","url":"git@github.com:jden/callbackify.git"},"license":"MIT","devDependencies":{"chai":"~1.6.0","mocha":"~1.9.0","bluebird":"~0.11.5-0"},"bugs":{"url":"https://github.com/jden/callbackify/issues"},"homepage":"https://github.com/jden/callbackify","_id":"callbackify@0.1.2","dist":{"shasum":"2e7cdaba793237af6f0d184891c67b4ef689c6cc","size":2391,"noattachment":false,"key":"/callbackify/-/callbackify-0.1.2.tgz","tarball":"http://registry.cnpm.dingdandao.com/callbackify/download/callbackify-0.1.2.tgz"},"_from":".","_npmVersion":"1.4.3","_npmUser":{"name":"jden","email":"jason@denizac.org"},"maintainers":[{"name":"jden","email":"jason@denizac.org"}],"directories":{},"publish_time":1398719148340,"_cnpm_publish_time":1398719148340,"_hasShrinkwrap":false},"0.1.1":{"name":"callbackify","author":{"name":"jden","email":"jason@denizac.org"},"version":"0.1.1","description":"backwards compatibilify your callback functions while migrating apis to promises","keywords":["promises","promisesaplus"],"main":"index.js","scripts":{"test":"node node_modules/mocha/bin/mocha"},"repository":{"type":"git","url":"git@github.com:jden/callbackify.git"},"license":"MIT","readmeFilename":"README.md","devDependencies":{"chai":"~1.6.0","mocha":"~1.9.0","bluebird":"~0.11.5-0"},"bugs":{"url":"https://github.com/jden/callbackify/issues"},"homepage":"https://github.com/jden/callbackify","_id":"callbackify@0.1.1","dist":{"shasum":"3b1cdd6c4b326d75006bd8ad5a93a7a214117cda","size":2422,"noattachment":false,"key":"/callbackify/-/callbackify-0.1.1.tgz","tarball":"http://registry.cnpm.dingdandao.com/callbackify/download/callbackify-0.1.1.tgz"},"_from":".","_npmVersion":"1.3.14","_npmUser":{"name":"jden","email":"jason@denizac.org"},"maintainers":[{"name":"jden","email":"jason@denizac.org"}],"directories":{},"publish_time":1386709285704,"_cnpm_publish_time":1386709285704,"_hasShrinkwrap":false},"0.1.0":{"name":"callbackify","author":{"name":"jden","email":"jason@denizac.org"},"version":"0.1.0","description":"backwards compatibilify your callback functions while migrating apis to promises","keywords":["promises","promisesaplus"],"main":"index.js","scripts":{"test":"node node_modules/mocha/bin/mocha"},"repository":{"type":"git","url":"git@github.com:jden/callbackify.git"},"license":"MIT","readmeFilename":"README.md","devDependencies":{"chai":"~1.6.0","mocha":"~1.9.0","q":"~0.9.6"},"bugs":{"url":"https://github.com/jden/callbackify/issues"},"_id":"callbackify@0.1.0","dist":{"shasum":"cd2832a1ad4138fdf1b21eb3208c69ba02085d66","size":2353,"noattachment":false,"key":"/callbackify/-/callbackify-0.1.0.tgz","tarball":"http://registry.cnpm.dingdandao.com/callbackify/download/callbackify-0.1.0.tgz"},"_from":".","_npmVersion":"1.3.5","_npmUser":{"name":"jden","email":"jason@denizac.org"},"maintainers":[{"name":"jden","email":"jason@denizac.org"}],"directories":{},"publish_time":1376508387273,"_cnpm_publish_time":1376508387273,"_hasShrinkwrap":false}},"readme":"# callbackify\nbackwards compatibilify your callback functions while migrating apis to promises\n\n## usage\n```js\nvar callbackify = require('callbackify')\n\nvar getUserById = callbackify(function (id) {\n  // in this example, we're using [minq](https://npm.im/minq)\n  return db.users.byId(id).first()\n})\n\n// later in your code, we can use a callback\n\ngetUserById(23, function (err, user) {\n  if (err) { /* give up */ return }\n  console.log('hello, ', user.name)\n})\n\n// but for newer code, we can consume it as a promise\n\ngetUserById(23).then(function (user) {\n  console.log('hello, ', user.name)\n}, function (err) {\n  console.error(err)\n})\n\n```\n`callbackify` will also preserve the `this` context of your functions:\n```js\ngetUserById.call({foo:true}, 12)\n// the underlying promise-returning function is called with the supplied context argument\n```\n\nNormally, callbackify will only work with fixed-parameter-length functions, and will use the declared\nparameter length to determine if the extra callback argument is present.  If you need to use\ncallbackify with variadic functions, or functions that don't declare their full argument\nlist, you can use:\n```js\n// options argument is optional\nvar getUserById = callbackify.variadic(function (id, options) {\n  if (options === undefined) { options = {} }\n  if (options.select) {\n    return db.users.byId(id).select(options.select).first()\n  } else {\n    return db.users.byId(id).first()\n  }\n})\n\n// we can do either of these\ngetUserById(23, function (err, user) { })\ngetUserById(23, { select: [ 'name' ] }, function (err, user) {} )\n```\nNote that this will not work if the last argument your function can take\nis a function, as that last argument will always be detected as a callback\nfunction.\n\n## api\n\n### `callbackify : (fn: (...args) => Promise<T> ) => (...args, Callback<T>) => Promise<T>`\n\nTakes a Promise-returning function `fn` and returns a new function which can return a Promise or take a callback as the last parameter. If a callback is supplied, the function returns void. If no callback is supplied, the promise is returned.\n\n## installation\n\n    $ npm install callbackify\n\n\n## running the tests\n\nFrom package root:\n\n    $ npm install\n    $ npm test\n\n\n## contributors\n\n- jden <jason@denizac.org>\n- tootallnate <nathan@tootallnate.net>\n\n\n## license\n\nMIT. (c) MMXIII jden <jason@denizac.org>. See LICENSE.md\n","_attachments":{},"homepage":"https://github.com/jden/callbackify","bugs":{"url":"https://github.com/jden/callbackify/issues"},"license":"MIT"}