fnif

1.0.0 • Public • Published

FNIF

Functional if

Simple functional if statement also known as branch

Examples

Simple

const $if = require("fnif")
 
const i = 10
 
$if(> 5, () =>
{
    console.log("It is greater than 5 !")
})

Complete

const $if = require("fnif")
 
const i = 10
 
$if(> 5, () =>
{
    console.log("It is greater than 5 !")
}, () =>
{
    console.error("Oh no ! it isn't greater than 5")
})

Actual use case

const $if = require("fnif")
 
const age = 16
 
const denomination = $if(age >= 18, () => "major", () => "minor")

Nesting

const $if = require("fnif")
 
const age = 16
 
const denomination = $if(age >= 18,
    () => "major",
    () => $if(age >= 16,
        () => "not too young",
        () => "minor"))

Please report any issues on Github ! Thanks

Package Sidebar

Install

npm i fnif

Weekly Downloads

0

Version

1.0.0

License

MIT

Last publish

Collaborators

  • scottishcyclops