Introducing Socket Firewall: Free, Proactive Protection for Your Software Supply Chain.Learn More
Socket
Book a DemoInstallSign in
Socket

lao-utils

Package Overview
Dependencies
Maintainers
1
Versions
8
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

lao-utils

常用工具集函数

latest
Source
npmnpm
Version
0.1.7
Version published
Maintainers
1
Created
Source

lao-utils

Build Status Coverage Status NPM version NPM download NPM license

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是否为浮点值

License

MIT

Keywords

utils

FAQs

Package last updated on 24 Oct 2016

Did you know?

Socket

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.

Install

Related posts