Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

promise-factory

Package Overview
Dependencies
Maintainers
1
Versions
3
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

promise-factory

A wrapper for creating promises in JavaScript based on native ES2015 promises.

  • 1.0.4
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
0
decreased by-100%
Maintainers
1
Weekly downloads
 
Created
Source

Build Status

promise-factory

A wrapper for creating promises in JavaScript based on native ES2015 promises.

Installation

npm install promise-factory --save

Usage

ES5

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);
});

ES2015

import {PromiseFactory as pf} from "promise-factory";

pf.create((resolve, reject) => {
  resolve("test");
}).then((res) => {
  console.log(res);
})

API

PromiseFactory.all

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);
});

PromiseFactory.create

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);
});

PromiseFactory.createFromNode

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);
});

Keywords

FAQs

Package last updated on 27 Feb 2016

Did you know?

Socket

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.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc