ut2 1.7.1 → 1.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (82) hide show
  1. package/README.md +133 -133
  2. package/dist/ut2.js +51 -55
  3. package/dist/ut2.js.map +1 -1
  4. package/dist/ut2.min.js +1 -1
  5. package/dist/ut2.min.js.map +1 -1
  6. package/es/clamp.js +4 -3
  7. package/es/conformsTo.js +4 -3
  8. package/es/countBy.js +4 -3
  9. package/es/defaultTo.js +4 -3
  10. package/es/every.js +4 -3
  11. package/es/filter.js +4 -3
  12. package/es/find.js +4 -3
  13. package/es/fromPairs.js +4 -3
  14. package/es/groupBy.js +4 -3
  15. package/es/internals/baseDebounce.js +2 -8
  16. package/es/internals/createForEach.js +2 -2
  17. package/es/internals/createReduce.js +2 -2
  18. package/es/internals/helpers.js +1 -1
  19. package/es/keyBy.js +4 -3
  20. package/es/map.js +4 -3
  21. package/es/orderBy.js +4 -3
  22. package/es/partial.js +16 -11
  23. package/es/partition.js +4 -3
  24. package/es/range.js +4 -3
  25. package/es/some.js +4 -3
  26. package/es/times.js +4 -3
  27. package/lib/clamp.js +4 -3
  28. package/lib/conformsTo.js +4 -3
  29. package/lib/countBy.js +4 -3
  30. package/lib/defaultTo.js +4 -3
  31. package/lib/every.js +4 -3
  32. package/lib/filter.js +4 -3
  33. package/lib/find.js +4 -3
  34. package/lib/fromPairs.js +4 -3
  35. package/lib/groupBy.js +4 -3
  36. package/lib/index.js +4 -4
  37. package/lib/internals/baseDebounce.js +2 -8
  38. package/lib/internals/createForEach.js +2 -2
  39. package/lib/internals/createReduce.js +2 -2
  40. package/lib/internals/helpers.js +1 -1
  41. package/lib/keyBy.js +4 -3
  42. package/lib/map.js +4 -3
  43. package/lib/orderBy.js +4 -3
  44. package/lib/partial.js +16 -11
  45. package/lib/partition.js +4 -3
  46. package/lib/range.js +4 -3
  47. package/lib/some.js +4 -3
  48. package/lib/times.js +4 -3
  49. package/package.json +26 -24
  50. package/types/after.d.ts +2 -1
  51. package/types/before.d.ts +2 -1
  52. package/types/clamp.d.ts +29 -2
  53. package/types/conformsTo.d.ts +23 -2
  54. package/types/countBy.d.ts +28 -2
  55. package/types/debounce.d.ts +2 -1
  56. package/types/defaultTo.d.ts +6 -3
  57. package/types/delay.d.ts +2 -1
  58. package/types/every.d.ts +28 -4
  59. package/types/filter.d.ts +26 -4
  60. package/types/find.d.ts +26 -4
  61. package/types/forEach.d.ts +1 -6
  62. package/types/forEachRight.d.ts +1 -6
  63. package/types/fromPairs.d.ts +20 -2
  64. package/types/groupBy.d.ts +28 -2
  65. package/types/internals/baseDebounce.d.ts +2 -1
  66. package/types/internals/createForEach.d.ts +7 -6
  67. package/types/internals/createReduce.d.ts +11 -10
  68. package/types/internals/types.d.ts +1 -0
  69. package/types/isFunction.d.ts +2 -1
  70. package/types/keyBy.d.ts +28 -2
  71. package/types/map.d.ts +28 -4
  72. package/types/negate.d.ts +2 -1
  73. package/types/once.d.ts +2 -1
  74. package/types/orderBy.d.ts +43 -2
  75. package/types/partial.d.ts +63 -11
  76. package/types/partition.d.ts +38 -2
  77. package/types/range.d.ts +28 -3
  78. package/types/reduce.d.ts +1 -10
  79. package/types/reduceRight.d.ts +1 -10
  80. package/types/some.d.ts +26 -4
  81. package/types/throttle.d.ts +2 -1
  82. package/types/times.d.ts +25 -2
package/README.md CHANGED
@@ -60,139 +60,139 @@ const debounced = debounce(() => {
60
60
  >
61
61
  > `import { throttle, chunk, max } from 'ut2'`
62
62
 
63
- - Array 数组
64
- - chunk - 拆分成多个 `size` 长度的区块。
65
- - compact - 剔除假值元素。
66
- - difference - 排除部分值。
67
- - formPairs - 将键值对转为对象。
68
- - intersection - 交集去重。
69
- - nth - 获取第 `n` 个元素。
70
- - shuffle - 打乱数组。
71
- - union - 并集去重。
72
- - uniq - 数组去重。
73
- - unzip - 数组分组。
74
- - xor - 先并集再排除交集部分。
75
- - zip - 数组参数分组。
76
- - Collection 集合
77
- - countBy - 统计数量。
78
- - every - 检查集合元素都为真值。
79
- - find - 查找集合元素。
80
- - filter - 过滤集合元素。
81
- - forEach - 迭代集合元素。
82
- - forEachRight - 迭代集合元素(从右往左的顺序)。
83
- - groupBy - 对象分组。
84
- - keyBy - 转为对象。
85
- - map - 迭代集合元素生成新数组。
86
- - orderBy - 排序。
87
- - partition - 拆分真值和假值。
88
- - reduce - 累计值(从右往左的顺序)。
89
- - reduceRight - 累计值。
90
- - some - 检查集合元素包含真值。
91
- - Function 函数
92
- - after - 调用 `n` 或更多次之后触发。
93
- - before - 调用次数少于 `n` 次之前触发。
94
- - debounce - 防抖函数。
95
- - delay - 延迟触发。
96
- - negate - 否定断言。
97
- - once - 只执行一次。
98
- - partial - 预设部分参数。
99
- - throttle - 节流函数。
100
- - Language 语言
101
- - isArguments - `arguments` 对象。
102
- - isArray - `Array` 对象。
103
- - isArrayBuffer - `ArrayBuffer` 对象。
104
- - isArrayLike - 类数组。
105
- - isArrayLikeObject - 类数组对象。
106
- - isBlob - `Blob` 对象。
107
- - isBoolean - 布尔类型或对象。
108
- - isBuffer - `Buffer` 对象。
109
- - isDataView - `DataView` 对象。
110
- - isDate - `Date` 对象。
111
- - isElement - `Dom` 元素。
112
- - isEqual - 深比较。
113
- - isEmpty - 空对象、数组、`Map`、`Set`。
114
- - isError - `Error` 对象。
115
- - isFinite - 有限数字。
116
- - isFunction - `Function` 对象。
117
- - isInteger - 整数。
118
- - isLength - 有效的类数组长度。
119
- - isMap - `Map` 对象。
120
- - isMatch - 普通对象部分匹配的深比较。
121
- - isNaN - `NaN` 。
122
- - isNil - `undefined` 或 `null` 。
123
- - isNull - `null` 。
124
- - isNumber - 数字类型或对象。
125
- - isObject - 对象。
126
- - isObjectLike - 类对象。
127
- - isPlainObject - 普通对象。
128
- - isPromiseLike - 类 `Promise` 对象。
129
- - isRegExp - `RegExp` 对象。
130
- - isSafeInteger - 安全整数。
131
- - isSet - `Set` 对象。
132
- - isString - 字符串类型或对象。
133
- - isSymbol - `Symbol` 类型或对象。
134
- - isTypedArray - 类型化数组。
135
- - isUndefined - `undefined` 。
136
- - isWeakMap - `WeakMap` 对象。
137
- - isWeakSet - `WeakSet` 对象。
138
- - Math 数学
139
- - ceil - 向上舍入。
140
- - floor - 向下舍入。
141
- - max - 取最大值。
142
- - min - 取最小值。
143
- - round - 四舍五入。
144
- - Number 数字
145
- - clamp - 限制数字范围。
146
- - inRange - 是否在范围内。
147
- - random - 随机小数。
148
- - randomInt - 随机整数。
149
- - Object 对象
150
- - allKeys - 对象自身的可枚举属性(包含 `Symbol` 属性)。
151
- - allKeysIn - 对象自身及继承的可枚举属性(包含 `Symbol` 属性)。
152
- - keys - 对象自身的可枚举属性(不包含 `Symbol` 属性)。
153
- - keysIn - 对象自身及继承的可枚举属性(不包含 `Symbol` 属性)。
154
- - merge - 递归对象或数组进行合并。
155
- - omit - 排除部分属性。
156
- - omitBy - 根据方法,排除部分属性。
157
- - pick - 选择部分属性。
158
- - pickBy - 根据方法,选择部分属性。
159
- - String 字符串
160
- - camelCase - 驼峰小写。
161
- - capitalize - 首字母大写,其余小写。
162
- - escape - 转义 `&` `<` `>` `"` `'` 为 HTML 实体字符。
163
- - escapeRegExp - 转义为 `RegExp` 字符串中的特殊字符。
164
- - kebabCase - 连接符分隔小写。
165
- - lowerCase - 空格分隔小写。
166
- - lowerFirst - 首字母小写。
167
- - snakeCase - 下划线分隔小写
168
- - unescape - 转义字符串中的 HTML 实体字符 `&amp;` `&lt;` `&quot;` `&#39;`。
169
- - upperCase - 空格分隔大写。
170
- - upperFirst - 首字母大写。
171
- - words - 拆分词组。
172
- - Util 实用工具
173
- - castArray - 包装成数组。
174
- - conforms - 创建断言对象属性的方法。
175
- - conformsTo - 断言对象属性。
176
- - constant - 返回自身的函数。
177
- - defaultTo - 默认值。
178
- - eq - 等于。
179
- - gt - 大于。
180
- - gte - 大于等于
181
- - identity - 返回第一个参数的函数。
182
- - lt - 小于。
183
- - lte - 小于等于。
184
- - noop - 空函数。
185
- - nthArg - 返回指定位置参数的函数。
186
- - range - 创建升序或降序的数字数组。
187
- - sleep - 返回 `promise` 延迟。
188
- - times - 迭代执行次数。
189
- - toFinite - 转为有限数字。
190
- - toInteger - 转为整数。
191
- - toLength - 转为数组长度整数。
192
- - toNumber - 转为数字。
193
- - toSafeInteger - 转为安全整数。
194
- - toString - 转为字符串。
195
- - uniqueId - 唯一 ID。
63
+ - [Array](https://caijf.github.io/ut2/module-Array.html) 数组
64
+ - [chunk](https://caijf.github.io/ut2/module-Array.html#.chunk) - 拆分成多个 `size` 长度的区块。
65
+ - [compact](https://caijf.github.io/ut2/module-Array.html#.compact) - 剔除假值元素。
66
+ - [difference](https://caijf.github.io/ut2/module-Array.html#.difference) - 排除部分值。
67
+ - [formPairs](https://caijf.github.io/ut2/module-Array.html#.fromPairs) - 将键值对转为对象。
68
+ - [intersection](https://caijf.github.io/ut2/module-Array.html#.intersection) - 交集去重。
69
+ - [nth](https://caijf.github.io/ut2/module-Array.html#.nth) - 获取第 `n` 个元素。
70
+ - [shuffle](https://caijf.github.io/ut2/module-Array.html#.shuffle) - 打乱数组。
71
+ - [union](https://caijf.github.io/ut2/module-Array.html#.union) - 并集去重。
72
+ - [uniq](https://caijf.github.io/ut2/module-Array.html#.uniq) - 数组去重。
73
+ - [unzip](https://caijf.github.io/ut2/module-Array.html#.unzip) - 数组分组。
74
+ - [xor](https://caijf.github.io/ut2/module-Array.html#.xor) - 先并集再排除交集部分。
75
+ - [zip](https://caijf.github.io/ut2/module-Array.html#.zip) - 数组参数分组。
76
+ - [Collection](https://caijf.github.io/ut2/module-Collection.html) 集合
77
+ - [countBy](https://caijf.github.io/ut2/module-Collection.html#.countBy) - 统计数量。
78
+ - [every](https://caijf.github.io/ut2/module-Collection.html#.every) - 检查集合元素都为真值。
79
+ - [filter](https://caijf.github.io/ut2/module-Collection.html#.filter) - 过滤集合元素。
80
+ - [find](https://caijf.github.io/ut2/module-Collection.html#.find) - 查找集合元素。
81
+ - [forEach](https://caijf.github.io/ut2/module-Collection.html#.forEach) - 迭代集合元素。
82
+ - [forEachRight](https://caijf.github.io/ut2/module-Collection.html#.forEachRight) - 迭代集合元素(从右往左的顺序)。
83
+ - [groupBy](https://caijf.github.io/ut2/module-Collection.html#.groupBy) - 对象分组。
84
+ - [keyBy](https://caijf.github.io/ut2/module-Collection.html#.keyBy) - 转为对象。
85
+ - [map](https://caijf.github.io/ut2/module-Collection.html#.map) - 迭代集合元素生成新数组。
86
+ - [orderBy](https://caijf.github.io/ut2/module-Collection.html#.orderBy) - 排序。
87
+ - [partition](https://caijf.github.io/ut2/module-Collection.html#.partition) - 拆分真值和假值。
88
+ - [reduce](https://caijf.github.io/ut2/module-Collection.html#.reduce) - 累计值。
89
+ - [reduceRight](https://caijf.github.io/ut2/module-Collection.html#.reduceRight) - 累计值(从右往左的顺序)。
90
+ - [some](https://caijf.github.io/ut2/module-Collection.html#.some) - 检查集合元素包含真值。
91
+ - [Function](https://caijf.github.io/ut2/module-Function.html) 函数
92
+ - [after](https://caijf.github.io/ut2/module-Function.html#.after) - 调用 `n` 或更多次之后触发。
93
+ - [before](https://caijf.github.io/ut2/module-Function.html#.before) - 调用次数少于 `n` 次之前触发。
94
+ - [debounce](https://caijf.github.io/ut2/module-Function.html#.debounce) - 防抖函数。
95
+ - [delay](https://caijf.github.io/ut2/module-Function.html#.delay) - 延迟触发。
96
+ - [negate](https://caijf.github.io/ut2/module-Function.html#.negate) - 否定断言。
97
+ - [once](https://caijf.github.io/ut2/module-Function.html#.once) - 只执行一次。
98
+ - [partial](https://caijf.github.io/ut2/module-Function.html#.partial) - 预设部分参数。
99
+ - [throttle](https://caijf.github.io/ut2/module-Function.html#.throttle) - 节流函数。
100
+ - [Language](https://caijf.github.io/ut2/module-Language.html) 语言
101
+ - [isArguments](https://caijf.github.io/ut2/module-Language.html#.isArguments) - `arguments` 对象。
102
+ - [isArray](https://caijf.github.io/ut2/module-Language.html#.isArray) - `Array` 对象。
103
+ - [isArrayBuffer](https://caijf.github.io/ut2/module-Language.html#.isArrayBuffer) - `ArrayBuffer` 对象。
104
+ - [isArrayLike](https://caijf.github.io/ut2/module-Language.html#.isArrayLike) - 类数组。
105
+ - [isArrayLikeObject](https://caijf.github.io/ut2/module-Language.html#.isArrayLikeObject) - 类数组对象。
106
+ - [isBlob](https://caijf.github.io/ut2/module-Language.html#.isBlob) - `Blob` 对象。
107
+ - [isBoolean](https://caijf.github.io/ut2/module-Language.html#.isBoolean) - 布尔类型或对象。
108
+ - [isBuffer](https://caijf.github.io/ut2/module-Language.html#.isBuffer) - `Buffer` 对象。
109
+ - [isDataView](https://caijf.github.io/ut2/module-Language.html#.isDataView) - `DataView` 对象。
110
+ - [isDate](https://caijf.github.io/ut2/module-Language.html#.isDate) - `Date` 对象。
111
+ - [isElement](https://caijf.github.io/ut2/module-Language.html#.isElement) - `Dom` 元素。
112
+ - [isEmpty](https://caijf.github.io/ut2/module-Language.html#.isEmpty) - 空对象、数组、`Map`、`Set`。
113
+ - [isEqual](https://caijf.github.io/ut2/module-Language.html#.isEqual) - 深比较。
114
+ - [isError](https://caijf.github.io/ut2/module-Language.html#.isError) - `Error` 对象。
115
+ - [isFinite](https://caijf.github.io/ut2/module-Language.html#.isFinite) - 有限数字。
116
+ - [isFunction](https://caijf.github.io/ut2/module-Language.html#.isFunction) - `Function` 对象。
117
+ - [isInteger](https://caijf.github.io/ut2/module-Language.html#.isInteger) - 整数。
118
+ - [isLength](https://caijf.github.io/ut2/module-Language.html#.isLength) - 有效的类数组长度。
119
+ - [isMap](https://caijf.github.io/ut2/module-Language.html#.isMap) - `Map` 对象。
120
+ - [isMatch](https://caijf.github.io/ut2/module-Language.html#.isMatch) - 普通对象部分匹配的深比较。
121
+ - [isNaN](https://caijf.github.io/ut2/module-Language.html#.isNaN) - `NaN` 。
122
+ - [isNil](https://caijf.github.io/ut2/module-Language.html#.isNil) - `undefined` 或 `null` 。
123
+ - [isNull](https://caijf.github.io/ut2/module-Language.html#.isNull) - `null` 。
124
+ - [isNumber](https://caijf.github.io/ut2/module-Language.html#.isNumber) - 数字类型或对象。
125
+ - [isObject](https://caijf.github.io/ut2/module-Language.html#.isObject) - 对象。
126
+ - [isObjectLike](https://caijf.github.io/ut2/module-Language.html#.isObjectLike) - 类对象。
127
+ - [isPlainObject](https://caijf.github.io/ut2/module-Language.html#.isPlainObject) - 普通对象。
128
+ - [isPromiseLike](https://caijf.github.io/ut2/module-Language.html#.isPromiseLike) - 类 `Promise` 对象。
129
+ - [isRegExp](https://caijf.github.io/ut2/module-Language.html#.isRegExp) - `RegExp` 对象。
130
+ - [isSafeInteger](https://caijf.github.io/ut2/module-Language.html#.isSafeInteger) - 安全整数。
131
+ - [isSet](https://caijf.github.io/ut2/module-Language.html#.isSet) - `Set` 对象。
132
+ - [isString](https://caijf.github.io/ut2/module-Language.html#.isString) - 字符串类型或对象。
133
+ - [isSymbol](https://caijf.github.io/ut2/module-Language.html#.isSymbol) - `Symbol` 类型或对象。
134
+ - [isTypedArray](https://caijf.github.io/ut2/module-Language.html#.isTypedArray) - 类型化数组。
135
+ - [isUndefined](https://caijf.github.io/ut2/module-Language.html#.isUndefined) - `undefined` 。
136
+ - [isWeakMap](https://caijf.github.io/ut2/module-Language.html#.isWeakMap) - `WeakMap` 对象。
137
+ - [isWeakSet](https://caijf.github.io/ut2/module-Language.html#.isWeakSet) - `WeakSet` 对象。
138
+ - [Math](https://caijf.github.io/ut2/module-Math.html) 数学
139
+ - [ceil](https://caijf.github.io/ut2/module-Math.html#.ceil) - 向上舍入。
140
+ - [floor](https://caijf.github.io/ut2/module-Math.html#.floor) - 向下舍入。
141
+ - [max](https://caijf.github.io/ut2/module-Math.html#.max) - 取最大值。
142
+ - [min](https://caijf.github.io/ut2/module-Math.html#.min) - 取最小值。
143
+ - [round](https://caijf.github.io/ut2/module-Math.html#.round) - 四舍五入。
144
+ - [Number](https://caijf.github.io/ut2/module-Number.html) 数字
145
+ - [clamp](https://caijf.github.io/ut2/module-Number.html#.clamp) - 限制数字范围。
146
+ - [inRange](https://caijf.github.io/ut2/module-Number.html#.inRange) - 是否在范围内。
147
+ - [random](https://caijf.github.io/ut2/module-Number.html#.random) - 随机小数。
148
+ - [randomInt](https://caijf.github.io/ut2/module-Number.html#.randomInt) - 随机整数。
149
+ - [Object](https://caijf.github.io/ut2/module-Object.html) 对象
150
+ - [allKeys](https://caijf.github.io/ut2/module-Object.html#.allKeys) - 对象自身的可枚举属性(包含 `Symbol` 属性)。
151
+ - [allKeysIn](https://caijf.github.io/ut2/module-Object.html#.allKeysIn) - 对象自身及继承的可枚举属性(包含 `Symbol` 属性)。
152
+ - [keys](https://caijf.github.io/ut2/module-Object.html#.keys) - 对象自身的可枚举属性(不包含 `Symbol` 属性)。
153
+ - [keysIn](https://caijf.github.io/ut2/module-Object.html#.keysIn) - 对象自身及继承的可枚举属性(不包含 `Symbol` 属性)。
154
+ - [merge](https://caijf.github.io/ut2/module-Object.html#.merge) - 递归对象或数组进行合并。
155
+ - [omit](https://caijf.github.io/ut2/module-Object.html#.omit) - 排除部分属性。
156
+ - [omitBy](https://caijf.github.io/ut2/module-Object.html#.omitBy) - 根据方法,排除部分属性。
157
+ - [pick](https://caijf.github.io/ut2/module-Object.html#.pick) - 选择部分属性。
158
+ - [pickBy](https://caijf.github.io/ut2/module-Object.html#.pickBy) - 根据方法,选择部分属性。
159
+ - [String](https://caijf.github.io/ut2/module-String.html) 字符串
160
+ - [camelCase](https://caijf.github.io/ut2/module-String.html#.camelCase) - 驼峰小写。
161
+ - [capitalize](https://caijf.github.io/ut2/module-String.html#.capitalize) - 首字母大写,其余小写。
162
+ - [escape](https://caijf.github.io/ut2/module-String.html#.escape) - 转义 `&` `<` `>` `"` `'` 为 HTML 实体字符。
163
+ - [escapeRegExp](https://caijf.github.io/ut2/module-String.html#.escapeRegExp) - 转义为 `RegExp` 字符串中的特殊字符。
164
+ - [kebabCase](https://caijf.github.io/ut2/module-String.html#.kebabCase) - 连接符分隔小写。
165
+ - [lowerCase](https://caijf.github.io/ut2/module-String.html#.lowerCase) - 空格分隔小写。
166
+ - [lowerFirst](https://caijf.github.io/ut2/module-String.html#.lowerFirst) - 首字母小写。
167
+ - [snakeCase](https://caijf.github.io/ut2/module-String.html#.snakeCase) - 下划线分隔小写
168
+ - [unescape](https://caijf.github.io/ut2/module-String.html#.unescape) - 转义字符串中的 HTML 实体字符 `&amp;` `&lt;` `&quot;` `&#39;`。
169
+ - [upperCase](https://caijf.github.io/ut2/module-String.html#.upperCase) - 空格分隔大写。
170
+ - [upperFirst](https://caijf.github.io/ut2/module-String.html#.upperFirst) - 首字母大写。
171
+ - [words](https://caijf.github.io/ut2/module-String.html#.words) - 拆分词组。
172
+ - [Util](https://caijf.github.io/ut2/module-Util.html) 实用工具
173
+ - [castArray](https://caijf.github.io/ut2/module-Util.html#.castArray) - 包装成数组。
174
+ - [conforms](https://caijf.github.io/ut2/module-Util.html#.conforms) - 创建断言对象属性的方法。
175
+ - [conformsTo](https://caijf.github.io/ut2/module-Util.html#.conformsTo) - 断言对象属性。
176
+ - [constant](https://caijf.github.io/ut2/module-Util.html#.constant) - 返回自身的函数。
177
+ - [defaultTo](https://caijf.github.io/ut2/module-Util.html#.defaultTo) - 默认值。
178
+ - [eq](https://caijf.github.io/ut2/module-Util.html#.eq) - 等于。
179
+ - [gt](https://caijf.github.io/ut2/module-Util.html#.gt) - 大于。
180
+ - [gte](https://caijf.github.io/ut2/module-Util.html#.gte) - 大于等于
181
+ - [identity](https://caijf.github.io/ut2/module-Util.html#.identity) - 返回第一个参数的函数。
182
+ - [lt](https://caijf.github.io/ut2/module-Util.html#.lt) - 小于。
183
+ - [lte](https://caijf.github.io/ut2/module-Util.html#.lte) - 小于等于。
184
+ - [noop](https://caijf.github.io/ut2/module-Util.html#.noop) - 空函数。
185
+ - [nthArg](https://caijf.github.io/ut2/module-Util.html#.nthArg) - 返回指定位置参数的函数。
186
+ - [range](https://caijf.github.io/ut2/module-Util.html#.range) - 创建升序或降序的数字数组。
187
+ - [sleep](https://caijf.github.io/ut2/module-Util.html#.sleep) - 返回 `promise` 延迟。
188
+ - [times](https://caijf.github.io/ut2/module-Util.html#.times) - 迭代执行次数。
189
+ - [toFinite](https://caijf.github.io/ut2/module-Util.html#.toFinite) - 转为有限数字。
190
+ - [toInteger](https://caijf.github.io/ut2/module-Util.html#.toInteger) - 转为整数。
191
+ - [toLength](https://caijf.github.io/ut2/module-Util.html#.toLength) - 转为数组长度整数。
192
+ - [toNumber](https://caijf.github.io/ut2/module-Util.html#.toNumber) - 转为数字。
193
+ - [toSafeInteger](https://caijf.github.io/ut2/module-Util.html#.toSafeInteger) - 转为安全整数。
194
+ - [toString](https://caijf.github.io/ut2/module-Util.html#.toString) - 转为字符串。
195
+ - [uniqueId](https://caijf.github.io/ut2/module-Util.html#.uniqueId) - 唯一 ID。
196
196
 
197
197
  [npm]: https://img.shields.io/npm/v/ut2.svg
198
198
  [npm-url]: https://npmjs.com/package/ut2
package/dist/ut2.js CHANGED
@@ -176,7 +176,7 @@
176
176
  });
177
177
  }
178
178
 
179
- function fromPairs(array) {
179
+ var fromPairs = function (array) {
180
180
  var result = {};
181
181
  if (!isArray(array)) {
182
182
  return result;
@@ -185,7 +185,7 @@
185
185
  result[item[0]] = item[1];
186
186
  });
187
187
  return result;
188
- }
188
+ };
189
189
 
190
190
  function intersection(array, other, iteratee, strictCheck) {
191
191
  if (iteratee === void 0) { iteratee = identity; }
@@ -357,7 +357,7 @@
357
357
  }
358
358
 
359
359
  function createForEach(dir) {
360
- function forEach(collection, iteratee) {
360
+ var forEach = function (collection, iteratee) {
361
361
  if (iteratee === void 0) { iteratee = identity; }
362
362
  var _keys = !isArrayLike(collection) && keys$1(collection);
363
363
  var len = (_keys || collection).length;
@@ -370,13 +370,13 @@
370
370
  i += dir;
371
371
  }
372
372
  return collection;
373
- }
373
+ };
374
374
  return forEach;
375
375
  }
376
376
 
377
377
  var forEach = createForEach(1);
378
378
 
379
- function countBy(collection, iteratee) {
379
+ var countBy = function (collection, iteratee) {
380
380
  var result = {};
381
381
  var internalIteratee = createIteratee(iteratee);
382
382
  forEach(collection, function (item) {
@@ -389,9 +389,9 @@
389
389
  }
390
390
  });
391
391
  return result;
392
- }
392
+ };
393
393
 
394
- function every(collection, predicate) {
394
+ var every = function (collection, predicate) {
395
395
  if (predicate === void 0) { predicate = identity; }
396
396
  var result = true;
397
397
  forEach(collection, function (item, index, arr) {
@@ -401,9 +401,9 @@
401
401
  }
402
402
  });
403
403
  return result;
404
- }
404
+ };
405
405
 
406
- function find(collection, predicate) {
406
+ var find = function (collection, predicate) {
407
407
  if (predicate === void 0) { predicate = identity; }
408
408
  var result;
409
409
  forEach(collection, function (item, index, arr) {
@@ -413,9 +413,9 @@
413
413
  }
414
414
  });
415
415
  return result;
416
- }
416
+ };
417
417
 
418
- function filter(array, predicate) {
418
+ var filter = function (array, predicate) {
419
419
  if (predicate === void 0) { predicate = identity; }
420
420
  var results = [];
421
421
  forEach(array, function (item, index) {
@@ -424,11 +424,11 @@
424
424
  }
425
425
  });
426
426
  return results;
427
- }
427
+ };
428
428
 
429
429
  var forEachRight = createForEach(-1);
430
430
 
431
- function groupBy(collection, iteratee) {
431
+ var groupBy = function (collection, iteratee) {
432
432
  if (iteratee === void 0) { iteratee = identity; }
433
433
  var result = {};
434
434
  var internalIteratee = createIteratee(iteratee);
@@ -442,9 +442,9 @@
442
442
  }
443
443
  });
444
444
  return result;
445
- }
445
+ };
446
446
 
447
- function keyBy(collection, iteratee) {
447
+ var keyBy = function (collection, iteratee) {
448
448
  if (iteratee === void 0) { iteratee = identity; }
449
449
  var result = {};
450
450
  var internalIteratee = createIteratee(iteratee);
@@ -453,7 +453,7 @@
453
453
  result[key] = item;
454
454
  });
455
455
  return result;
456
- }
456
+ };
457
457
 
458
458
  function isNil(value) {
459
459
  return value == null;
@@ -519,7 +519,7 @@
519
519
  return object.index - other.index;
520
520
  }
521
521
 
522
- function orderBy(collection, iteratees, orders) {
522
+ var orderBy = function (collection, iteratees, orders) {
523
523
  var result = [];
524
524
  iteratees = (isArray(iteratees) ? iteratees : iteratees !== undefined ? [iteratees] : [identity]);
525
525
  orders = (isArray(orders) ? orders : orders !== undefined ? [orders] : []);
@@ -533,18 +533,18 @@
533
533
  });
534
534
  });
535
535
  return result.sort(function (a, b) { return compareMultiple(a, b, orders); }).map(function (item) { return item.value; });
536
- }
536
+ };
537
537
 
538
- function map(collection, iteratee) {
538
+ var map = function (collection, iteratee) {
539
539
  if (iteratee === void 0) { iteratee = identity; }
540
540
  var result = [];
541
541
  forEach(collection, function (item, index, arr) {
542
542
  result.push(iteratee(item, index, arr));
543
543
  });
544
544
  return result;
545
- }
545
+ };
546
546
 
547
- function partition(collection, predicate) {
547
+ var partition = function (collection, predicate) {
548
548
  if (predicate === void 0) { predicate = identity; }
549
549
  var result = [[], []];
550
550
  var internalIteratee = createIteratee(predicate);
@@ -552,7 +552,7 @@
552
552
  result[internalIteratee(item) ? 0 : 1].push(item);
553
553
  });
554
554
  return result;
555
- }
555
+ };
556
556
 
557
557
  function createReduce(dir) {
558
558
  function reducer(collection, iteratee, memo, initial) {
@@ -570,11 +570,11 @@
570
570
  }
571
571
  return memo;
572
572
  }
573
- function reduce(collection, iteratee, initialValue) {
573
+ var reduce = function (collection, iteratee, initialValue) {
574
574
  if (iteratee === void 0) { iteratee = identity; }
575
575
  var initial = arguments.length >= 3;
576
576
  return reducer(collection, iteratee, initialValue, initial);
577
- }
577
+ };
578
578
  return reduce;
579
579
  }
580
580
 
@@ -582,7 +582,7 @@
582
582
 
583
583
  var reduceRight = createReduce(-1);
584
584
 
585
- function some(collection, predicate) {
585
+ var some = function (collection, predicate) {
586
586
  if (predicate === void 0) { predicate = identity; }
587
587
  var result = false;
588
588
  forEach(collection, function (item, index, arr) {
@@ -592,13 +592,13 @@
592
592
  }
593
593
  });
594
594
  return result;
595
- }
595
+ };
596
596
 
597
- function defaultTo(value, defaultValue) {
597
+ var defaultTo = function (value, defaultValue) {
598
598
  return value == null || value !== value ? defaultValue : value;
599
- }
599
+ };
600
600
 
601
- var VERSION = "1.7.1";
601
+ var VERSION = "1.7.2";
602
602
  var supportedArgumentsType = getTag((function () { return arguments; })()) === argumentsTag;
603
603
  var FUNC_ERROR_TEXT = 'Expected a function';
604
604
  function toSource(func) {
@@ -660,9 +660,7 @@
660
660
  }
661
661
  var timeSinceLastCall = time - lastCallTime;
662
662
  var timeSinceLastInvoke = time - lastInvokeTime;
663
- return (timeSinceLastCall >= wait ||
664
- timeSinceLastCall < 0 ||
665
- (__throttle__ && timeSinceLastInvoke >= wait));
663
+ return timeSinceLastCall >= wait || timeSinceLastCall < 0 || (__throttle__ && timeSinceLastInvoke >= wait);
666
664
  }
667
665
  function invokeFunc(time) {
668
666
  lastInvokeTime = time;
@@ -679,11 +677,7 @@
679
677
  lastArgs = args;
680
678
  var time = Date.now();
681
679
  var isInvoke = shouldInvoke(time);
682
- var waitTime = !__throttle__
683
- ? wait
684
- : !isInvoke && lastCallTime !== undefined && timer === undefined
685
- ? wait - (time - lastCallTime)
686
- : wait;
680
+ var waitTime = !__throttle__ ? wait : !isInvoke && lastCallTime !== undefined && timer === undefined ? wait - (time - lastCallTime) : wait;
687
681
  lastCallTime = time;
688
682
  if (isInvoke) {
689
683
  if (immediate && timer === undefined) {
@@ -767,19 +761,21 @@
767
761
  return before(2, func);
768
762
  }
769
763
 
770
- function partial(func) {
771
- var args = [];
772
- for (var _i = 1; _i < arguments.length; _i++) {
773
- args[_i - 1] = arguments[_i];
774
- }
764
+ var PLACEHOLDER = {
765
+ __ut2_partial__: 1
766
+ };
767
+ var partial = function (func) {
768
+ var argsOrig = arrayProtoSlice.call(arguments, 1);
775
769
  return function () {
776
- var remainingArgs = [];
777
- for (var _i = 0; _i < arguments.length; _i++) {
778
- remainingArgs[_i] = arguments[_i];
770
+ var args = [];
771
+ var argsPartial = arrayProtoSlice.call(arguments);
772
+ for (var i = 0; i < argsOrig.length; i++) {
773
+ args[i] = argsOrig[i] === PLACEHOLDER ? argsPartial.shift() : argsOrig[i];
779
774
  }
780
- return func.apply(this, args.concat(remainingArgs));
775
+ return func.apply(this, args.concat(argsPartial));
781
776
  };
782
- }
777
+ };
778
+ partial.placeholder = partial._ = PLACEHOLDER;
783
779
 
784
780
  function throttle(func, wait, immediate) {
785
781
  if (wait === void 0) { wait = 0; }
@@ -1355,7 +1351,7 @@
1355
1351
  return decimalAdjust('round', number, precision);
1356
1352
  }
1357
1353
 
1358
- function clamp(number, lower, upper) {
1354
+ var clamp = function (number, lower, upper) {
1359
1355
  if (upper === undefined) {
1360
1356
  upper = lower;
1361
1357
  lower = undefined;
@@ -1376,7 +1372,7 @@
1376
1372
  }
1377
1373
  }
1378
1374
  return number;
1379
- }
1375
+ };
1380
1376
 
1381
1377
  function inRange(number, start, end) {
1382
1378
  if (end === void 0) { end = 0; }
@@ -1626,7 +1622,7 @@
1626
1622
  return splitCaseWords(string, pattern).reduce(function (prev, cur, index) { return prev + (index ? ' ' : '') + cur.toUpperCase(); }, '');
1627
1623
  }
1628
1624
 
1629
- function conformsTo(object, source) {
1625
+ var conformsTo = function (object, source) {
1630
1626
  var props = allKeys(source);
1631
1627
  var length = props.length;
1632
1628
  if (isNil(object)) {
@@ -1644,7 +1640,7 @@
1644
1640
  }
1645
1641
  }
1646
1642
  return true;
1647
- }
1643
+ };
1648
1644
 
1649
1645
  function conforms(source) {
1650
1646
  return function (object) {
@@ -1679,7 +1675,7 @@
1679
1675
  };
1680
1676
  }
1681
1677
 
1682
- function range(start, end, step) {
1678
+ var range = function (start, end, step) {
1683
1679
  start = toFinite(start);
1684
1680
  if (isNil(end)) {
1685
1681
  end = start;
@@ -1700,7 +1696,7 @@
1700
1696
  start += step;
1701
1697
  }
1702
1698
  return result;
1703
- }
1699
+ };
1704
1700
 
1705
1701
  function sleep(ms) {
1706
1702
  if (ms === void 0) { ms = 1000; }
@@ -1709,7 +1705,7 @@
1709
1705
  });
1710
1706
  }
1711
1707
 
1712
- function times(n, iteratee) {
1708
+ var times = function (n, iteratee) {
1713
1709
  if (iteratee === void 0) { iteratee = identity; }
1714
1710
  if (n < 1 || n > MAX_SAFE_INTEGER) {
1715
1711
  return [];
@@ -1723,7 +1719,7 @@
1723
1719
  index++;
1724
1720
  }
1725
1721
  return result;
1726
- }
1722
+ };
1727
1723
 
1728
1724
  function toSafeInteger(value) {
1729
1725
  if (!value) {