conditionally
v1.0.0
Published
Handle conditions easily
Downloads
1
Maintainers
Readme
conditionally
Handle conditions easily
Installing
Using npm:
$ npm install conditionally
Using bower:
$ bower install conditionally
API
ternary
ternary callback
Boolean(notBool).ternary(truthyFn, falsyFn);
// or
bool.ternary(truthyFn, falsyFn);
truthy
callback if true
Boolean(notBool).truthy(truthyFn);
// or
bool.truthy(truthyFn);
falsy
callback if false
Boolean(notBool).falsy(falsyFn);
// or
bool.falsy(falsyFn);
Example
bool
const isJohn = name => 'john' == name; // bool
isJohn('john').truthy(function () {
console.log('Hi, John!');
});
notBool
const getCurrentUser = () => 'john'; // string (notBool)
Boolean(getCurrentUser()).truthy(function () {
console.log('User is logged in!');
});
License
MIT. Copyright (c) 2017 Isaac Ferreira (zaclummys)