Skip to content
This repository has been archived by the owner on Jun 5, 2019. It is now read-only.

algolia/eventual-values

master
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Code

Latest commit

 

Git stats

Files

Permalink
Failed to load latest commit information.
Type
Name
Latest commit message
Commit time
 
 
src
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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 library.

Installation

eventual-values is available on npm:

npm install eventual-values

Usage

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

import eventual, {isReady} from 'eventual-values';

About

No description, website, or topics provided.

Resources

License

Code of conduct

Stars

Watchers

Forks

Packages

No packages published