{"library":"promisify-node","title":"Promisify Node","description":"promisify-node is a utility library designed to convert Node.js callback-style functions, methods, or entire modules into functions that return Promises. The current stable version is 0.5.0, though the project appears to be in an abandoned state with the last significant update in June 2020. Its primary differentiator is the ability to recursively wrap entire modules, automatically identifying asynchronous functions, and the option to wrap methods on objects either in-place or returning a new, non-mutated object. It uses an internal Promise implementation (or relies on a polyfill if not natively available) via `nodegit-promise` in older versions. Given its inactivity, users should be cautious about long-term support or compatibility with modern Node.js features like native ESM.","language":"javascript","status":"abandoned","last_verified":"Sun Apr 19","install":{"commands":["npm install promisify-node"],"cli":null},"imports":["const promisify = require('promisify-node');","const fs = require('promisify-node')('fs');","const wrappedFunc = promisify(callbackBasedFunction);"],"auth":{"required":false,"env_vars":[]},"quickstart":{"code":"const promisify = require('promisify-node');\nconst fs = require('fs');\n\n// Wrap the entire 'fs' module. The module is cloned and then its\n// asynchronous methods are identified and promisified.\nconst promisifiedFs = promisify(fs);\n\n// Use the promisified readFile function\npromisifiedFs.readFile('/etc/passwd', 'utf8')\n  .then(contents => {\n    console.log('File contents (first 100 chars):', contents.substring(0, 100));\n  })\n  .catch(err => {\n    console.error('Error reading file:', err.message);\n  });\n\n// Example of wrapping a single function\nfunction callbackStyleAsyncFunction(value, cb) {\n  setTimeout(() => {\n    if (value) {\n      cb(null, 'Success with: ' + value);\n    } else {\n      cb(new Error('No value provided'));\n    }\n  }, 50);\n}\n\nconst promisifiedFunc = promisify(callbackStyleAsyncFunction);\n\npromisifiedFunc('Hello Promisify')\n  .then(result => console.log('Promisified function result:', result))\n  .catch(error => console.log('Promisified function error:', error.message));","lang":"javascript","description":"This quickstart demonstrates how to promisify an entire Node.js module (like 'fs') and a standalone callback-style function, then use their promise-returning interfaces.","tag":null,"tag_description":null,"last_tested":null,"results":[]},"compatibility":null}