
Security News
Vite+ Joins the Push to Consolidate JavaScript Tooling
Evan You announces Vite+, a commercial, Rust-powered toolchain built on the Vite ecosystem to unify JavaScript development and fund open source.
JavaScript常用函数工具集
Node.js
npm install lao-utils --save
AMD/CMD、浏览器环境
引入dist目录下源码文件
21个常用函数
isIE(ver)
判断是否是IE浏览器
eg: laoUtils.isIE(8);//判断是否是IE8
laoUtils.isIE();//判断是否是IE
uuid()
生成一个uuid串(伪guid)is(x,y)
比较字符x和字符y是否相等
eg: 特殊例子:laoUtils.is(-0,+0); //false
,laoUtils.is(NaN,NaN); //true
isInteger(value)
是否为整数isNumber(value)
是否为数字isString(value)
是否为字符串isNaN(value)
是否为NaN
isDom(obj)
判断obj是否为Dom对象date(format,timestamp)
格式化日期
eg: laoUtils.date('yyyy-MM-dd'); //2016-02-26
copyObject(obj)
复制对象(浅拷贝,并且undefined属性不会被复制)clone(obj)
对一个object进行深度拷贝merge(a,b,c,...rest)
合并对象
eg: laoUtils.merge({a:1},{b:2},{b:3,c:3}); //{a:1,b:3,c:3}
arrayOf(a,b,c,...rest)
将一组值转换为数组(将参数转为数组)
eg: laoUtils.arrayOf(1,2,3); //[1,2,3]
includes(arr,value)
数组arr是否包含给定的值value.
eg: laoUtils.includes([1,2,3],3); //true
contains(str,value)
判断一个字符串是否被包含在另一个字符串中.
eg: laoUtils.contains('giscafer','g'); //true
isArray(arr)
判断arr是否为数组inherits(clazz, baseClazz)
构造类继承关系(clazz继承于baseClazz)extend(des, source)
源对象source
的所有属性复制到目标对象des
(undefined属性不会被复制)compact(array)
去除数组中假值元素,比如false
,null
,0
,""
,undefined
,和NaN
都是假值isExpect(value)
是否为非null,undefined和空字符以外的值isFloat(value)
value是否为浮点值MIT
FAQs
We found that lao-utils demonstrated a not healthy version release cadence and project activity because the last version was released a year ago. It has 1 open source maintainer collaborating on the project.
Did you know?
Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.
Security News
Evan You announces Vite+, a commercial, Rust-powered toolchain built on the Vite ecosystem to unify JavaScript development and fund open source.
Security News
Ruby Central’s incident report on the RubyGems.org access dispute sparks backlash from former maintainers and renewed debate over project governance.
Research
/Security News
Socket researchers uncover how threat actors weaponize Discord across the npm, PyPI, and RubyGems ecosystems to exfiltrate sensitive data.