if

2.0.0 • Public • Published

if

Conditional branching for Javascript

Installation

npm install if

Usage

If the condition is truthy, the handler function passed to Then will be called.

If(condition).Then(handler);

A handler can be passed to the Else method, which will be called if the condition is not truthy.

If(condition).Then(handler)
  .Else(handler);

To evaluate more conditions, call If after Else.

If(condition).Then(handler)
  .Else().If(condition).Then(handler)
  .Else().If(condition).Then(handler);

Example

If(isRobot()).Then(function(){
    console.log('beep');
  }).Else().If(isHuman()).Then(function(){
    console.log('boop');
  }).Else(function(){
    console.log('?')
  });

Versions

Current Tags

  • Version
    Downloads (Last 7 Days)
    • Tag
  • 2.0.0
    1,262
    • latest

Version History

  • Version
    Downloads (Last 7 Days)
    • Published
  • 2.0.0
    1,262
  • 1.0.0
    0

Package Sidebar

Install

npm i if

Weekly Downloads

1,262

Version

2.0.0

License

MIT

Last publish

Collaborators

  • mappum