promise-if

1.0.0 • Public • Published

promise-if

Build status NPM version js-xo-style

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

Package Sidebar

Install

npm i promise-if

Weekly Downloads

0

Version

1.0.0

License

MIT

Last publish

Collaborators

  • joakimbeng