Skip to content

Latest commit

 

History

History
46 lines (36 loc) · 788 Bytes

README.md

File metadata and controls

46 lines (36 loc) · 788 Bytes

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