apply finally function to a function, execute it after target return, event it error 在目标方法结束或出错后执行另一方法
get item from array by index. index can be negative number 通过索引获取数组一项. 支持负值索引.
get items from array between 2 indeies. index can be negative 从数组获得一个范围内的项. 范围可以为负.
diff1: in arr1 not in arr2. diff2: in arr2 not in arr1
Each item in the new array is unique. 新数组每项唯一.
simplified array.filter() e.g.: arrayFilter(arr, [null, undefined]) equal to arr.filter(v => v!== null && v!== undefined)
get first or array 返回数组首项
get one-dimensional array from multidimensional array 从多维数组获取一维数组
get last of array 返回数组末项
remove item from array. return removed count 从数组删除项. 返回删除计数
remove items from array by sorted indexes. indexes example: [0, 2, 6, 8, 9] 通过有序的索引集删除数组项. 索引集例子: [0, 2, 6, 8, 9]
alias of arrayFilter
return new array excluding n items from end 返回新数组排除末尾n项
Assign if value different. For assign sensitive, such as Vue.watch.
limit min and max of value. 限制值的最小和最大值.
binarySearch, 二分查找
return mid - your_value
for ascending array
wrap function, bind context(this).
Cache function return by arguments
'abc-abc-abc_abc' to 'AbcAbcAbcAbc'
'AbcAbcAbcAbc' to ['Abc', 'Abc', 'Abc', 'Abc']
return JSON.parse(JSON.stringify(obj))
warp continuous Promise method, such as mousemove handler
Copy to text to clipboard. Async not supported. Recommend clipboard-polyfill. 复制文字到剪贴板. 仅限于简单使用, 不支持异步. 复杂环境推荐clipboard-polyfill
return NodeList if there are multiple top-level nodes
like jquery $(el).css(), but only can read
example: dotGet(window, 'document.body.children.0')
example: dotSet(window, 'document.body.children.0', vaue)
detect if argumrnt is null, undefined, empty array, empty string, false, NaN, empty object 检查是否是null, undefined, 空数组, 空字符串, false, NaN, 空对象
execute promise in sequence
add executed count as first argument of func 增加执行次数作为方法的第一个参数
lisiten multi events, and can stop and resume them. start listening by default. start is alias for resume
like Array.find
like Array.find
return true when found.
like Array.find
return true when found.
get array item siblings. Example: getArrayItemSiblings(arr, item, [-1, 1]), get previous and next sibling 获得数组项的多个同级. 例: getArrayItemSiblings(arr, item, [-1, 1]), 获得前一个和后一个
relative to viewport. like position fixed. alias getViewportPosition 相对于视口. 类似 position fixed. 别名 getViewportPosition
startWeekDay: 0 is Sunday
[]
relative to page root element(document.documentElement). refer: https://gist.github.com/aderaaij/89547e34617b95ac29d1 相对于页面根元素.(document.documentElement)
there is some trap in el.offsetParent, so use this func to fix
get el current position. like jQuery.position. The position is relative to offsetParent viewport left top. it is for set absolute position, absolute position is relative to offsetParent viewport left top. 相对于offsetParent可视区域左上角(el.offsetLeft或top包含父元素的滚动距离, 所以要减去). position一般用于设置绝对定位的情况, 而绝对定位就是以可视区域左上角为原点.
like jQuery.offset(x, y), but it just return cmputed position, don't update style 类似 jQuery.offset的设置功能, 但是它只返回计算的position, 不改变元素样式.
get page root scroll(body or documentElement). refer: https://stackoverflow.com/questions/871399/cross-browser-method-for-detecting-the-scrolltop-of-the-browser-window
scrollLeft, scrollRight, scrollTop, scrollBottom. IMPORTANT! The min value of scrollRight and scrollBottom may be a float less than 1, not zero. 重要! scrollRight和scrollBottom的最小值可能是小于1的小数, 而不是0.
get global, such as window in browser.
返回顶级全局变量. 例如浏览器的window
group array by mark 计算每项的标识, 通过标识将数组项分组.
has any class in classNames
has all classNames
like indexOf, get all indexes
NOT RECOMMEND. Use Node.contains instead.
detect if global variable document
existing.
判断全局变量document
是否存在
timezone must be UTC. eg: 2018-09-07T03:38:37.888Z
[isOffsetInEl]
HTML Element
must pass arguments to next
manually
the returned function only accept one argument
example: pairRows(users, userProfiles, 'id', 'user_id')
To lower case and use -
as delimiter. example: '-ABC abc_def camelCase-- helloMyFriend' to 'a-b-c-abc-def-camel-case-hello-my-friend'
walk object and change key, value, delete key. return cloned new object. 深度遍历对象, 可以改变key, value, 删除key. 返回克隆的新对象.
return null: don't change anything return {delete: true}: delete return {key: newKey}: change key return {value: newValue}: change value return {skip: true}: skip children return {stop: true}: stop
to prevent circular reference.
[{id: 1}, {id: 2}] to {'1':{id: 1}, '2': {id: 2}}
If n greater than max
, return max
, else n.
如果n大于max, 返回max, 否则n.
If n less than min
, return min
, else n.
如果n小于min, 返回min, 否则n.
proxy a property to another key of this or another object
like Array.map
cancel event lisitener on element
listen event on element
on continuous input. return destroy 监听连续输入事件. 返回取消监听函数. 例如监听用户输入aa
listen event on element once. return destroy function
destroy
eg: 2018-09-07T03:38:37.888Z
rand item in array 返回数组随机一项
rand int in range, including min and max 返回指定范围随机整数, 包括范围起始值和终止值
generate random string 随机字符串
default 8
if it is function, return result, else return it directly.
reverse a string
To lower case and use _
as delimiter.
Split array every n. n can be getter, which argument is the times. 每n个拆分数组. n可以是方法, 参数是第几次分块
Pad a string to a certain length with another string 左边补充指定字符, 使其达到指定长度
'abc abc' to 'Abc abc'
'abcAbc' to 'Abc Abc'
try to delete obj[prop]
position fixed is not always related to viewport. position fixed不总是相对于视口. 参考/Check: https://developer.mozilla.org/en-US/docs/Web/CSS/position
walk tree data by with depth first search. tree data example: [{children: [{}, {}]}]
深度优先遍历树形数据. 树形数据示例: [{children: [{}, {}]}]
(getVal, handler) => update . when execute update, call getVal and check if changed. (getVal, handler) => update . 执行update时, 调用getVal并检查结果是否改变.
Generated using TypeDoc
Remove function's first parameter