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(){}); // trueThis method returns a boolean indicating whether this is function
Utils.isObject({"key":"value"}); //trueThis method returns a boolean indicating whether this is Object
Utils.isString("foo"); //trueThis method returns a boolean indicating whether this is String
Utils.isBoolean(true); //trueThis method returns a boolean indicating whether this is Boolean
Utils.isNumber(953); //trueThis method returns a boolean indicating whether this is Number
Utils.isEmptyString(""); // trueThis method returns a boolean indicating whether this string is Empty
Utils.isNotEmptyString("test"); //trueThis method returns a boolean indicating whether this sting is not empty or string
Utils.trim(" foo "); //fooThis method is Removes extra space from string beginning/ending
Utils.isArray([1,2,3]); //trueThis method returns a boolean indicating whether this is array
Utils.isEmptyArray([]); //trueThis method returns a boolean indicating whether this Array is empty
Utils.isError(new Error('Whoops!')); //trueThis method returns a boolean, Checks whether object is error
Utils.isEqual(1, 1); //trueThis method returns a boolean, Checks whether the 2 vaues is equal
Utils.isNotEqual(1, 2); //trueThis method returns a boolean, Checks whether 2 vaues is not equal or equal
Utils.isGreater(2, 1); //trueThis method returns a boolean, Checks whether 1st argument is greaterthan with 2nd one
Utils.isLess(1, 2); //trueThis method returns a boolean, Checks whether 1st argument is lessthan with 2nd one
Utils.isTrue(true); //trueThis method returns a boolean, Checks whether the valuse is true
Utils.isFalse(false); //trueThis method returns a boolean, Checks whether the valuse is false
Utils.isPercentage("95.3%"); //trueThis method returns a boolean, Checks whether a value is percentage
Utils.isNull(null); //trueThis method returns a boolean, Checks whether a value is null
var a = 1;
Utils.isDefined(a); //trueThis method returns a boolean, Checks whether a value is defined
Utils.isUndefined(a); //trueThis method returns a boolean, Checks whether a value is unDefined
Utils.getTimeStamp(); //1454433989971This method returns the timestamp according to local time
Utils.isValidDate("02/02/2016"); //trueThis 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 PMThis method returns the Time bases on date and formate(12/24 hrs)
Utils.getMonth(); // 2This method returns the month in the specified date according to local time
Utils.getMonthName(); // FebruaryThis method returns the month name in the specified date according to local time
Utils.getCurrentDate(); //2This method returns the current date in the specified date according to local time
Utils.getYear(); //2016This method returns the current year according to local time
Utils.getDay(); //TuesdayThis method returns the current day according to local time
Utils.isEmpty({}); //trueThis method checks whether is empty Array/Object
Utils.hasProperty({'foo':'test'},'foo'); //trueThis method returns a boolean indicating whether the object has the specified property
Utils.toCamelCase('foo_bar'); //fooBarThis 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"); //tsetThis 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!