lisp "cond" special form realization for js
npm install node-cond
npm install node-cond
`
Usage
`js
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
`js
cond.doif(Then, Else)(conditional)
``