In my work, I often use some methods frequently, or do type judgment, data conversion, etc. For convenience, some functions are encapsulated into functions and organized into the tool set lao-utils
Use
Node.js
npm install lao-utils --save
AMD/CMD, browser environment
Introduce source code files in the dist directory
Function
uuid() generates a uuid string (pseudo-guid)
is(x,y) Compares whether character x and character y are equal
eg: Special example: laoUtils.is(-0,+0); //false,laoUtils.is(NaN,NaN); //true
isInteger(value) Is it an integer
isNumber(value) Is it a number
isString(value) Is it a string
isNaN(value) Is it NaN
isDom(obj) determines whether obj is a Dom object
date(format,timestamp) format date
eg: laoUtils.date('yyyy-MM-dd'); //2016-02-26
copyObject(obj) Copy the object (shallow copy, and undefined properties will not be copied)
clone(obj) performs a deep copy of an object
merge(a,b,c,...rest) Merge objects
eg: laoUtils.merge({a:1},{b:2},{b:3,c:3}); //{a:1,b:3,c:3}
arrayOf(a,b,c,...rest) Convert a set of values to an array (convert parameters to an array)
eg: laoUtils.arrayOf(1,2,3); //[1,2,3]
includes(arr,value) Whether the array arr contains the given value value.
eg: laoUtils.includes([1,2,3],3); //true
contains(str,value) Determines whether a string is contained in another string.
eg: laoUtils.contains('giscafer','g'); //true
isArray(arr) determines whether arr is an array
inherits(clazz, baseClazz) Construct class inheritance relationship (clazz inherits from baseClazz)
extend(des, source) Copies all properties of the source object source to the target object des (undefined properties will not be copied)
Source code
Download from this site http://xiazai.jb51.net/201603/yuanma/lao-utils-master(jb51.net).zip