dbj.cond

Better conditional statement

(c) 2009-2013 .. and beyond, by dbj

Project :: dbj.cond

Licensed under the MIT (MIT-LICENSE.txt)

npm install dbj.cond

       var dbj = require("dbj.cond").dbj ;
               dbj.cond(1,1,"1","!") //=> "1" 

               // include dbj.cond.js 
               dbj.cond(1,1,"1","!"); //=> "1" 

Standard comparison is one of strict equality.

To change the standard strict equality comparator:

       dbj.cond.comparator = function myComparator (a,b ) { return a != b ; };

Two powerfull non-standard comparators are provided, "deep" and "multi". Usage:

      dbj.cond.comparator = dbj.compare.deep;
          dbj.cond({ "Alpha": 1 }, 
                   { "Beta": 2 }, false, 
                   { "Alpha": 1 }, "Works!", 
                   false ); //=> "Works!" 
 
          dbj.cond.comparator = dbj.compare.multi;
          // compare arrays 
          dbj.cond([1,2], [3,2], false, [1,2], "Works!", false ); //=> "Works!" 
          // lookup into the array 
          dbj.cond([1,2], [3,2], false, ['2d', [1,2]], "Works!", false ); //=> "Works!" 
          // lookup from the array 
          dbj.cond(['2d', [1,2]], [3,2], false, [1,2], "Works!", false ); //=> "Works!" 

It is to be the reference source and knowledge base, but right now Wiki is work-in-progress, mainly to sync it with a code after numerous changes and re-thinking sessions. After this note is removed, Wiki will be released as the reference text on dbj.cond()