Skip to content

A deferred promise implementation on top of Promises/A+ spec for Node.js or the browser.

Notifications You must be signed in to change notification settings

mjwwit/es6-deferred-promise

Repository files navigation

es6-deferred-promise

A deferred promise implementation on top of Promises/A+ spec. TypeScript definition file included.

Installation

npm install --save es6-deferred-promise

Usage

In ES2015 JavaScript:

const Deferred = require('es6-deferred-promise').Deferred;
const deferred = new Deferred();

deferred.promise
  .then(result => {
    console.log('Result: %s', result);
  });

// Resolving a promise
deferred.resolve('Success!');

// Rejecting a promise
deferred.reject('Failure!');

In TypeScript:

import { Deferred } from 'es6-deferred-promise';

const deferred = new Deferred<string>();

deferred.promise
  .then(result => {
    console.log(result);
  });

deferred.resolve('success');

Testing

npm install
npm test

About

A deferred promise implementation on top of Promises/A+ spec for Node.js or the browser.

Topics

Resources

Stars

Watchers

Forks

Packages

No packages published