conditionally

1.0.0 • Public • Published

conditionally npm version npm downloads

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)

Dependencies (0)

    Dev Dependencies (1)

    Package Sidebar

    Install

    npm i conditionally

    Weekly Downloads

    1

    Version

    1.0.0

    License

    MIT

    Last publish

    Collaborators

    • zaclummys