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

promish

Package Overview
Dependencies
Maintainers
1
Versions
27
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

promish

ES6 Promise Shim

  • 0.0.2
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
29K
decreased by-4.03%
Maintainers
1
Weekly downloads
 
Created
Source

Promish

     SH
      I
P R O M

The Promish module creates a wrapper around the EcmaScript 6 Promise class. It adds some of the useful features found in many of the other popular promise libraries such as Q and Bluebird. It is designed to be interchangeable with the ES6 Promise as its interface is a superset of the Promise class.

Installation

npm install promish

New Features!

  • Promish.delay()
  • Promish.defer()

Backlog

  • TBD

Contents

Interface

Include

var Promish = require('promish');

Instantiation

Typical use - construct with handler function

var promise = new Promish(function(resolve, reject) {
  // do something async
});

3rd Party Wrapper Mode

var promise = new Promish(Q());

Value Wrapper Mode

var promise = new Promish('Resolve Value');

Error Wrapper Mode

var promise = new Promish(new Error('This promise is rejected'));

Then

// typical use
promise
  .then(function(value) {
    // something async has completed with a value
    // here you can return a resolve value,
    // return a new Promish or throw an error (handled as rejection)
  });
  
// with onRejected...
promise.then(
  function(value) {
  },
  function(error) {
  });

Catch

// catch all
promise
  .catch(function(error) {
    // Something async has failed with an error.
    // Just like with then(), you can return a resolve value,
    // return a new Promish or throw a new error (handled as rejection)
    // You can also 'rethrow' the error by returning a new Promish with the error
  });

Defer

For compatability with the old Promise.defer() pattern...

function readAFile(filename) {
  var deferred = Promish.defer();
  
  fs.readFile(filename, function(error, data) {
    if (error) {
      deferred.reject(error);
    } else {
      deferred.resolve(data);
    }
  });
  
  return deferred.promise;
}

Known Issues

  • TBD

Release History

VersionChanges
0.0.1
  • Initial Version
0.0.2

Keywords

FAQs

Package last updated on 18 Aug 2015

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