{"_attachments":{},"_id":"universalify","_rev":"241-61f14432963ca28f5ee35089","author":{"name":"Ryan Zimmerman","email":"opensrc@ryanzim.com"},"description":"Make a callback- or promise-based function support both promises and callbacks.","dist-tags":{"latest":"2.0.1"},"license":"MIT","maintainers":[{"name":"ryanzim","email":"opensrc@ryanzim.com"}],"name":"universalify","readme":"# universalify\n\n![GitHub Workflow Status (branch)](https://img.shields.io/github/actions/workflow/status/RyanZim/universalify/ci.yml?branch=master)\n![Coveralls github branch](https://img.shields.io/coveralls/github/RyanZim/universalify/master.svg)\n![npm](https://img.shields.io/npm/dm/universalify.svg)\n![npm](https://img.shields.io/npm/l/universalify.svg)\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 three or more 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  // -> Hi!\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  // -> Hi!\n})\n```\n\n## License\n\nMIT\n","time":{"created":"2022-01-26T12:53:06.430Z","modified":"2023-11-01T17:20:47.033Z","2.0.0":"2020-07-25T13:35:08.897Z","1.0.0":"2020-03-06T21:39:56.588Z","0.2.0":"2020-02-19T16:24:46.080Z","0.1.2":"2018-06-20T11:17:11.369Z","0.1.1":"2017-07-20T14:41:09.194Z","0.1.0":"2017-04-22T14:32:41.242Z","0.0.1":"2017-04-08T17:28:40.301Z","2.0.1":"2023-11-01T17:12:45.392Z"},"versions":{"2.0.0":{"name":"universalify","version":"2.0.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"},"repository":{"type":"git","url":"git+https://github.com/RyanZim/universalify.git"},"scripts":{"test":"standard && nyc tape test/*.js | colortape"},"devDependencies":{"colortape":"^0.1.2","coveralls":"^3.0.1","nyc":"^15.0.0","standard":"^14.3.1","tape":"^5.0.1"},"engines":{"node":">= 10.0.0"},"gitHead":"a853a4aedc63c69fcdc62b77643d75b0d162a098","_id":"universalify@2.0.0","_nodeVersion":"14.0.0","_npmVersion":"6.14.4","dist":{"shasum":"75a4984efedc4b08975c5aeb73f530d02df25717","size":2067,"noattachment":false,"tarball":"https://registry.npmmirror.com/universalify/-/universalify-2.0.0.tgz","integrity":"sha512-hAZsKq7Yy11Zu1DE0OzWjw7nnLZmJZYTDZZyEFHZdUhV8FkH5MCfoU1XMaxXovpyW5nq5scPqq0ZDP9Zyl04oQ=="},"maintainers":[{"name":"ryanzim","email":"opensrc@ryanzim.com"}],"_npmUser":{"name":"ryanzim","email":"opensrc@ryanzim.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/universalify_2.0.0_1595684108772_0.826098899436974"},"_hasShrinkwrap":false,"publish_time":1595684108897,"_cnpm_publish_time":1595684108897,"_cnpmcore_publish_time":"2021-12-13T08:29:25.267Z"},"1.0.0":{"name":"universalify","version":"1.0.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"},"repository":{"type":"git","url":"git+https://github.com/RyanZim/universalify.git"},"scripts":{"test":"standard && nyc tape test/*.js | colortape"},"devDependencies":{"colortape":"^0.1.2","coveralls":"^3.0.1","nyc":"^15.0.0","standard":"^14.3.1","tape":"^4.6.3"},"engines":{"node":">= 10.0.0"},"gitHead":"17c5efbc1bc96c201d8b0b116d43f7b5e2cad297","_id":"universalify@1.0.0","_nodeVersion":"13.7.0","_npmVersion":"6.13.6","dist":{"shasum":"b61a1da173e8435b2fe3c67d29b9adf8594bd16d","size":2066,"noattachment":false,"tarball":"https://registry.npmmirror.com/universalify/-/universalify-1.0.0.tgz","integrity":"sha512-rb6X1W158d7pRQBg5gkR8uPaSfiids68LTJQYOtEUhoJUWBdaQHsuT/EUduxXYxcrt4r5PJ4fuHW1MHT6p0qug=="},"maintainers":[{"name":"ryanzim","email":"opensrc@ryanzim.com"}],"_npmUser":{"name":"ryanzim","email":"opensrc@ryanzim.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/universalify_1.0.0_1583530796485_0.383723721188459"},"_hasShrinkwrap":false,"publish_time":1583530796588,"_cnpm_publish_time":1583530796588,"_cnpmcore_publish_time":"2021-12-13T08:29:25.571Z"},"0.2.0":{"name":"universalify","version":"0.2.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"},"repository":{"type":"git","url":"git+https://github.com/RyanZim/universalify.git"},"scripts":{"test":"standard && nyc tape test/*.js | colortape"},"devDependencies":{"colortape":"^0.1.2","coveralls":"^3.0.1","nyc":"^10.2.0","standard":"^10.0.1","tape":"^4.6.3"},"engines":{"node":">= 4.0.0"},"gitHead":"4342aa98a8801428ac66319c956443c0bfb0ce7e","_id":"universalify@0.2.0","_nodeVersion":"13.7.0","_npmVersion":"6.13.6","dist":{"shasum":"6451760566fa857534745ab1dde952d1b1761be0","size":2051,"noattachment":false,"tarball":"https://registry.npmmirror.com/universalify/-/universalify-0.2.0.tgz","integrity":"sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg=="},"maintainers":[{"name":"ryanzim","email":"opensrc@ryanzim.com"}],"_npmUser":{"name":"ryanzim","email":"opensrc@ryanzim.com"},"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/universalify_0.2.0_1582129485961_0.19346377093010547"},"_hasShrinkwrap":false,"publish_time":1582129486080,"_cnpm_publish_time":1582129486080,"_cnpmcore_publish_time":"2021-12-13T08:29:25.844Z"},"0.1.2":{"name":"universalify","version":"0.1.2","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","coveralls":"^3.0.1","nyc":"^10.2.0","standard":"^10.0.1","tape":"^4.6.3"},"engines":{"node":">= 4.0.0"},"gitHead":"ab4b5cd7e962c4915da68bdf0e5b8f9aa677f8f6","_id":"universalify@0.1.2","_npmVersion":"5.8.0","_nodeVersion":"8.10.0","_npmUser":{"name":"ryanzim","email":"opensrc@ryanzim.com"},"dist":{"shasum":"b646f69be3942dabcecc9d6639c80dc105efaa66","size":2039,"noattachment":false,"tarball":"https://registry.npmmirror.com/universalify/-/universalify-0.1.2.tgz","integrity":"sha512-rBJeI5CXAlmy1pV+617WB9J63U6XcazHHF2f2dbJix4XzpUF0RS3Zbj0FGIOCAva5P/d/GBOYaACQ1w+0azUkg=="},"maintainers":[{"name":"ryanzim","email":"opensrc@ryanzim.com"}],"directories":{},"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/universalify_0.1.2_1529493431283_0.2533941036533853"},"_hasShrinkwrap":false,"publish_time":1529493431369,"_cnpm_publish_time":1529493431369,"_cnpmcore_publish_time":"2021-12-13T08:29:26.098Z"},"0.1.1":{"name":"universalify","version":"0.1.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":"6dcade29ad1fc945f3d2a6e63cf92ec041fa83d2","_id":"universalify@0.1.1","_shasum":"fa71badd4437af4c148841e3b3b165f9e9e590b7","_from":".","_npmVersion":"4.2.0","_nodeVersion":"7.8.0","_npmUser":{"name":"ryanzim","email":"opensrc@ryanzim.com"},"dist":{"shasum":"fa71badd4437af4c148841e3b3b165f9e9e590b7","size":1990,"noattachment":false,"tarball":"https://registry.npmmirror.com/universalify/-/universalify-0.1.1.tgz","integrity":"sha512-MVi79HEPwGk0grI7/Kl6H51fX7wcDTe6gGoCdK22pkRG6IPsi9L6NltClWJfBLUoIE5y3pKy3SplFAs/b0G+QQ=="},"maintainers":[{"name":"ryanzim","email":"opensrc@ryanzim.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/universalify-0.1.1.tgz_1500561668015_0.5723595882300287"},"directories":{},"publish_time":1500561669194,"_hasShrinkwrap":false,"_cnpm_publish_time":1500561669194,"_cnpmcore_publish_time":"2021-12-13T08:29:26.459Z"},"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","size":1993,"noattachment":false,"tarball":"https://registry.npmmirror.com/universalify/-/universalify-0.1.0.tgz","integrity":"sha512-fYHpatg8wmx63V78K3cA10Xo1bXeFZB0m18BkXjs7buvgq/Ew96SX8wPIIl/qUuEOo5L1/KJ7nfbUlMtAHmbPw=="},"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":{},"publish_time":1492871561242,"_hasShrinkwrap":false,"_cnpm_publish_time":1492871561242,"_cnpmcore_publish_time":"2021-12-13T08:29:26.769Z"},"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","size":1959,"noattachment":false,"tarball":"https://registry.npmmirror.com/universalify/-/universalify-0.0.1.tgz","integrity":"sha512-1L8JNmaIuH/QHyT0Rc3+ba62M0fR/agg5EF+CXM2m9O0OzP/oRjYa1NBSzb7NLke+bIT0C2JEGNlF4Fe9rWi8A=="},"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":{},"publish_time":1491672520301,"_hasShrinkwrap":false,"_cnpm_publish_time":1491672520301,"_cnpmcore_publish_time":"2021-12-13T08:29:27.153Z"},"2.0.1":{"name":"universalify","version":"2.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"},"repository":{"type":"git","url":"git+https://github.com/RyanZim/universalify.git"},"scripts":{"test":"standard && nyc --reporter text --reporter lcovonly tape test/*.js | colortape"},"devDependencies":{"colortape":"^0.1.2","coveralls":"^3.0.1","nyc":"^15.0.0","standard":"^14.3.1","tape":"^5.0.1"},"engines":{"node":">= 10.0.0"},"gitHead":"dc17e0e00fb39c8d52e97ce77e494cdadfa8d19c","_id":"universalify@2.0.1","_nodeVersion":"18.15.0","_npmVersion":"9.5.0","dist":{"integrity":"sha512-gptHNQghINnc/vTGIk0SOFGFNXw7JVrlRUtConJRlvaw6DuX0wO5Jeko9sWrMBhh+PsYAZ7oXAiOnf/UKogyiw==","shasum":"168efc2180964e6386d061e094df61afe239b18d","tarball":"https://registry.npmmirror.com/universalify/-/universalify-2.0.1.tgz","fileCount":4,"unpackedSize":4675,"signatures":[{"keyid":"SHA256:jl3bwswu80PjjokCgh0o2w5c2U4LhQAE57gj9cz1kzA","sig":"MEUCIAUFWZO9ik+8IH55REhY6tJ/JfNYwYpdKIM3FXV7NX/7AiEAnLH4+tAcL1mGyIz4gVmPJVA16jBN25Z/HykKLkZFn84="}],"size":2068},"_npmUser":{"name":"ryanzim","email":"opensrc@ryanzim.com"},"directories":{},"maintainers":[{"name":"ryanzim","email":"opensrc@ryanzim.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages","tmp":"tmp/universalify_2.0.1_1698858765140_0.22716497055102036"},"_hasShrinkwrap":false,"_cnpmcore_publish_time":"2023-11-01T17:12:45.392Z","publish_time":1698858765392,"_source_registry_name":"default"}},"bugs":{"url":"https://github.com/RyanZim/universalify/issues"},"homepage":"https://github.com/RyanZim/universalify#readme","keywords":["callback","native","promise"],"repository":{"type":"git","url":"git+https://github.com/RyanZim/universalify.git"},"_source_registry_name":"default"}