Security News
Weekly Downloads Now Available in npm Package Search Results
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
promise-factory
Advanced tools
A wrapper for creating promises in JavaScript based on native ES2015 promises.
A wrapper for creating promises in JavaScript based on native ES2015 promises.
npm install promise-factory --save
var pf = require("promise-factory").PromiseFactory;
var fs = require("fs");
pf.createFromNode(fs.readFile.bind(null, "package.json", { "encoding": "utf8" })).then(function(res) {
console.log(res);
});
import {PromiseFactory as pf} from "promise-factory";
pf.create((resolve, reject) => {
resolve("test");
}).then((res) => {
console.log(res);
})
Wraps the Promise.all function.
var pf = require("promise-factory").PromiseFactory;
pf.all([
pf.create(function(resolve, reject) {
resolve("test1");
}),
pf.create(function(resolve, reject) {
resolve("test2");
})
]).then(function(res) {
console.log(res);
});
Wraps the creation of a new promise in a static function.
var pf = require("promise-factory").PromiseFactory;
pf.create(function(resolve, reject) {
resolve("test2");
}).then(function(res) {
console.log(res);
});
Creates a promise from a function that takes a node style callback function as its only argument. Should you want to use a function that takes more arguments, you can bind them before calling this function.
var pf = require("promise-factory").PromiseFactory;
var fs = require("fs");
pf.createFromNode(fs.readFile.bind(null, "package.json", { "encoding": "utf8" })).then(function(res) {
console.log(res);
});
FAQs
A wrapper for creating promises in JavaScript based on native ES2015 promises.
The npm package promise-factory receives a total of 0 weekly downloads. As such, promise-factory popularity was classified as not popular.
We found that promise-factory 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
Socket's package search now displays weekly downloads for npm packages, helping developers quickly assess popularity and make more informed decisions.
Security News
A Stanford study reveals 9.5% of engineers contribute almost nothing, costing tech $90B annually, with remote work fueling the rise of "ghost engineers."
Research
Security News
Socket’s threat research team has detected six malicious npm packages typosquatting popular libraries to insert SSH backdoors.