@pedromsilva/data-future
TypeScript icon, indicating that this package has built-in type declarations

1.1.3 • Public • Published

Future

Simple TypeScript/ES2015 class to allow to create a promise and to be resolved/rejected later

Installation

npm install --save data-future

Usage

import { Future } from 'data-future';

const future = new Future<number>();

futrue.promise.then( number => console.log( number ) ); // 1

// Can be called anytime after instantiating a Future object
future.resolve( 1 );
import { Future } from 'data-future';

const future = new Future<number>();

futrue.promise.catch( err => console.error( err ) ); // Error {}

// Can be called anytime after instantiating a Future object
future.reject( new Error() );

Package Sidebar

Install

npm i @pedromsilva/data-future

Weekly Downloads

566

Version

1.1.3

License

ISC

Unpacked Size

8.24 kB

Total Files

7

Last publish

Collaborators

  • pedromsilva