Skip to content

yocontra/jif

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

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

About

Dead simple ternary or if/else replacement

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages