
Security News
OpenGrep Restores Fingerprinting in JSON and SARIF Outputs
OpenGrep has restored fingerprint and metavariable support in JSON and SARIF outputs, making static analysis more effective for CI/CD security automation.
An experiment with promises
@see example/example.js
var ahead = require('ahead');
Ahead provides a easy way to create promises. And lets you write asynchronous stuff that looks synchronous. Its thought as an experiment and not for real use. Error handling can get pretty confusing.
It adds two arguments to a function.
var random = ahead(function (delay, kept, broken) {
setTimeout(function () {
kept(Math.random());
}, delay);
});
var r = random(10); // creates a promise for a random number
r.then(function (number) { console.log(number);});
Functions created with ahead can take promises as arguments the execution gets deferred until all promised arguments are resolved
var multiply = ahead(function (a, b, keep) {
keep(a * b);
});
multiply(random(10), 3); // just looks synchronous
Ahead.shift converts a synchronous function (shifts it in time ahead).
var pow = ahead.shift(function (a, b) {
return Math.pow(a, b);
});
Lets shift console.log in time ahead
var log = ahead.shift(console.log.bind(console));
Thrown errors will break the promise
var fail = ahead.shift(function () {
throw Error("break everything");
});
All the above created functions can be used in a synchronous style but are executed asynchronous
log(pow(multiply(random(1000), 3), 2));
The returned value of each function created with ahead or ahead.shift is a promise for a future value
fail(random(1000), 3).then(
function success (value) {
},
function fail (reason) {
}
);
FAQs
An experiment with promises
The npm package ahead receives a total of 2 weekly downloads. As such, ahead popularity was classified as not popular.
We found that ahead 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
OpenGrep has restored fingerprint and metavariable support in JSON and SARIF outputs, making static analysis more effective for CI/CD security automation.
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.