1.0.0 • Published 9 years ago
promise-if v1.0.0
promise-if
The if statement (or unary operator) for promises
Installation
Install promise-if
using npm:
npm install --save promise-if
Usage
Module usage
var if = require('promise-if');
if(Promise.resolve(false), Promise.resolve('hey'), Promise.resolve('ho'))
.then(function (val) {
// val === 'ho'
});
API
if(condition, trueVal, falsecondition)
Name | Type | Description |
---|---|---|
condition | Mixed | Condition |
trueVal | Mixed | What to return if condition resolves to a "truthy" value |
falseVal | Mixed | What to return if condition resolves to a "falsy" value |
Returns: Promise
, which resolves to what either trueVal
or falseVal
resolves to depending on condition
Related
License
MIT © Joakim Carlstein
1.0.0
9 years ago