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

x-js-tools

v2.6.11

Published

This is a JS tool function library for web development

Downloads

11

Readme

这是一个用于web开发的js工具函数库

使用方法示例:

 npm i x-js-tools
 import { arrToTree } from x-js-tools

| 函数名称 | 入参 | 回参 | 功能描述 | | ---- | ---- | ---- | ---- | | arrToTree | { pid: string | number; id: string | number; [k: string]: any }[] | object[] | 将一维数组转化为树状数据 | | treeToArr | { [k: string]: any; children: &[] | undefined; } | any[] | 将树状数据转为一维数组 | | isContentEqual | a: any, b: any | boolean | 比较基本类型、数组、纯对象数据的内容是否相等 | | anyArrSort | arr: any[], order = 1, key: string | any[] | 对任何类型元素数组进行排序 | | isEffectiveValue | any | boolean | 判断是否是有效值:value不为null、undefined、""、{}、[] | | isBasicType | any | boolean | 判断是否基本类型 | | isPureObject | any | boolean | 判断变量是不是纯对象 | | isArray | any | boolean | 判断是否数组 | | isNull | any | boolean | 判断是否为null | | isString | any | boolean | 判断是否字符串 | | getRandomNumberInClosedInterval | left: number, right: number | number | 获取闭区间内的随机数 | | getFullArrangement | string | string[] | 获取全排列后的字符串数组 | | antiShaking | fn: Function, delay: number, immediate: boolean = true | Functon | 防抖函数 | | deepClone | val: any | any | 深拷贝 | | getCopiedText | elementId: string | void | 拷贝文本 ,系统剪贴板获取到了拷贝内容 | | getRandomColor | 无 | string | 获取随机颜色值(16进制字符串形式)| | throttle | fn: Function, delay: number | Function | 节流函数 | | hLine2Hump | str: string, line: ''或者'-' | string | 将横线转为驼峰命名(横线可以是-或者) | | hump2HLine | str: string, line: string | string | 将驼峰命名的字符串转为横线形式的字符串 | | isChinesePhoneFormat | phone: string | boolean | 验证中国座机电话格式 | | isEmail | email: string | boolean | 验证邮箱格式 | | addClass | domSelector: string, className: string | void | 给元素添加类名 | | hasClass | domSelector: string, className: string | boolean | 判断元素是否有某个类 | | removeClass | domSelector: string, className: string | void | 去除类名 | | toggleClass | domSelector: string, className: string | void | 切换类名 | | getMousePosition | event: MouseEvent, type: 'client'/'offsetToParent'/'scrollToDoc' | { x: number, y: number } | 获取鼠标位置坐标 | | sleep | millisecond: number | Promise | 延迟毫秒 |


This is a JS tool function library for web development

Example of usage:

import { arrToTree } from x-js-tools

| Function Name | Enter parameters | Back reference | Function description | | ---- | ---- | ---- | ---- | | arrToTree | { pid: string | number; id: string | number; [k: string]: any }[] | object[] | Convert one-dimensional array to tree data | | treeToArr | { [k: string]: any; children: &[] | undefined; } | any[] | Convert tree data into one-dimensional array | | isContentEqual | a: any, b: any | boolean | Compare whether the contents of basic type, array and pure object data are equal | | anyArrSort | arr: any[], order = 1, key: string | any[] | Sort an array of elements of any type | | isEffectiveValue | any | boolean | Judge whether it is a valid value: value is not null, undefined, '', {}, [] | | isBasicType | any | boolean | Judge whether the basic type is | | isPureObject | any | boolean | Judge whether the variable is a pure object | | isArray | any | boolean | Determine whether it is an array | | isNull | any | boolean | Judge whether it is null | | isString | any | boolean | Judge whether string | | getRandomNumberInClosedInterval | left: number, right: number | number | Obtain random numbers within a closed interval | | getFullArrangement | string | string[] | Obtain a fully arranged string array | | antiShaking | fn: Function, delay: number, immediate: boolean = true | Functon | Anti shake function | | deepClone | val: any | any | deep copy | | getCopiedText | elementId: string | void | Copy the text, the system clipboard obtained the copied content | | getRandomColor | 无 | string | Obtain random color values (in hexadecimal string format) | | throttle | fn: Function, delay: number | Function | Throttling function | | hLine2Hump | str: string, line: '_' or '-' | string | Convert the horizontal line to a hump name (the horizontal line can be either - or _) | | hump2HLine | str: string, line: string | string | Convert the named string of the hump to a horizontal string | | isChinesePhoneFormat | phone: string | boolean | Verify Chinese landline phone format | | isEmail | email: string | boolean | Verify email format | | addClass | domSelector: string, className: string | void | Add a class name to an element | | hasClass | domSelector: string, className: string | boolean | Determine if an element has a certain class | | removeClass | domSelector: string, className: string | void | remove class | | toggleClass | domSelector: string, className: string | void | toggle class | | getMousePosition | event: MouseEvent, type: 'client'/'offsetToParent'/'scrollToDoc' | { x: number, y: number } | Obtain mouse position coordinates | | sleep | millisecond: number | Promise | Delay in milliseconds |