{"_id":"@benzn/promisify","_rev":"1-d3de1dbeeeb5b9a9930c909507b008a1","name":"@benzn/promisify","dist-tags":{"latest":"0.0.1-beta-1"},"versions":{"0.0.1":{"name":"@benzn/promisify","version":"0.0.1","keywords":["promisify","utility","eventListener","function","object"],"author":{"name":"benzaria"},"license":"MIT","_id":"@benzn/promisify@0.0.1","maintainers":[{"name":"benzaria","email":"benz.github@gmail.com"}],"homepage":"https://benzaria.github.io/es-promisify","bugs":{"url":"https://github.com/benzaria/es-promisify/issues"},"dist":{"shasum":"1d41e4d5fd85d4d69cd528350e75b063c984718b","tarball":"https://registry.npmjs.org/@benzn/promisify/-/promisify-0.0.1.tgz","fileCount":6,"integrity":"sha512-0l2Ljycwoj0O9o8R91j61nRAatKHIzIVOlRufMVTp6qRTtAVmuIBB6yI/0KLcNRmZg20FoFW+HBs9t6enXWE3g==","signatures":[{"sig":"MEYCIQCYW1SoWpAQ8NglrwDNREQd+0LfOBOH2FClEwASHEx5ZgIhAIDz2HUqdhcUXwiD58vB1ljbrFEeJxWNp+8C50jVSc5C","keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U"}],"unpackedSize":24009},"main":".dist/index.js","type":"module","_from":"file:benzn-promisify-0.0.1.tgz","types":"./dist/types/index.d.ts","scripts":{"lint":"eslint ./src/index.ts","test":"tsx test/test.ts","tsup":"tsup","build":"tsup","start":"node ./dist/index.js","prebuild":"npm run check && npm run lint","build:cjs":"tsc --module CommonJS --outDir out/cjs","build:esm":"tsc --module ESNext --outDir out/esm","build:tsc":"npm run build:cjs && npm run build:esm","type-check":"tsc --noEmit"},"_npmUser":{"name":"benzaria","email":"benz.github@gmail.com"},"_resolved":"C:\\Users\\benz\\AppData\\Local\\Temp\\e4752d673277f51197b5529e42bd307c\\benzn-promisify-0.0.1.tgz","_integrity":"sha512-0l2Ljycwoj0O9o8R91j61nRAatKHIzIVOlRufMVTp6qRTtAVmuIBB6yI/0KLcNRmZg20FoFW+HBs9t6enXWE3g==","repository":{"url":"git+https://github.com/benzaria/es-promisify.git","type":"git"},"_npmVersion":"10.8.2","description":"Promisify utility for function and object","directories":{},"_nodeVersion":"20.18.0","dependencies":{"@benzn/to-ms":"^1.2.0"},"publishConfig":{"access":"public"},"_hasShrinkwrap":false,"devDependencies":{"tsx":"^4.19.2","tsup":"^8.3.5","eslint":"^9.19.0","globals":"^15.14.0","@eslint/js":"^9.19.0","typescript":"^5.7.3","typescript-eslint":"^8.21.0"},"_npmOperationalInternal":{"tmp":"tmp/promisify_0.0.1_1738256750327_0.22373753317954326","host":"s3://npm-registry-packages-npm-production"}},"0.0.1-beta-1":{"name":"@benzn/promisify","version":"0.0.1-beta-1","description":"Promisify utility for function and object","type":"module","main":"./dist/cjs/index.js","module":"./dist/esm/index.js","types":"./dist/types/index.d.ts","exports":{"types":"./dist/types/index.d.ts","import":"./dist/esm/index.js","require":"./dist/cjs/index.js"},"publishConfig":{"access":"public"},"repository":{"type":"git","url":"git+https://github.com/benzaria/promisify.git"},"author":{"name":"benzaria"},"license":"MIT","bugs":{"url":"https://github.com/benzaria/promisify/issues"},"homepage":"https://benzaria.github.io/promisify","keywords":["promisify","utility","eventListener","function","object","cache","fast","callback","promise","es-promisify"],"devDependencies":{"@eslint/js":"^9.19.0","@jest/globals":"^29.7.0","@types/jest":"^29.5.14","eslint":"^9.19.0","globals":"^15.14.0","jest":"^29.7.0","tsup":"^8.3.6","tsx":"^4.19.2","typescript":"^5.7.3","typescript-eslint":"^8.22.0"},"dependencies":{"@benzn/to-ms":"^1.2.0"},"scripts":{"start":"node ./dist/index.js","test":"tsx test","test:jest":"jest","dist":"npm run build:cjs && npm run build:esm && npm run build:types","predist":"npm run prebuild","build":"tsup","build:skip":"tsup","prebuild":"npm run type-check && npm run lint-check","build:types":"tsup --dts-only --out-dir ./dist/types","build:cjs":"tsup --format cjs --out-dir ./dist/cjs","build:esm":"tsup --format esm --out-dir ./dist/esm","type-check":"tsc --noEmit","lint-check":"eslint ./src/**/*"},"_id":"@benzn/promisify@0.0.1-beta-1","_integrity":"sha512-tJsSbl+cr+19VB8Jon9rirFBZv61cI5Ftvx4MH0HzccScQONOdnYTKMFYhBgeDz1htTxMYgSdtTCcsxgJRYEXA==","_resolved":"C:\\Users\\benz\\AppData\\Local\\Temp\\b4f39084e9bc62885c2670acb1f8cb6f\\benzn-promisify-0.0.1-beta-1.tgz","_from":"file:benzn-promisify-0.0.1-beta-1.tgz","_nodeVersion":"20.18.0","_npmVersion":"10.8.2","dist":{"integrity":"sha512-tJsSbl+cr+19VB8Jon9rirFBZv61cI5Ftvx4MH0HzccScQONOdnYTKMFYhBgeDz1htTxMYgSdtTCcsxgJRYEXA==","shasum":"78ec34d5ef42ad04e78fdf4f2789c56100ce914f","tarball":"https://registry.npmjs.org/@benzn/promisify/-/promisify-0.0.1-beta-1.tgz","fileCount":8,"unpackedSize":52043,"signatures":[{"keyid":"SHA256:DhQ8wR5APBvFHLF/+Tc+AYvPOdTpcIDqOhxsBHRwC7U","sig":"MEQCID7N8DZEvE+1NHNIYKg/y9tOWZzEuA6sSADca3aHEJYsAiBsCdMv3rfOo/hxfSH4gD8b3q6QpdQJ8Dc1tAf1KdFTVQ=="}]},"_npmUser":{"name":"benzaria","email":"benz.github@gmail.com"},"directories":{},"maintainers":[{"name":"benzaria","email":"benz.github@gmail.com"}],"_npmOperationalInternal":{"host":"s3://npm-registry-packages-npm-production","tmp":"tmp/promisify_0.0.1-beta-1_1738332879828_0.7445035266017768"},"_hasShrinkwrap":false}},"time":{"created":"2025-01-30T17:05:50.217Z","modified":"2025-01-31T14:14:40.300Z","0.0.1":"2025-01-30T17:05:50.544Z","0.0.1-beta-1":"2025-01-31T14:14:40.072Z"},"bugs":{"url":"https://github.com/benzaria/promisify/issues"},"author":{"name":"benzaria"},"license":"MIT","homepage":"https://benzaria.github.io/promisify","keywords":["promisify","utility","eventListener","function","object","cache","fast","callback","promise","es-promisify"],"repository":{"type":"git","url":"git+https://github.com/benzaria/promisify.git"},"description":"Promisify utility for function and object","maintainers":[{"name":"benzaria","email":"benz.github@gmail.com"}],"readme":"# es-promisify\r\n\r\n`es-promisify` is a lightweight utility that converts Node.js callback-style functions to Promises, enabling you to use modern async/await syntax with legacy APIs.\r\n\r\n## Installation\r\n\r\nYou can install `es-promisify` via npm:\r\n\r\n```sh\r\nnpm install es-promisify\r\n```\r\n\r\n## Basic Usage\r\n\r\nHere's a basic example of how to use `es-promisify`: [More](#advance-usage)\r\n\r\n- [x] **cjs**\r\n\r\n```typescript\r\nconst promisify = require('es-promisify')\r\nconst fs = require('fs')\r\n\r\n// overload-1: promisify(fn, optionsObj)\r\nconst readFileAsync = promisify(fs.readFile, { timeout: '2s', bind: fs, cbType: 'errFirst', cache: true })\r\n\r\nreadFileAsync('example.txt', 'utf8')\r\n  .then(data => console.log(data))\r\n  .catch(err => console.error(err))\r\n```\r\n\r\n- [x] **esm**\r\n\r\n```typescript\r\nimport promisify from 'es-promisify'\r\n\r\nconst fn = (str: string, cb: (err, ...res) => void) => {\r\n  setTimeout(() => {\r\n    cb(null, str.toUpperCase())\r\n  }, 2e3)\r\n}\r\n\r\n// overload-2: promisify(fn, timeout, optionsObj)\r\nconst result = await promisify(fn, 3e3)('upperCase this!!')\r\n\r\nconsole.log(result) //=> UPPERCASE THIS!! after 2s\r\n```\r\n\r\n## API\r\n\r\n### promisify(target, ...params)\r\n\r\n- `target` (Function|Object): With callback-style to convert.\r\n- ***...params*** :\r\n  - `timeout` (String|Number): Timeout for the promisified function.\r\n  - `bind` (Object|String): The context for the function. `'this' = target`\r\n  - `options` (Object): Optional settings.\r\n    - `timeout`, `bind` : Optional overload prop, instead of the above.\r\n    - `cbType` (String): Callback type, either 'errFirst' or 'resultOnly'.\r\n    - `cache` (Boolean): Whether to cache the promisified function.\r\n- Returns: A `Promise` function.\r\n\r\n## Advance Usage\r\n\r\n### `Promisify` class\r\n\r\n```javascript\r\nimport { newPromisify, Promisify } from 'es-promisify'\r\n\r\n// methode-1 \r\nconst promisify = newPromisify(customPromiseConstructor, defultOptions)\r\n// return ↑ the handler binded to new instance\r\n\r\n// methode-2\r\nconst P = new Promisify(/* same optional args */) \r\n//    ↑ the class instance\r\nconst promisify = P.handler.bind(P)\r\n//        ↑ the handler\r\n\r\n\r\n\r\n```\r\n\r\n## Contributing\r\n\r\nContributions are welcome! Please open an issue or submit a pull request on GitHub.\r\n\r\n## License\r\n\r\nThis project is licensed under the MIT License.\r\n","readmeFilename":"README.md"}