1.0.1 • Published 8 years ago

jif v1.0.1

Weekly downloads
543
License
MIT
Repository
github
Last release
8 years ago

jif NPM version Downloads

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

// lets get started with some primitives...
jif(truthy, 123, 456) // 123
jif(falsey, 123, 456) // 456

// and now some functions!
jif(truthy, () => 123) // 123
jif(falsey, () => 123) // undefined

ES5

var jif = require('jif');

var truthy = true;
var falsey = false;

// lets get started with some primitives...
jif(truthy, 123, 456); // 123
jif(falsey, 123, 456); // 456

// and now some functions!
jif(truthy, function(){
  return 123;
}); // 123
jif(falsey, function(){
  return 123;
}); // undefined