Research
Security News
Malicious npm Packages Inject SSH Backdoors via Typosquatted Libraries
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
accept-promises
Advanced tools
Let them into your heart and/or functions.
var assert = require('assert');
var acceptPromises = require('./');
var Promise = require('bluebird');
var add = acceptPromises(function (a, b) {
return a + b;
});
var assertIsPromise = function (it) {
assert(Promise.is(it));
};
assertPromise(add(1, 2));
add(1, 2).then(function (three) {
assert.equal(3, three);
});
assertPromise(
add(1, Promise.resolve(2))).then(function (three) {
assert.equal(3, three);
})
);
In addition to decorating individual functions, there is also a helper for walking over an object prototype:
function Calculator () {}
Calculator.prototype = acceptPromises.mutateMethods({
add: function (a, b) { return a + b },
sub: function (a, b) { return a - b },
mul: function (a, b) { return a * b },
div: function (a, b) { return a / b }
});
This module exports a function decorator that will wait for all Promise
arguments to a function to settle. This allows you to avoid writing a lot of
.then
boilerplate in your code, and write things as though they are sync.
This is really just the bindSync
decorator from z-core pulled out into
it's own module, since it was the only part of z-core
that I really wanted.
MIT
FAQs
Accept Promises into your heart and/or functions.
We found that accept-promises 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.
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.
Security News
MITRE's 2024 CWE Top 25 highlights critical software vulnerabilities like XSS, SQL Injection, and CSRF, reflecting shifts due to a refined ranking methodology.
Security News
In this segment of the Risky Business podcast, Feross Aboukhadijeh and Patrick Gray discuss the challenges of tracking malware discovered in open source softare.