Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/algolia/eventual-values
https://github.com/algolia/eventual-values
Last synced: 13 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/algolia/eventual-values
- Owner: algolia
- License: mit
- Archived: true
- Created: 2016-07-07T15:25:45.000Z (over 8 years ago)
- Default Branch: master
- Last Pushed: 2018-07-16T08:41:52.000Z (over 6 years ago)
- Last Synced: 2024-10-14T03:08:49.130Z (about 1 month ago)
- Language: JavaScript
- Size: 26.4 KB
- Stars: 9
- Watchers: 71
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- Changelog: CHANGELOG.md
- License: LICENSE
Awesome Lists containing this project
README
# eventual-values
`eventual-values` is a tiny JS library that lets you to create values that are themselved pending, errored, or resolved. It is inspired by the [eventual](https://github.com/Gozala/eventual) library.
## Installation
`eventual-values` is available on npm:
```bash
npm install eventual-values
```## Usage
```js
var eventual = require('eventual-values');// Create an eventual value
var val = eventual();// Check its status
eventual.isReady(val); // => false
eventual.isError(val); // => false
eventual.isPending(val); // => true// reject the value
val = eventual.reject('Access denied');
eventual.isReady(val); // => false
eventual.isError(val); // => true
eventual.isPending(val); // => false// Any error is an errored value
eventual.isError(new Error('Access denied')); // => true// Any other value is a resolved value
eventual.isReady('OK'); // => true
eventual.isError('OK'); // => false
eventual.isPending('OK'); // => false
```### With ES2015
```js
import eventual, {isReady} from 'eventual-values';
```