@palxp/ijs-utils
TypeScript icon, indicating that this package has built-in type declarations

0.0.4 • Public • Published

Functions

`arrayEqual(arr1, arr2)`Boolean

判断两个数组是否相等

`fuzzyQuery(list, field, keyWord)`Array

对象数组模糊查询

`objArrayDelRepetitive(arr, 对象中相同的关键字(如id))`Array

对象数组去重

`throttle(delay, noTrailing, callback, debounceMode)`function

函数节流。 适用于限制resizescroll等函数的调用频率

`debounce(delay, atBegin, callback)`function

函数防抖 与throttle不同的是,debounce保证一个函数在多少毫秒内不再被触发,只会执行一次, 要么在第一次调用return的防抖函数时执行,要么在延迟指定毫秒后调用。

`deepClone(values)`Any

深拷贝,支持常见类型

`isEmptyObject(obj)`Boolean

判断obj是否为空

`randomColor(title, author)`String

随机生成颜色

`randomNum(min, max, title, author)`

生成指定范围[min, max]的随机数

arrayDelRepetitiveArray

数组去重

Kind: global Array - 数组类函数
Returns: Array - eg: arrayDelRepetitive([1,2],[2,5],[3,5,9]) // [1, 2, 5, 3, 9]

Param Type Description
arr1 Array 去重的对象
...arr2 Array 可以同时合并多个数组之后再去重

arrayEqual(arr1, arr2)Boolean

判断两个数组是否相等

Kind: global function

Param Type
arr1 Array
arr2 Array

fuzzyQuery(list, field, keyWord)Array

对象数组模糊查询

Kind: global function
Returns: Array - 查询的结果 eg: fuzzyQuery([{key:123},{key:62},{key:7}], 'key', 2) // [{key:123},{key:62}]

Param Type Description
list Array 原数组
field String 对应字段
keyWord String 查询的关键词

objArrayDelRepetitive(arr, 对象中相同的关键字(如id))Array

对象数组去重

Kind: global function

Param Type
arr Array
对象中相同的关键字(如id) String

throttle(delay, noTrailing, callback, debounceMode)function

函数节流。 适用于限制resizescroll等函数的调用频率

Kind: global function
Returns: function - 新的节流函数

Param Type Description
delay Number 0 或者更大的毫秒数。 对于事件回调,大约100或250毫秒(或更高)的延迟是最有用的。
noTrailing Boolean 可选,默认为false。 如果noTrailing为true,当节流函数被调用,每过delay毫秒callback也将执行一次。 如果noTrailing为false或者未传入,callback将在最后一次调用节流函数后再执行一次. (延迟delay毫秒之后,节流函数没有被调用,内部计数器会复位)
callback function 延迟毫秒后执行的函数。this上下文和所有参数都是按原样传递的, 执行去节流功能时,调用callback
debounceMode Boolean 如果debounceMode为true,cleardelayms后执行。 如果debounceMode是false,callbackdelay ms之后执行。

debounce(delay, atBegin, callback)function

函数防抖 与throttle不同的是,debounce保证一个函数在多少毫秒内不再被触发,只会执行一次, 要么在第一次调用return的防抖函数时执行,要么在延迟指定毫秒后调用。

Kind: global function
Returns: function - 新的防抖函数。

Param Type Description
delay Number 0或者更大的毫秒数。 对于事件回调,大约100或250毫秒(或更高)的延迟是最有用的。
atBegin Boolean 可选,默认为false。 如果atBegin为false或未传入,回调函数则在第一次调用return的防抖函数后延迟指定毫秒调用。 如果atBegin为true,回调函数则在第一次调用return的防抖函数时直接执行
callback function 延迟毫秒后执行的函数。this上下文和所有参数都是按原样传递的, 执行去抖动功能时,,调用callback

Example

适用场景:如在线编辑的自动存储防抖。

deepClone(values)Any

深拷贝,支持常见类型

Kind: global function

Param Type
values Any

isEmptyObject(obj)Boolean

判断obj是否为空

Kind: global function

Param Type
obj Object

randomColor(title, author)String

随机生成颜色

Kind: global function
Returns: String - color

Param Type Description
title string The title of the book.
author string The author of the book.

randomNum(min, max, title, author)

生成指定范围[min, max]的随机数

Kind: global function

Param Type Description
min Number
max Number
title string The title of the book.
author string The author of the book.

Dependencies (0)

    Dev Dependencies (1)

    Package Sidebar

    Install

    npm i @palxp/ijs-utils

    Weekly Downloads

    0

    Version

    0.0.4

    License

    MIT

    Unpacked Size

    38.9 kB

    Total Files

    18

    Last publish

    Collaborators

    • palxiao