iffy

1.0.0 • Public • Published

iffy Build Status

Ternary in a function, but performant through closure science

Install

$ npm install --save iffy

Usage

var iffy = require('iffy')

iffy(true, onTrue, onFalse) // => onTrue called

iffy(false, onTrue, onFalse) // => onFalse called

API

iffy(condition, onTrue, [onFalse]) -> value

condition

Required Type: any

If condition is truthy, onTrue will be called and its return value returned.

Otherwise, if onFalse is provided, it will be called and its return value returned.

onTrue

Type: function

onFalse

Type: function

Related

These are similar, but are less performant due to lack of closure science.

License

MIT © Andrew Joslin

Package Sidebar

Install

npm i iffy

Weekly Downloads

1

Version

1.0.0

License

MIT

Last publish

Collaborators

  • andytjoslin