Security News
NVD Backlog Tops 20,000 CVEs Awaiting Analysis as NIST Prepares System Updates
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
js-promisify
Advanced tools
A simple utility to convert NodeJS async functions to native JS promises.
JS Promisify is a npm minimal and well-tested async module for NodeJS, that converts NodeJS async style functions to native JS promises (if they're supported by the underlying JavaScript engine, like in Node >= 4.0.0).
For example, it can be used to convert the NodeJS native file system library (fs
), to easily perform file operations with promises.
npm install js-promisify
(add "--save" if you want the module to be automatically added to your project's "package.json" dependencies)
promisify(fun, args, [ctx])
fun
can be any function with a callback argument that follows the Node JS async function pattern signature (i.e. the callback is the last argument and has a signature function(err, data)
).args
is an array containing all the arguments that need to be passed to fun
, excluding the callback.ctx
(optional) is what the variable this
should be bound to when fun
is called with the arguments provided through the args
array.const promisify = require('js-promisify');
const fs = require('fs');
promisify(fs.readFile, ['path/to/myfile.txt', {encoding: 'utf8'}])
.then(function (data) {
console.log(data);
})
.catch(function (err) {
console.log(err);
})
// Same as above, using async / await
(async () => {
console.log(await promisify(fs.readFile, ['path/to/myfile.txt', {encoding: 'utf8'}]))
})()
MIT License
FAQs
A simple utility to convert NodeJS async functions to native JS promises.
The npm package js-promisify receives a total of 4,124 weekly downloads. As such, js-promisify popularity was classified as popular.
We found that js-promisify demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
NVD’s backlog surpasses 20,000 CVEs as analysis slows and NIST announces new system updates to address ongoing delays.
Security News
Research
A malicious npm package disguised as a WhatsApp client is exploiting authentication flows with a remote kill switch to exfiltrate data and destroy files.
Security News
PyPI now supports digital attestations, enhancing security and trust by allowing package maintainers to verify the authenticity of Python packages.