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.
pinkie-promise
Advanced tools
The pinkie-promise npm package is a lightweight Promise implementation for environments that do not have a native Promise support. It uses the 'pinkie' package as its core to provide a minimal Promise polyfill.
Promise creation and usage
This feature allows users to create new promises and handle their resolution or rejection. The code sample demonstrates how to create a new promise and use 'then' and 'catch' methods to handle its outcome.
const pinkiePromise = require('pinkie-promise');
const promise = new pinkiePromise(function(resolve, reject) {
// Asynchronous operation here
if (/* operation successful */) {
resolve('Success!');
} else {
reject('Failure!');
}
});
promise.then(function(value) {
console.log(value); // 'Success!'
}).catch(function(reason) {
console.log(reason); // 'Failure!'
});
Chaining promises
This feature demonstrates how promises can be chained to perform a sequence of asynchronous operations where each step waits for the previous one to complete.
const pinkiePromise = require('pinkie-promise');
pinkiePromise.resolve(1)
.then(function(value) {
return value + 1;
})
.then(function(value) {
return value + 1;
})
.then(function(value) {
console.log(value); // 3
});
Bluebird is a full-featured Promise library with a focus on innovative features and performance. It is significantly larger and more feature-rich than pinkie-promise, offering utilities like Promise.map, .spread, and .finally, as well as advanced features like cancellation.
Q is one of the earliest Promise libraries for JavaScript. It provides a robust set of Promise-related tools but is heavier compared to pinkie-promise. It includes features like long stack traces and custom methods for handling collections of promises.
ES6-Promise is a polyfill for the ES6 Promise specification. It aims to provide a close approximation to the native implementation of Promises in environments that lack such support. It is more widely used than pinkie-promise and has similar functionality but with a larger footprint.
ES2015 Promise ponyfill
Module exports global Promise object (if available) or pinkie
Promise polyfill.
$ npm install --save pinkie-promise
var Promise = require('pinkie-promise');
new Promise(function (resolve) { resolve('unicorns'); });
//=> Promise { 'unicorns' }
MIT © Vsevolod Strukchinsky
FAQs
ES2015 Promise ponyfill
The npm package pinkie-promise receives a total of 10,757,007 weekly downloads. As such, pinkie-promise popularity was classified as popular.
We found that pinkie-promise 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.