Very simple implementation of Deferred for TypeScript.
$ npm install --save ts-deferred
import {Deferred} from "ts-deferred";
let d: Deferred<string> = new Deferred<string>();
let p: Promise<string> = d.promise;
p.then(text => console.log(text));
d.resolve("Hello World!!");
let Deferred = require("ts-deferred").Deferred;
let d = new Deferred();
let p = d.promise;
p.then(function (text) {
console.log(text);
});
d.resolve("Hello World!!");
The promise.
Resolves the promise with the given value.
Rejects the promise with the given reason.
This library has no implementation of Promise<T>
.
If the target is es5 or less, it's depends
to es6-promise
or es6-shim.
- Clone this repository.
- Run
npm install
to install dependencies. - Run
npm run build
ornpm test
.
MIT