promise-if
v1.0.0
Published
The if statement (or unary operator) for promises
Downloads
0
Maintainers
Readme
promise-if
The if statement (or unary operator) for promises
Installation
Install promise-if using npm:
npm install --save promise-ifUsage
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
