{"maintainers":[{"name":"ryanzim","email":"opensrc@ryanzim.com"}],"keywords":["callback","native","promise"],"dist-tags":{"latest":"0.1.0"},"author":{"name":"Ryan Zimmerman","email":"opensrc@ryanzim.com"},"description":"Make a callback- or promise-based function support both promises and callbacks.","readme":"# universalify\n\n[![Travis branch](https://img.shields.io/travis/RyanZim/universalify/master.svg)](https://travis-ci.org/RyanZim/universalify)\n\nMake a callback- or promise-based function support both promises and callbacks.\n\nUses the native promise implementation.\n\n## Installation\n\n```bash\nnpm install universalify\n```\n\n## API\n\n### `universalify.fromCallback(fn)`\n\nTakes a callback-based function to universalify, and returns the universalified  function.\n\nFunction must take a callback as the last parameter that will be called with the signature `(error, result)`. `universalify` does not support calling the callback with more than three arguments, and does not ensure that the callback is only called once.\n\n```js\nfunction callbackFn (n, cb) {\n  setTimeout(() => cb(null, n), 15)\n}\n\nconst fn = universalify.fromCallback(callbackFn)\n\n// Works with Promises:\nfn('Hello World!')\n.then(result => console.log(result)) // -> Hello World!\n.catch(error => console.error(error))\n\n// Works with Callbacks:\nfn('Hi!', (error, result) => {\n  if (error) return console.error(error)\n  console.log(result)\n  // -> Hello World!\n})\n```\n\n### `universalify.fromPromise(fn)`\n\nTakes a promise-based function to universalify, and returns the universalified  function.\n\nFunction must return a valid JS promise. `universalify` does not ensure that a valid promise is returned.\n\n```js\nfunction promiseFn (n) {\n  return new Promise(resolve => {\n    setTimeout(() => resolve(n), 15)\n  })\n}\n\nconst fn = universalify.fromPromise(promiseFn)\n\n// Works with Promises:\nfn('Hello World!')\n.then(result => console.log(result)) // -> Hello World!\n.catch(error => console.error(error))\n\n// Works with Callbacks:\nfn('Hi!', (error, result) => {\n  if (error) return console.error(error)\n  console.log(result)\n  // -> Hello World!\n})\n```\n\n## License\n\nMIT\n","repository":{"type":"git","url":"git+https://github.com/RyanZim/universalify.git"},"users":{"heartnett":true,"larrychen":true},"bugs":{"url":"https://github.com/RyanZim/universalify/issues"},"license":"MIT","versions":{"0.0.1":{"name":"universalify","version":"0.0.1","description":"Make a callback- or promise-based function support both promises and callbacks.","keywords":["callback","native","promise"],"homepage":"https://github.com/RyanZim/universalify#readme","bugs":{"url":"https://github.com/RyanZim/universalify/issues"},"license":"MIT","author":{"name":"Ryan Zimmerman","email":"opensrc@ryanzim.com"},"files":["index.js"],"repository":{"type":"git","url":"git+https://github.com/RyanZim/universalify.git"},"scripts":{"test":"standard && nyc tape test/*.js | colortape"},"devDependencies":{"colortape":"^0.1.2","nyc":"^10.2.0","standard":"^10.0.1","tape":"^4.6.3"},"gitHead":"131e6f2b86511f880e04e5995e7a8db468e5bc24","_id":"universalify@0.0.1","_shasum":"937b1b69cecc2f27e27395428eb7952bc7939617","_from":".","_npmVersion":"4.2.0","_nodeVersion":"7.8.0","_npmUser":{"name":"ryanzim","email":"opensrc@ryanzim.com"},"dist":{"shasum":"937b1b69cecc2f27e27395428eb7952bc7939617","tarball":"http://nexus.dui88.com:8081/nexus/content/repositories/npm-registry/universalify/-/universalify-0.0.1.tgz"},"maintainers":[{"name":"ryanzim","email":"opensrc@ryanzim.com"}],"_npmOperationalInternal":{"host":"packages-12-west.internal.npmjs.com","tmp":"tmp/universalify-0.0.1.tgz_1491672518379_0.970205559860915"},"directories":{}},"0.1.0":{"name":"universalify","version":"0.1.0","description":"Make a callback- or promise-based function support both promises and callbacks.","keywords":["callback","native","promise"],"homepage":"https://github.com/RyanZim/universalify#readme","bugs":{"url":"https://github.com/RyanZim/universalify/issues"},"license":"MIT","author":{"name":"Ryan Zimmerman","email":"opensrc@ryanzim.com"},"files":["index.js"],"repository":{"type":"git","url":"git+https://github.com/RyanZim/universalify.git"},"scripts":{"test":"standard && nyc tape test/*.js | colortape"},"devDependencies":{"colortape":"^0.1.2","nyc":"^10.2.0","standard":"^10.0.1","tape":"^4.6.3"},"gitHead":"003666ace34712273c8dfb27b7a92b1112573f15","_id":"universalify@0.1.0","_shasum":"9eb1c4651debcc670cc94f1a75762332bb967778","_from":".","_npmVersion":"4.2.0","_nodeVersion":"7.8.0","_npmUser":{"name":"ryanzim","email":"opensrc@ryanzim.com"},"dist":{"shasum":"9eb1c4651debcc670cc94f1a75762332bb967778","tarball":"http://nexus.dui88.com:8081/nexus/content/repositories/npm-registry/universalify/-/universalify-0.1.0.tgz"},"maintainers":[{"name":"ryanzim","email":"opensrc@ryanzim.com"}],"_npmOperationalInternal":{"host":"packages-18-east.internal.npmjs.com","tmp":"tmp/universalify-0.1.0.tgz_1492871560174_0.5206800866872072"},"directories":{}}},"name":"universalify","time":{"modified":"2017-05-27T03:45:42.298Z","created":"2017-04-08T17:28:40.301Z","0.0.1":"2017-04-08T17:28:40.301Z","0.1.0":"2017-04-22T14:32:41.242Z"},"readmeFilename":"README.md","homepage":"https://github.com/RyanZim/universalify#readme"}