{"_id":"thenify-ex","_rev":"4-2cf6ad39ac064186cd4e2fc746761e99","name":"thenify-ex","dist-tags":{"latest":"4.4.0"},"versions":{"4.0.0":{"name":"thenify-ex","version":"4.0.0","keywords":["promisify","promise","thenify","then","es6"],"license":"MIT","_id":"thenify-ex@4.0.0","maintainers":[{"name":"erossignon","email":"etienne.rossignon@sterfive.com"}],"homepage":"https://github.com/node-opcua/thenify2#readme","bugs":{"url":"https://github.com/node-opcua/thenify2/issues"},"dist":{"shasum":"8db8e71577dfe820c45d7342040f469fd4b91a53","tarball":"https://registry.npmjs.org/thenify-ex/-/thenify-ex-4.0.0.tgz","fileCount":10,"integrity":"sha512-AuZ8c8BhAyDpWhpk6lD1y+4Ye7LpsSpOolpX1iunPpp4M9mzvBLrhh+3a5X7LElVSRq+7c3vB82R+xq6YQSp7w==","signatures":[{"sig":"MEQCIHKERsC48AbapS3dex2yNT+apPkcR3nis5xWR+xR3cNiAiBM3Ni7VA4ZB1zzSrOK3vzJjhygCkycLu/3A3qwqJCCwg==","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":19916},"main":"dist/index.cjs","type":"module","types":"dist/index.d.ts","module":"dist/index.js","authors":["Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)","Etienne Rossignon <etienne.rossignon@sterfive.com>"],"gitHead":"79602d99eb07aea0650e5e0a9ba1eecd3a47ab5c","scripts":{"ncu":"npx npm-check-updates -u","test":"mocha --reporter spec","build":"tsup","release":"npx release-it","test-cov":"istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot"},"_npmUser":{"name":"erossignon","email":"etienne.rossignon@sterfive.com"},"repository":{"url":"git+https://github.com/node-opcua/thenify2.git","type":"git"},"_npmVersion":"10.9.2","description":"Promisify a callback-based function","directories":{},"_nodeVersion":"22.13.0","dependencies":{"assert":"^2.1.0","any-promise":"^1.3.0","@types/assert":"^1.5.11"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.3.6","mocha":"11","typescript":"5"},"_npmOperationalInternal":{"tmp":"tmp/thenify-ex_4.0.0_1737895384945_0.979504665626568","host":"s3://npm-registry-packages-npm-production"}},"4.1.0":{"name":"thenify-ex","version":"4.1.0","keywords":["promisify","promise","thenify","then","es6"],"license":"MIT","_id":"thenify-ex@4.1.0","maintainers":[{"name":"erossignon","email":"etienne.rossignon@sterfive.com"}],"homepage":"https://github.com/node-opcua/thenify2#readme","bugs":{"url":"https://github.com/node-opcua/thenify2/issues"},"dist":{"shasum":"e81662b79c95536110a610274a750783a6bcd598","tarball":"https://registry.npmjs.org/thenify-ex/-/thenify-ex-4.1.0.tgz","fileCount":10,"integrity":"sha512-cBXUKQ73v64dQ6yyCLHX32z7zDXkPeDOWzR2YvYLItx8cCqqFaULc9u49hjJxSHu89F1z8KK/GTViSdJ0MgU1Q==","signatures":[{"sig":"MEUCIQD5rbpxe6ga0DfuwCu9Pc2z7KOOjZDSFx65VG+zbnRmhwIgUORrswdMKuvUph4O+65m4j10hjCjXGgF/LwPIGLJPzM=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":20015},"main":"./dist/index.cjs","types":"./dist/index.d.ts","authors":["Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)","Etienne Rossignon <etienne.rossignon@sterfive.com>"],"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"gitHead":"48c7e019f0c993471a347d2b163e5c9151f662ec","scripts":{"ncu":"npx npm-check-updates -u","test":"mocha --reporter spec","build":"tsup","release":"npx release-it","test-cov":"istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot"},"_npmUser":{"name":"erossignon","email":"etienne.rossignon@sterfive.com"},"repository":{"url":"git+https://github.com/node-opcua/thenify2.git","type":"git"},"_npmVersion":"10.2.1","description":"Promisify a callback-based function","directories":{},"_nodeVersion":"20.5.1","dependencies":{"assert":"^2.1.0","any-promise":"^1.3.0","@types/assert":"^1.5.11"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.3.6","mocha":"11","typescript":"5"},"_npmOperationalInternal":{"tmp":"tmp/thenify-ex_4.1.0_1737896267251_0.12090727462218887","host":"s3://npm-registry-packages-npm-production"}},"4.2.0":{"name":"thenify-ex","version":"4.2.0","keywords":["promisify","promise","thenify","then","es6"],"license":"MIT","_id":"thenify-ex@4.2.0","maintainers":[{"name":"erossignon","email":"etienne.rossignon@sterfive.com"}],"homepage":"https://github.com/node-opcua/thenify2#readme","bugs":{"url":"https://github.com/node-opcua/thenify2/issues"},"dist":{"shasum":"492ddad5c090761997a5418a9bbc69d7c85460c5","tarball":"https://registry.npmjs.org/thenify-ex/-/thenify-ex-4.2.0.tgz","fileCount":13,"integrity":"sha512-etsBsTYflau+wm9Gt8UR8g8JDYFbg2k53UtSsqy8CGiktwO+4BhstVc/Dj7Xt1fDNbn0a6cj7a9I8yrwPvnhIg==","signatures":[{"sig":"MEUCIQCn5kaX5V9YR6YHPFZXNUqSSZ6Qwlq2bpxh0nM6ZwMzCwIgDy3mkdzvhGjmDHHQTOUdqZAoz86S7SlhxUXG4wZ/5rI=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":26518},"main":"./dist/index.cjs","types":"./dist/index.d.ts","authors":["Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)","Etienne Rossignon <etienne.rossignon@sterfive.com>"],"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.cjs"}},"gitHead":"2729572671235e7bb11df18a2cc2d89b9a3034cc","scripts":{"ncu":"npx npm-check-updates -u","test":"mocha --reporter spec","build":"tsup","release":"npx release-it","test-cov":"istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot"},"_npmUser":{"name":"erossignon","email":"etienne.rossignon@sterfive.com"},"repository":{"url":"git+https://github.com/node-opcua/thenify2.git","type":"git"},"_npmVersion":"10.2.1","description":"Promisify a callback-based function","directories":{},"_nodeVersion":"20.5.1","dependencies":{"assert":"^2.1.0","any-promise":"^1.3.0","@types/assert":"^1.5.11"},"_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.3.6","mocha":"11","should":"^13.2.3","ts-node":"^10.9.2","typescript":"5","@types/node":"^22.10.10","@types/mocha":"^10.0.10"},"_npmOperationalInternal":{"tmp":"tmp/thenify-ex_4.2.0_1737901735953_0.3381815021094061","host":"s3://npm-registry-packages-npm-production"}},"4.3.0":{"name":"thenify-ex","version":"4.3.0","keywords":["promisify","promise","thenify","then","es6"],"license":"MIT","_id":"thenify-ex@4.3.0","maintainers":[{"name":"erossignon","email":"etienne.rossignon@sterfive.com"}],"homepage":"https://github.com/node-opcua/thenify-ex#readme","bugs":{"url":"https://github.com/node-opcua/thenify-ex/issues"},"dist":{"shasum":"9dd91fba4160db8c0819cc91c7e32082ca2979fe","tarball":"https://registry.npmjs.org/thenify-ex/-/thenify-ex-4.3.0.tgz","fileCount":10,"integrity":"sha512-Gj6HFImVhdXOxJiXamjsISKqJqckHg3xSnIwhZjqDqOVqXRhGcL8Kr6rrVnInNTVrEk0c6YPy9t0vrBc/Sw3NA==","signatures":[{"sig":"MEUCIQD1Yjkmh+NNK5hmVZJAMVqWoO92aes4eeD5E4dY7hc9ywIgNaZ0CozOVynJuCQ3dDdoK9sdFg9BPO3oZDOYfeOMd6A=","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":20254},"main":"./dist/index.js","types":"./dist/index.d.ts","authors":["Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)","Etienne Rossignon <etienne.rossignon@sterfive.com>"],"exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.js"}},"gitHead":"c5c016e3f3fc904136b75a63399b292afe485981","scripts":{"ncu":"npx npm-check-updates -u","test":"mocha --reporter spec","build":"npx tsup","release":"npx release-it","test-cov":"istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot"},"_npmUser":{"name":"erossignon","email":"etienne.rossignon@sterfive.com"},"repository":{"url":"git+https://github.com/node-opcua/thenify-ex.git","type":"git"},"_npmVersion":"10.9.2","description":"Promisify a callback-based function","directories":{},"_nodeVersion":"22.13.0","_hasShrinkwrap":false,"devDependencies":{"tsup":"^8.3.6","mocha":"11","should":"^13.2.3","ts-node":"^10.9.2","typescript":"5","@types/node":"^22.10.10","@types/mocha":"^10.0.10"},"_npmOperationalInternal":{"tmp":"tmp/thenify-ex_4.3.0_1738225613065_0.19193865921126507","host":"s3://npm-registry-packages-npm-production"}},"4.4.0":{"name":"thenify-ex","description":"Promisify a callback-based function","version":"4.4.0","authors":["Jonathan Ong <me@jongleberry.com> (http://jongleberry.com)","Etienne Rossignon <etienne.rossignon@sterfive.com>"],"license":"MIT","repository":{"type":"git","url":"git+https://github.com/node-opcua/thenify-ex.git"},"devDependencies":{"@types/mocha":"^10.0.10","@types/node":"^22.10.10","mocha":"11","should":"^13.2.3","ts-node":"^10.9.2","tsup":"^8.3.6","typescript":"5"},"types":"./dist/index.d.ts","main":"./dist/index.js","exports":{".":{"types":"./dist/index.d.ts","import":"./dist/index.js","require":"./dist/index.js"}},"scripts":{"build":"npx tsup","test":"mocha --reporter spec","test-cov":"istanbul cover node_modules/mocha/bin/_mocha -- --reporter dot","ncu":"npx npm-check-updates -u","release-it":"npm run build && npx release-it"},"keywords":["promisify","promise","thenify","then","es6"],"_id":"thenify-ex@4.4.0","gitHead":"56ed8af39b1bfb1b15fe4f88a67c75db573b2073","bugs":{"url":"https://github.com/node-opcua/thenify-ex/issues"},"homepage":"https://github.com/node-opcua/thenify-ex#readme","_nodeVersion":"20.5.1","_npmVersion":"10.2.1","dist":{"integrity":"sha512-YHA/2DlY1vWpqGLCc7BzdT9aTrqyHCbsX5J3zbW68LLeD4RPwd+2tMEWshMP+27ikuTnaeKbFDmjqc7fKWmDew==","shasum":"719fb14c9099851872fe2412438c696d50208fa4","tarball":"https://registry.npmjs.org/thenify-ex/-/thenify-ex-4.4.0.tgz","fileCount":10,"unpackedSize":20205,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEYCIQCbMZFdL+u65UuyBtiVNBMj5O9JAAMgzlfGhughL2bOwgIhAJJUmWOX4ZvfDChUVkuj8ObXqfH27AXoj90lm6nXfimF"}]},"_npmUser":{"name":"erossignon","email":"etienne.rossignon@sterfive.com"},"directories":{},"maintainers":[{"name":"erossignon","email":"etienne.rossignon@sterfive.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/thenify-ex_4.4.0_1738239098151_0.843724409056398"},"_hasShrinkwrap":false}},"time":{"created":"2025-01-26T12:43:04.944Z","modified":"2025-01-30T12:11:38.616Z","4.0.0":"2025-01-26T12:43:05.135Z","4.1.0":"2025-01-26T12:57:47.423Z","4.2.0":"2025-01-26T14:28:56.113Z","4.3.0":"2025-01-30T08:26:53.222Z","4.4.0":"2025-01-30T12:11:38.453Z"},"bugs":{"url":"https://github.com/node-opcua/thenify-ex/issues"},"license":"MIT","homepage":"https://github.com/node-opcua/thenify-ex#readme","keywords":["promisify","promise","thenify","then","es6"],"repository":{"type":"git","url":"git+https://github.com/node-opcua/thenify-ex.git"},"description":"Promisify a callback-based function","maintainers":[{"name":"erossignon","email":"etienne.rossignon@sterfive.com"}],"readme":"# thenify-ex\n\nA  fork of [thenify](thenify-url) to support modern CJS/ESM modules with typescript support.\n\n\n\n[![NPM version][npm-image]][npm-url]\n[![Build status][github-action-image]][github-action-url]\n[![Test coverage][coveralls-image]][coveralls-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\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\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\n```js\nimport { thenify } from 'thenify';\n\nconst  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\nimport { thenify } from 'thenify';\n\nconst somethingAsync = thenify(\n  function somethingAsync(a, b, c, callback) {\n    callback(null, a, b, c)\n  },\n  { withCallback: true },\n)\n\n// somethingAsync(a, b, c).then(onFulfilled).catch(onRejected);\n// somethingAsync(a, b, c, function () {});\n```\n\nor use `withCallback()`\n\n```js\nimport { withCallback}  from \"thenify\";\n\nvar somethingAsync = withCallback(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\nimport { thenify}  from \"thenify\";\n\nvar promise = thenify(\n  function (callback) {\n    callback(null, 1, 2, 3)\n  },\n  { multiArgs: false },\n)\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\nimport { thenify}  from \"thenify\";\n\nvar promise = thenify(\n  function (callback) {\n    callback(null, 1, 2, 3)\n  },\n  { multiArgs: ['one', 'tow', 'three'] },\n)\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[github-action-image]: https://github.com/node-opcua/thenify2/actions/workflows/workflow.yaml/badge.svg\n[github-action-url]: https://github.com/node-opcua/thenify2/actions\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[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-ex.svg?style=flat-square\n[downloads-url]: https://npmjs.org/package/thenify-ex\n","readmeFilename":"README.md"}