
Security News
Attackers Are Hunting High-Impact Node.js Maintainers in a Coordinated Social Engineering Campaign
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.
Bonnet is a simple tool for distribute your long running blocking tasks in time, using ES6 generators.
Bonnet is a simple tool for distributing your long running blocking tasks in time using ES6 generators in node.
Using Bonnet you are able to split your computation into pieces with yield and in the end return your result. Bonnet returns a promise and resolves it, if your function finished or rejects it, if you throw an error. The benefit of this is that you won't block your event loop if you are working on small fast parts.
$ npm install bonnet
And after:
var bonnet = require('bonnet');
bonnet(myGenerator);
var bonnet = require('bonnet');
bonnet(function* () {
var sum = 0;
for (var i = 0; i <= 10000; i++) {
yield sum = sum + i;
}
return sum;
}).then(function (data) {
console.log(data);
}, function (error) {
console.log(error);
});
var bonnet = require('bonnet');
var Promise = require('promise');
function myAsynchronousTask() {
return new Promise(function (resolve, reject) {
setTimeout(function () {
resolve("bar");
}, 10);
});
}
bonnet(function* () {
var result = "foo";
result += yield myAsynchronousTask();
result += yield "foo";
return result;
}).then(function (data) {
console.log(data); //foobarfoo
});
var bonnet = require('bonnet');
bonnet(function* () {
var somethingWrong = true;
if(somethingWrong){
throw new Error("ERROR");
}
}).then(null, function (error) {
console.log(error);
});
var wrap = require('bonnet').wrap;
var wrappedFunction = wrap(function* (a,b) {
var str = "";
for (var i=0; i<=10000; i++){
str = yield (new Array(5)).join(b);
}
return a+str;
});
wrappedFunction("foo","bar").then(function(data){
console.log(data); //foobarbarbarbar
});
$ npm test
FAQs
Bonnet is a simple tool for distribute your long running blocking tasks in time, using ES6 generators.
We found that bonnet 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
Multiple high-impact npm maintainers confirm they have been targeted in the same social engineering campaign that compromised Axios.

Security News
Axios compromise traced to social engineering, showing how attacks on maintainers can bypass controls and expose the broader software supply chain.

Security News
Node.js has paused its bug bounty program after funding ended, removing payouts for vulnerability reports but keeping its security process unchanged.