npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

lao-utils

v0.1.7

Published

常用工具集函数

Downloads

2

Readme

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