jif
1.0.1 • Public • Published jif
Information
- Dead simple ternary or if/else replacement.
- All arguments (conditions, ifTrue, and ifFalse) can be either a value or a function which returns a value.
- Super useful for cleaning up JSX, which doesn't allow use of if/else.
Install
npm install jif --save
jif(condition[, ifTrue, ifFalse])
ES6
import jif from 'jif'
const truthy = true
const falsey = false
jif(truthy, 123, 456)
jif(falsey, 123, 456)
jif(truthy, () => 123)
jif(falsey, () => 123)
ES5
var jif = require('jif');
var truthy = true;
var falsey = false;
jif(truthy, 123, 456);
jif(falsey, 123, 456);
jif(truthy, function(){
return 123;
});
jif(falsey, function(){
return 123;
});
Package Sidebar
Install
Weekly Downloads