UNPKG

node-cond

Version:

lisp "cond" special form realization for js

47 lines (40 loc) 781 B
# node-cond # Install ``` 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) ```