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

eprom

Package Overview
Dependencies
Maintainers
4
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

eprom

JavaScript Async Primitive

  • 1.0.0
  • latest
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
152
decreased by-36.67%
Maintainers
4
Weekly downloads
 
Created
Source

eprom

travis npm

eprom is an enhanced promise implementation. It works by wrapping a globally available Promise class and is as compliant with the Promises/A+ spec as the global Promise is.

In addition to the usual then, call and finally instance methods, it provides resolve and reject methods. In this regard, it resembles jQuery's Deferred object. On top of that, it features a reset method that enables repeat fulfillment.

Installation

Using NPM:

npm install -S eprom

Using Yarn:

yarn add eprom

API

eprom's EnhancedPromise mimics more usual Promises in every way. As such, it provides all class (resolve, reject, all, race) and instance (then, catch, finally) methods these provide.

enhancedPromise.resolve(value)

This method resolves an EnhancedPromise's inner Promise, triggering the execution of all onFulfilled handlers.

const enhancedPromise = new EnhancedPromise();
enhancedPromise.then(value => console.log(value));
enhancedPromise.resolve('foo');
// logs 'foo'
enhancedPromise.reject(reason)

This method rejects an EnhancedPromise's inner Promise, triggering the execution of all onRejected handlers.

const enhancedPromise = new EnhancedPromise();
enhancedPromise.catch(reason => console.err(reason));
enhancedPromise.reject('bar');
// logs 'bar'
enhancedPromise.reset()

This method creates a fresh inner Promise and thus allows for the re-fulfillment of an EnhancedPromise. A typical use case for this is handling repeat builds triggered by Webpack in watch mode.

const enhancedPromise = new EnhancedPromise();

enhancedPromise.then(value => console.log(value));
enhancedPromise.resolve('foo');
// logs 'foo'

enhancedPromise.reset();

enhancedPromise.then(value => console.log(value));
enhancedPromise.resolve('bar');
// logs 'bar'

FAQs

Package last updated on 24 Oct 2018

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