0.0.4 • Published 7 months ago

@palxp/ijs-utils v0.0.4

Weekly downloads
-
License
MIT
Repository
-
Last release
7 months ago

Functions

arrayDelRepetitiveArray

数组去重

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

ParamTypeDescription
arr1Array去重的对象
...arr2Array可以同时合并多个数组之后再去重

arrayEqual(arr1, arr2)Boolean

判断两个数组是否相等

Kind: global function

ParamType
arr1Array
arr2Array

fuzzyQuery(list, field, keyWord)Array

对象数组模糊查询

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

ParamTypeDescription
listArray原数组
fieldString对应字段
keyWordString查询的关键词

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

对象数组去重

Kind: global function

ParamType
arrArray
对象中相同的关键字(如id)String

throttle(delay, noTrailing, callback, debounceMode)function

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

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

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

debounce(delay, atBegin, callback)function

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

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

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

Example

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

deepClone(values)Any

深拷贝,支持常见类型

Kind: global function

ParamType
valuesAny

isEmptyObject(obj)Boolean

判断obj是否为空

Kind: global function

ParamType
objObject

randomColor(title, author)String

随机生成颜色

Kind: global function
Returns: String - color

ParamTypeDescription
titlestringThe title of the book.
authorstringThe author of the book.

randomNum(min, max, title, author)

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

Kind: global function

ParamTypeDescription
minNumber
maxNumber
titlestringThe title of the book.
authorstringThe author of the book.
0.0.4

7 months ago