Utils is a lightweight pure Javascript library, it helps for handling most generic validation
v1.0.1
You need Gulp installed globally:
$ npm i -g gulp
$ git clone https://github.com/ksankumar/utils
<script type="text/javascript" src="src/Utils.js"></script>
Utils.isFunction(function(){}); // true
This method returns a boolean indicating whether this is function
Utils.isObject({"key":"value"}); //true
This method returns a boolean indicating whether this is Object
Utils.isString("foo"); //true
This method returns a boolean indicating whether this is String
Utils.isBoolean(true); //true
This method returns a boolean indicating whether this is Boolean
Utils.isNumber(953); //true
This method returns a boolean indicating whether this is Number
Utils.isEmptyString(""); // true
This method returns a boolean indicating whether this string is Empty
Utils.isNotEmptyString("test"); //true
This method returns a boolean indicating whether this sting is not empty or string
Utils.trim(" foo "); //foo
This method is Removes extra space from string beginning/ending
Utils.isArray([1,2,3]); //true
This method returns a boolean indicating whether this is array
Utils.isEmptyArray([]); //true
This method returns a boolean indicating whether this Array is empty
Utils.isError(new Error('Whoops!')); //true
This method returns a boolean, Checks whether object is error
Utils.isEqual(1, 1); //true
This method returns a boolean, Checks whether the 2 vaues is equal
Utils.isNotEqual(1, 2); //true
This method returns a boolean, Checks whether 2 vaues is not equal or equal
Utils.isGreater(2, 1); //true
This method returns a boolean, Checks whether 1st argument is greaterthan with 2nd one
Utils.isLess(1, 2); //true
This method returns a boolean, Checks whether 1st argument is lessthan with 2nd one
Utils.isTrue(true); //true
This method returns a boolean, Checks whether the valuse is true
Utils.isFalse(false); //true
This method returns a boolean, Checks whether the valuse is false
Utils.isPercentage("95.3%"); //true
This method returns a boolean, Checks whether a value is percentage
Utils.isNull(null); //true
This method returns a boolean, Checks whether a value is null
var a = 1;
Utils.isDefined(a); //true
This method returns a boolean, Checks whether a value is defined
Utils.isUndefined(a); //true
This method returns a boolean, Checks whether a value is unDefined
Utils.getTimeStamp(); //1454433989971
This method returns the timestamp according to local time
Utils.isValidDate("02/02/2016"); //true
This method returns the Boolean if date is valid or invalid
Utils.getDate(); //Tue Feb 02 2016 12:25:58 GMT-0500 (EST)
This method returns the current date with time according to local time
Utils.getTime(12); //9:53 PM
This method returns the Time bases on date and formate(12/24 hrs)
Utils.getMonth(); // 2
This method returns the month in the specified date according to local time
Utils.getMonthName(); // February
This method returns the month name in the specified date according to local time
Utils.getCurrentDate(); //2
This method returns the current date in the specified date according to local time
Utils.getYear(); //2016
This method returns the current year according to local time
Utils.getDay(); //Tuesday
This method returns the current day according to local time
Utils.isEmpty({}); //true
This method checks whether is empty Array/Object
Utils.hasProperty({'foo':'test'},'foo'); //true
This method returns a boolean indicating whether the object has the specified property
Utils.toCamelCase('foo_bar'); //fooBar
This method is convert a camelCase string
Utils.stringify([{'foo':'bar'}]); //[{"foo":"bar"}]
This method converts a JavaScript value to a JSON string
Utils.reverse("test"); //tset
This method reverse a string
Utils.search([{'a':'foo','b':'bar'},{'a':'gama','b':'beta'}], 'gama');//{a: "gama", b: "beta"}
This method returns a filtered object which is matched string
Utils.sort([{'a':'foo','b':'bar'},{'a':'gama','b':'beta'}], 'a', false); //[{'a':'gama','b':'beta'},{'a':'foo','b':'bar'}]
This method returns sort object which is based on key and order(Asc/Des)
Utils.unique([1,2,3,1,4,2,5]); //[3, 1, 4, 2, 5]
This method removes a dublicate element in array
And of course ksankumar itself is open source with a [public repository][ksankumar] on GitHub.
MIT
Free Software, Santhosh Kumar Krishnan!