2.6.11 • Published 11 months ago

x-js-tools v2.6.11

Weekly downloads
-
License
ISC
Repository
-
Last release
11 months ago

这是一个用于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[]将树状数据转为一维数组
isContentEquala: any, b: anyboolean比较基本类型、数组、纯对象数据的内容是否相等
anyArrSortarr: any[], order = 1, key: stringany[]对任何类型元素数组进行排序
isEffectiveValueanyboolean判断是否是有效值:value不为null、undefined、""、{}、[]
isBasicTypeanyboolean判断是否基本类型
isPureObjectanyboolean判断变量是不是纯对象
isArrayanyboolean判断是否数组
isNullanyboolean判断是否为null
isStringanyboolean判断是否字符串
getRandomNumberInClosedIntervalleft: number, right: numbernumber获取闭区间内的随机数
getFullArrangementstringstring[]获取全排列后的字符串数组
antiShakingfn: Function, delay: number, immediate: boolean = trueFuncton防抖函数
deepCloneval: anyany深拷贝
getCopiedTextelementId: stringvoid拷贝文本 ,系统剪贴板获取到了拷贝内容
getRandomColorstring获取随机颜色值(16进制字符串形式)
throttlefn: Function, delay: numberFunction节流函数
hLine2Humpstr: string, line: '_'或者'-'string将横线转为驼峰命名(横线可以是-或者_)
hump2HLinestr: string, line: stringstring将驼峰命名的字符串转为横线形式的字符串
isChinesePhoneFormatphone: stringboolean验证中国座机电话格式
isEmailemail: stringboolean验证邮箱格式
addClassdomSelector: string, className: stringvoid给元素添加类名
hasClassdomSelector: string, className: stringboolean判断元素是否有某个类
removeClassdomSelector: string, className: stringvoid去除类名
toggleClassdomSelector: string, className: stringvoid切换类名
getMousePositionevent: MouseEvent, type: 'client'/'offsetToParent'/'scrollToDoc'{ x: number, y: number }获取鼠标位置坐标
sleepmillisecond: numberPromise延迟毫秒

This is a JS tool function library for web development

Example of usage:

import { arrToTree } from x-js-tools
Function NameEnter parametersBack referenceFunction 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
isContentEquala: any, b: anybooleanCompare whether the contents of basic type, array and pure object data are equal
anyArrSortarr: any[], order = 1, key: stringany[]Sort an array of elements of any type
isEffectiveValueanybooleanJudge whether it is a valid value: value is not null, undefined, '', {}, []
isBasicTypeanybooleanJudge whether the basic type is
isPureObjectanybooleanJudge whether the variable is a pure object
isArrayanybooleanDetermine whether it is an array
isNullanybooleanJudge whether it is null
isStringanybooleanJudge whether string
getRandomNumberInClosedIntervalleft: number, right: numbernumberObtain random numbers within a closed interval
getFullArrangementstringstring[]Obtain a fully arranged string array
antiShakingfn: Function, delay: number, immediate: boolean = trueFunctonAnti shake function
deepCloneval: anyanydeep copy
getCopiedTextelementId: stringvoidCopy the text, the system clipboard obtained the copied content
getRandomColorstringObtain random color values (in hexadecimal string format)
throttlefn: Function, delay: numberFunctionThrottling function
hLine2Humpstr: string, line: '_' or '-'stringConvert the horizontal line to a hump name (the horizontal line can be either - or _)
hump2HLinestr: string, line: stringstringConvert the named string of the hump to a horizontal string
isChinesePhoneFormatphone: stringbooleanVerify Chinese landline phone format
isEmailemail: stringbooleanVerify email format
addClassdomSelector: string, className: stringvoidAdd a class name to an element
hasClassdomSelector: string, className: stringbooleanDetermine if an element has a certain class
removeClassdomSelector: string, className: stringvoidremove class
toggleClassdomSelector: string, className: stringvoidtoggle class
getMousePositionevent: MouseEvent, type: 'client'/'offsetToParent'/'scrollToDoc'{ x: number, y: number }Obtain mouse position coordinates
sleepmillisecond: numberPromiseDelay in milliseconds
2.5.6

11 months ago

2.5.5

11 months ago

2.5.8

11 months ago

1.5.1

11 months ago

2.5.9

11 months ago

1.4.1

11 months ago

1.3.1

11 months ago

1.3.0

11 months ago

2.5.2

11 months ago

2.5.1

11 months ago

2.5.4

11 months ago

2.5.3

11 months ago

2.6.11

11 months ago

2.5.11

11 months ago

1.2.2

2 years ago

1.2.1

2 years ago

1.2.0

2 years ago

1.1.3

2 years ago

1.1.2

2 years ago

1.1.1

2 years ago

1.0.1

2 years ago

1.0.0

2 years ago