0.0.1 • Published 9 years ago
node-cond v0.0.1
node-cond
Install
npm install node-condUsage
var cond = require("node-cond");
/*
cond(
condition1, Then1,
condition2, Then2,
...
conditionN, ThenN,
[defaultThen]
)
*/
// ternary operator emulation
var test = cond(
true, "t", "f"
);
// now test equal "t"
// usind function
var test = cond(
true, () => "t", "f"
);
// test still equal "t"
// if Then is function it will be called with condition as arg
var test = cond(
false, "no",
null, "no",
() => "this is default value. it will be returned"
)cond.all
cond.all exec all Then after truthy conditionals and return the last. If default Then is defined it will be returned
cond.doif
cond.doif(Then, Else)(conditional)0.0.1
9 years ago