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 🙏

© 2026 – Pkg Stats / Ryan Hefner

liands_tool

v1.0.3

Published

常用方法集合

Readme

public.js 公用方法

  • author: lian_Ds
  • create_time: 2022年5月19日13:47:20
  • last_update_time: 2022年7月4日15:14:10
  • version: v1.6.0

版本更新说明

版本 v1.6.0

  • 更新时间 2022年7月4日15:14:10

数组方法新增功能

  • 数组去重-数组对象 (removeRepetitionOfObj)
  • 通过指定下标,添加数组元素 (replaceElement)
  • 通过指定下标,删除对应元素 (delElement)

版本 v1.5.1

  • 更新时间 2022年6月9日15:13:59

更新引用方法

版本 v1.5.0

  • 更新时间 2022年6月7日16:59:16

增加 生成UUID

更新 整合的数组方法 ,增加 数组对象归类(groupBy,keyBy) 方法

版本 v1.0.0

  • 更新时间 2022年5月19日13:47:20

创建公共方法


  • 函数方法文档

特殊值判断

import { SpecialValue } from 'liands_tool'
const fn = new SpecialValue()
  ...

用途 | 方法 | 参数 | 默认值 | 返回类型 | 使用示例 :-: | :-: | :-: | :-: | :-: | :-- 结果函数 | getRes() | value [String,Number] , extraValue [Array{String,Number}] | - | Boolean | new SpecialValue('--',[0,'--']).getRes()

事件防抖

import { Debounce } from 'liands_tool'
const fn = new Debounce()
  ...

用途 | 方法 | 参数 | 默认值 | 返回类型 | 使用示例 :-: | :-: | :-: | :-: | :-: | :-- 设置防抖方法 | setDebounce() | callBack[function] ,wait[Number] | - | - | new Debounce(()=>{ console.log('5s 内不会重复执行')},5000).setDebounce()

随机十六进制的颜色

import { RandomColor } from 'liands_tool'
const fn = new RandomColor()
  ...

用途 | 方法 | 参数 | 默认值 | 返回类型 | 使用示例 :-: | :-: | :-: | :-: | :-: | :-: 获取随机颜色 | getColor() | - | - | - |fn.getColor()

整合的数组方法

import { ArrayMethods } from 'liands_tool'
const fn = new ArrayMethods()
  ...

用途 | 方法 | 参数 | 默认值 | 返回类型 | 使用示例 :-: | :-: | :-: | :-: | :-: | :-- 数组去重-常规 | removeRepetition() | arr[Array] | - | Array | fn.removeRepetition([0,0,1,2,3,5,6,6,0,7]) 数组去重-数组对象 | removeRepetitionOfObj() | arr[Array{Object}] | - | Array | fn.new ArrayMethods().removeRepetitionOfObj([{ id:123, name:'123' },{ id:123, name:'123' },{ id:456, name:'456' }],'id') 是否是空数组 | isNotEmpty() | arr[Array] | -| Boolean | fn.isNotEmpty([]) 简单排序(默认正序) | defSort() | arr[Array] | - | Array | fn.defSort([3,2,5,0,1,6,7]) 数组对象排序(默认正序) | allSort() | arr[Array{Object}] ,keyword[String] | - | Array{Object} | fn.allSort([{ key:1, name:'第一个' },{ key:2, name:'第二个' },{ key:5, name:'第五个' }, { key:3, name:'第三个' },{ key:4, name:'第四个' }],'key') 数组字符串排序(排序顺序按第二个参数) | strSort() | arr[Array] ,strArr[Array] | - | Array{String} | fn.strSort(['this is demo2','sdas','this is demo3','this is demo1',"test"],['demo1','demo2',"demo3"]) 数组对象归类,符合条件的元素放在同个对象里 | groupBy() | arr[Array],fn[Function] | - | Object | fn.groupBy([{ name: '张三', score: 60 },null,{ name: '李四', score: 40 },undefined,{ name: '王二', score: 80 },{ name: '王二', score: 90 }],function(n){return n.name}) 数组对象归类,把指定的key,相同值的作为一类 | keyBy() | arr[Array],key[String] | - | Object | fn.keyBy([{ name: '张三', score: 60 },null,{ name: '李四', score: 40 },undefined,{ name: '王二', score: 80 },{ name: '王二', score: 90 }],'name') 通过指定下标,添加数组元素 | replaceElement | data[Array],index[Number],el[Any] | - | Array | new ArrayMethods().replaceElement([1,2,3,4],2,'55') 通过指定下标,删除对应元素 | delElement | data[Array],index[Number] | - | Array | new ArrayMethods().delElement([1,2,3,4],2)

整合的字符串方法

import { StringMethods } from 'liands_tool'
const fn = new StringMethods()
  ...

用途 | 方法 | 参数 | 默认值 | 返回类型 | 使用示例 :-: | :-: | :-: | :-: | :-: | :-- 获取对应的下标 | getIndex() | data[String] ,target[String] | - | Number | fn.getIndex('this is demo','is') 判断是否存在 | isExist() | data[String] ,target[String,RegExp] | - | Object | fn.isExist('this is demo','is') 字符串替换 | strReplace() | data[String] ,el[String,RegExp] ,targer[String] | - | String | fn.strReplace('this is demo','demo','test') 截取 | cutStr() | data[String] ,startStr[String] ,endStr[String] | - | String | fn.cutStr('this is demo set Function of cutStr methods','this','of') 用下标截取字符串 | cutStrOfIndex() | data[Array] ,startIndex[Number] ,endIndex[Number] | - | String | fn.cutStrOfIndex('this is demo',0,3) 将字符串转化为数组 | toArray() | data[String] ,val[String] | - | String | fn.toArray('this is demo',' ')

整合常用的数字方法

import { MathMethods } from 'liands_tool'
const fn = new MathMethods()
  ...

用途 | 方法 | 参数 | 默认值 | 返回类型 | 使用示例 :-: | :-: | :-: | :-: | :-: | :-- 根据属性,获取数组对象中的值 | valOfArray() | data[Array{Object}] ,keyword[String] | - | Array | fn.valOfArray([{num:10,name:'第一个'},null,{num:4,name:'第二个'},undefined],'num') 随机n位数 | getNum() | num[Number] ,type[Boolean] | - | Number| fn.getNum(5,true) 从数组对象中取最大值 | getMax() | data[Array{Object}] ,keyword[String] | - | Number | fn.getMax([{num:10,name:'第一个'},null,{num:4,name:'第二个'},undefined],'num') 从数组对象中取最小值 | getMin() | data[Array{Object}] ,keyword[String] | - | Number | fn.getMin([{num:10,name:'第一个'},null,{num:4,name:'第二个'},undefined],'num') 小数和整数的处理 | setNumFormat() | data[Number] / type[String] ,index[Number] | - | Number | fn.setNumFormat(2000.5561,'round')

生成UUID

import { createID } from 'liands_tool'
const fn = new createID()
  ...

用途 | 方法 | 参数 | 默认值 | 返回类型 | 使用示例 :-: | :-: | :-: | :-: | :-: | :-: 自动生成UUID | getUUID() | - | - | string | fn.getUUID()