Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/pedromsilvapt/data-future
Simple TypeScript/ES2015 class to allow to create a promise and to be resolved/rejected later
https://github.com/pedromsilvapt/data-future
Last synced: 11 days ago
JSON representation
Simple TypeScript/ES2015 class to allow to create a promise and to be resolved/rejected later
- Host: GitHub
- URL: https://github.com/pedromsilvapt/data-future
- Owner: pedromsilvapt
- Created: 2018-04-19T14:10:03.000Z (over 6 years ago)
- Default Branch: master
- Last Pushed: 2019-06-25T20:39:58.000Z (over 5 years ago)
- Last Synced: 2024-12-22T16:34:34.942Z (17 days ago)
- Language: TypeScript
- Size: 2.93 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# Future
> Simple TypeScript/ES2015 class to allow to create a promise and to be resolved/rejected later
# Installation
```shell
npm install --save data-future
```# Usage
```typescript
import { Future } from 'data-future';const future = new Future();
futrue.promise.then( number => console.log( number ) ); // 1
// Can be called anytime after instantiating a Future object
future.resolve( 1 );
``````typescript
import { Future } from 'data-future';const future = new Future();
futrue.promise.catch( err => console.error( err ) ); // Error {}
// Can be called anytime after instantiating a Future object
future.reject( new Error() );
```