
Security News
NVD Concedes Inability to Keep Pace with Surging CVE Disclosures in 2025
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.
Provide some promisified version (by bluebird) for some commonly used libs.
$ npm i bblib
For Standard libs:
const bfs = require('bblib/fs');
async function main() {
var exists = await bfs.exists('/path/to/file');
if (exists) {
// do something
}
}
main();
For npm packages: bblib provide only the promisify script, so that you don't need to install all the packages. in order to use promisified version of a npm package, you need to install it to your project manually. for example, if you'd like to use promisified request lib:
$ npm i request -S
const request = require('bblib/request');
async function main() {
var res = await request('https://www.google.com');
console.log(`status: ${res.statusCode}`);
console.log(`body : ${res.body}`);
}
main();
Some libs were designed base on EvenEmitter, which can not be promisified simply. Here is the list or some useful libs
Same as before, you need to install the original package first by
$ npm i $PKG -S
Wrap child_process
to execute shell command
Wrap ssh2
to provide ssh access
Homepage: https://github.com/mscdex/ssh2
const Client = require('bblib/ssh2');
async function main() {
var client = new Client({
host: 'example.com',
username: 'root',
password: '******'
});
var retryCount = 10;
try {
await client.connect(retryCount);
} catch (e) {
...
}
var files = await client.exec('ls');
var sftp = await client.sftp();
await sftp.writeFile('/path/to/files.log', files);
client.disconnect();
}
Wrap request to provide a general purpose RESTful client
var client = new RestClient({
suppress: true, // suppress rejection while response status is not ok
prefix: 'http://api.example.com', // api url prefix
beforeSend: async function(opts) { // modify request options before sending, like adding signature
opts.headers = {
signature: await sign(opt.form)
};
},
afterReceive: function(resp) { // reject with a custom error while status code is not 200
if (resp.status !== 200)
return P.reject(new MyOwnError('request error'));
}
})
// or:
var client = new RestClient({ suppress: true });
client.prefix = 'https://api.example.com';
client.beforeSend = function(options) { };
// then:
async function madin() {
var getQuery = { page: 2 };
var list = await client.get('/orders', getQuery);
if (list['error'])
throw new Error(list['message']);
console.log(list.body['data']);
var postJson = { name: 'John Doe', phone: '94823944', ... };
var postQuery = { overwrite: true };
var created = await client.post('/orders', postJson, postQuery);
if (created['error'])
throw new Error(created['message']);
console.log(created.body.data.id);
try {
client.suppress = false;
await client.get('/path/some/error');
} catch (e) {
console.log(e.response.body.message);
}
}
You are more than welcome to contribute by sending Pull Request.
FAQs
promisified libs for Node.js
We found that bblib 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
Security experts warn that recent classification changes obscure the true scope of the NVD backlog as CVE volume hits all-time highs.
Security Fundamentals
Attackers use obfuscation to hide malware in open source packages. Learn how to spot these techniques across npm, PyPI, Maven, and more.
Security News
Join Socket for exclusive networking events, rooftop gatherings, and one-on-one meetings during BSidesSF and RSA 2025 in San Francisco.