A general purpose JavaScript library.
"This is pretty {0}".format("cool");
var user = "John Doe";
user.log();
user.log("Current User");
=> John Doe
=> Current User: John Doe
"123".toInt();
"123a".toInt(3);
"test".reverse();
Output:
tset
var test = true;
test.flip();
Helpful when making a toggle function:
<button ng-click="displayStuff.flip()"></button>
var active = true;
active.log();
active.log("Active");
=> true
=> Active : true
The last function will return the last item in the array.
var arr = [ 'one', 'two', 'three' ];
arr.last();
=> 'three'
var arr = [ 'one', 'two', 'three' ];
arr.log();
arr.log("Message");
=> [ 'one', 'two', 'three' ]
=> Message: [ 'one', 'two', 'three' ]
This function will return the passed object as an array. Useful when objects or arrays can be supplied.
var a = 1;
var b = [1,2,3];
Array.asArray(a);
Array.asArray(b);
=> [1];
=> [1,2,3];
This function will test if an object has a property and return it. It can also take in compound properties (i.e. find property recursively). Will return fallBack value if no matches are made and false if no matches and no fallBack.
var obj = {'a': { 'b' : { 123 } }, 'b' : 2, 'c' : 3};
obj.getValue("c");
=> 3;
obj.getValue("d",4);
=> 4;
obj.getValue("a.b");
=> 123;