a-js-tools 1.0.13-beta.0 → 1.0.13-beta.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.
- package/index.cjs.js +881 -35
- package/index.d.ts +2 -3
- package/package.json +1 -1
- package/src/object/createConstructor.d.ts +2 -0
- package/src/array/difference.cjs.js +0 -49
- package/src/array/difference.mjs.js +0 -47
- package/src/array/index.cjs.js +0 -154
- package/src/array/index.mjs.js +0 -148
- package/src/array/intersection.cjs.js +0 -43
- package/src/array/intersection.mjs.js +0 -41
- package/src/array/symmetricDifference.cjs.js +0 -48
- package/src/array/symmetricDifference.mjs.js +0 -46
- package/src/array/union.cjs.js +0 -61
- package/src/array/union.mjs.js +0 -59
- package/src/className.cjs.js +0 -58
- package/src/className.mjs.js +0 -55
- package/src/getRandomNumber.cjs.js +0 -76
- package/src/getRandomNumber.mjs.js +0 -73
- package/src/getRandomString.cjs.js +0 -107
- package/src/getRandomString.mjs.js +0 -105
- package/src/isNode.cjs.js +0 -23
- package/src/isNode.mjs.js +0 -20
- package/src/object/createConstructor.cjs.js +0 -51
- package/src/object/createConstructor.mjs.js +0 -49
- package/src/performance.cjs.js +0 -116
- package/src/performance.mjs.js +0 -113
- package/src/regexp/autoEscapedRegExp.cjs.js +0 -48
- package/src/regexp/autoEscapedRegExp.mjs.js +0 -46
- package/src/regexp/escapeRegExp.cjs.js +0 -24
- package/src/regexp/escapeRegExp.mjs.js +0 -22
- package/src/regexp/parse.cjs.js +0 -32
- package/src/regexp/parse.mjs.js +0 -30
- package/src/sleep.cjs.js +0 -38
- package/src/sleep.mjs.js +0 -36
package/index.cjs.js
CHANGED
|
@@ -1,37 +1,883 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
var
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
3
|
+
var aTypeOfJs = require('a-type-of-js');
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
*
|
|
7
|
+
* 构建一个 Constructor 构造函数
|
|
8
|
+
*
|
|
9
|
+
* 接收一个构造函数,然后返回 TS 能识别的构造函数自身
|
|
10
|
+
*
|
|
11
|
+
* 函数本身并没有执行任何逻辑,仅是简单的返回了实参自身
|
|
12
|
+
*
|
|
13
|
+
* 而经过该函数的包装,构造函数成了能够被 TS 识别为可用 new 实例的构造函数
|
|
14
|
+
*
|
|
15
|
+
* @param constructor - 传入一个构造函数
|
|
16
|
+
* @returns 返回传入的构造函数
|
|
17
|
+
*
|
|
18
|
+
* ```ts
|
|
19
|
+
* import { createConstructor } from "a-js-tools";
|
|
20
|
+
*
|
|
21
|
+
* type Tom = {
|
|
22
|
+
* a: number
|
|
23
|
+
* }
|
|
24
|
+
*
|
|
25
|
+
* function _Tom (this: TomType): Tom {
|
|
26
|
+
* this.a = 1;
|
|
27
|
+
*
|
|
28
|
+
* return this;
|
|
29
|
+
* }
|
|
30
|
+
*
|
|
31
|
+
* // 逻辑上没有错,但是会造成 ts 显示
|
|
32
|
+
* // 其目标缺少构造签名的 "new" 表达式隐式具有 "any" 类型。ts(7009)
|
|
33
|
+
* const a = new _Tom();
|
|
34
|
+
*
|
|
35
|
+
* const tomConstructor = createConstructor(_tom);
|
|
36
|
+
*
|
|
37
|
+
* const b = new tomConstructor(); // 这时就不会显示错误
|
|
38
|
+
*
|
|
39
|
+
* ```
|
|
40
|
+
*
|
|
41
|
+
*/
|
|
42
|
+
function createConstructor(constructor) {
|
|
43
|
+
constructor.prototype.apply = Function.apply;
|
|
44
|
+
constructor.prototype.bind = Function.bind;
|
|
45
|
+
constructor.prototype.call = Function.call;
|
|
46
|
+
constructor.prototype.length = Function.length;
|
|
47
|
+
// constructor.prototype.arguments = Function.arguments;
|
|
48
|
+
constructor.prototype.name = Function.name;
|
|
49
|
+
constructor.prototype.toString = Function.toString;
|
|
50
|
+
return constructor;
|
|
51
|
+
}
|
|
52
|
+
/** 对象的 assign 用法 */
|
|
53
|
+
function ObjectAssign(target, bar) {
|
|
54
|
+
const keys = Object.keys(bar);
|
|
55
|
+
keys.forEach(key => (target[key] = bar[key]));
|
|
56
|
+
return target;
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* 过去随机数
|
|
61
|
+
*
|
|
62
|
+
* @packageDocumentation
|
|
63
|
+
* @module @a-js-tools/get-random-number
|
|
64
|
+
* @license MIT
|
|
65
|
+
*/
|
|
66
|
+
/**
|
|
67
|
+
*
|
|
68
|
+
* 获取一个随机的整数类型
|
|
69
|
+
*
|
|
70
|
+
* 您可以传入两个参数并获取它们之间的任意数字,返回值<span style="color:#ff0;">*会包含端值*</span>
|
|
71
|
+
*
|
|
72
|
+
* 如果只传递一个参数,则如果提供的值为负数,则得到一个小于(或大于)该数字的整数
|
|
73
|
+
*
|
|
74
|
+
* @param max 较大值 ,不允许为`NaN`
|
|
75
|
+
* @param min 较小值,不允许为 `NaN`
|
|
76
|
+
* @returns 任意的整数
|
|
77
|
+
*/
|
|
78
|
+
function getRandomInt(max = 1, min = 0) {
|
|
79
|
+
// 判断是否为 NaN 或 不是数字
|
|
80
|
+
if (!isFinite(max) ||
|
|
81
|
+
!isFinite(min) ||
|
|
82
|
+
aTypeOfJs.isNaN(max) ||
|
|
83
|
+
aTypeOfJs.isNaN(min) ||
|
|
84
|
+
!aTypeOfJs.isNumber(max) ||
|
|
85
|
+
!aTypeOfJs.isNumber(min)) {
|
|
86
|
+
throw new TypeError('getRandomInt: max or min is NaN or is not a number');
|
|
87
|
+
}
|
|
88
|
+
/** 获取最小值 */
|
|
89
|
+
let _min = Math.ceil(Number(min)),
|
|
90
|
+
/** 获取最大值 */
|
|
91
|
+
_max = Math.floor(Number(max));
|
|
92
|
+
// 两值相等时,直接返回最大值
|
|
93
|
+
if (_max === _min)
|
|
94
|
+
return _max;
|
|
95
|
+
// 两值交换
|
|
96
|
+
if (_min > _max)
|
|
97
|
+
[_max, _min] = [_min, _max];
|
|
98
|
+
return Math.round(Math.random() * (_max - _min) + _min);
|
|
99
|
+
}
|
|
100
|
+
/**
|
|
101
|
+
*
|
|
102
|
+
* 获取任意的浮点数
|
|
103
|
+
*
|
|
104
|
+
* 您可以传入两个参数并获取它们之间的任意数字
|
|
105
|
+
*
|
|
106
|
+
* 如果只传入一个参数,则如果提供的值为负数,则获取小于(或大于)该数字的浮点数
|
|
107
|
+
*
|
|
108
|
+
* @param max 较大数,缺省值为 1
|
|
109
|
+
* @param min 较小值,缺省值为 0
|
|
110
|
+
* @returns 任意的浮点数
|
|
111
|
+
*/
|
|
112
|
+
function getRandomFloat(max = 1, min = 0) {
|
|
113
|
+
// 判断是否为 NaN 或 不是数字
|
|
114
|
+
if (!isFinite(max) ||
|
|
115
|
+
!isFinite(min) ||
|
|
116
|
+
aTypeOfJs.isNaN(max) ||
|
|
117
|
+
aTypeOfJs.isNaN(min) ||
|
|
118
|
+
!aTypeOfJs.isNumber(max) ||
|
|
119
|
+
!aTypeOfJs.isNumber(min)) {
|
|
120
|
+
throw new TypeError('getRandomInt: max or min is NaN or is not a number');
|
|
121
|
+
}
|
|
122
|
+
if (max == min)
|
|
123
|
+
max++;
|
|
124
|
+
if (min > max)
|
|
125
|
+
[max, min] = [min, max];
|
|
126
|
+
return Math.random() * (max - min) + min;
|
|
127
|
+
}
|
|
128
|
+
|
|
129
|
+
/**
|
|
130
|
+
* 驼峰命名与连字符命名法的互换
|
|
131
|
+
*
|
|
132
|
+
* @packageDocumentation
|
|
133
|
+
* @module @a-js-tools/class-name
|
|
134
|
+
* @license MIT
|
|
135
|
+
*/
|
|
136
|
+
/**
|
|
137
|
+
*
|
|
138
|
+
* 连字符连接转化为小/大驼峰命名法
|
|
139
|
+
*
|
|
140
|
+
* @param str 待转化文本
|
|
141
|
+
* @param dividingType 连字符,缺省值为 "-"
|
|
142
|
+
* @param initial 是否转换第一个字符。默认值为 false (小驼峰类型)
|
|
143
|
+
* @returns 驼峰命名法字符串(e.g. “helloWorld”)
|
|
144
|
+
*
|
|
145
|
+
*/
|
|
146
|
+
function toLowerCamelCase(
|
|
147
|
+
/** 待转化文本 */
|
|
148
|
+
str,
|
|
149
|
+
/** 连字符,缺省值为 "-" */
|
|
150
|
+
dividingType = '-',
|
|
151
|
+
/** 是否转换第一个字符。默认值为 false (小驼峰类型) */
|
|
152
|
+
initial = false) {
|
|
153
|
+
let result = str;
|
|
154
|
+
/**
|
|
155
|
+
* 匹配规则
|
|
156
|
+
*
|
|
157
|
+
* - 匹配到分隔符,将分隔符后面的字符转化为大写
|
|
158
|
+
*/
|
|
159
|
+
const template = /[\\]|[\^]|[?]|[-]|[.]|[(]|[)]|[|]|[[]\[\]]|[{]|[}]|[+]|[*]|[$]/;
|
|
160
|
+
/** 转化首字符 */
|
|
161
|
+
const toTransform = (_str, _dividingType) => _str.replace(new RegExp(`${template.test(_dividingType) ? `\\${_dividingType}` : _dividingType}([a-zA-Z])`, 'g'), (match, p1) => p1.toUpperCase());
|
|
162
|
+
// 多分隔符转化
|
|
163
|
+
dividingType
|
|
164
|
+
.split('')
|
|
165
|
+
.forEach((item) => (result = toTransform(result, item)));
|
|
166
|
+
return initial
|
|
167
|
+
? result.replace(/^./, (match) => match.toUpperCase())
|
|
168
|
+
: result;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* 驼峰命名法转化为连字符连接
|
|
172
|
+
*
|
|
173
|
+
* @param str 待转化文本
|
|
174
|
+
* @param dividingType 分割符
|
|
175
|
+
* @returns 分割符转化的文本 (e.g. 'hello-world')
|
|
176
|
+
*
|
|
177
|
+
*/
|
|
178
|
+
function toSplitCase(str, dividingType = '-') {
|
|
179
|
+
const result = str.replace(/[A-Z]/g, (match) => dividingType.concat(match.toLowerCase()));
|
|
180
|
+
return result.startsWith(dividingType) ? result.substring(1) : result;
|
|
181
|
+
}
|
|
182
|
+
|
|
183
|
+
/**
|
|
184
|
+
* 获取随机字符串
|
|
185
|
+
*
|
|
186
|
+
* @packageDocumentation
|
|
187
|
+
* @module @a-js-tools/get-random-string
|
|
188
|
+
* @license MIT
|
|
189
|
+
*/
|
|
190
|
+
/**
|
|
191
|
+
*
|
|
192
|
+
* 获取简单的随机字符串
|
|
193
|
+
*
|
|
194
|
+
* @param options - 字符串长度
|
|
195
|
+
* @returns - 随机字符串
|
|
196
|
+
*
|
|
197
|
+
*
|
|
198
|
+
*/
|
|
199
|
+
function getRandomString(options) {
|
|
200
|
+
// 验证输入参数
|
|
201
|
+
if (
|
|
202
|
+
// 参数类型错误
|
|
203
|
+
(!aTypeOfJs.isPlainObject(options) && !aTypeOfJs.isNumber(options)) ||
|
|
204
|
+
// 参数为 NaN
|
|
205
|
+
(aTypeOfJs.isNumber(options) && aTypeOfJs.isNaN(options)) ||
|
|
206
|
+
// 参数为数字时为无穷大
|
|
207
|
+
(aTypeOfJs.isNumber(options) && !isFinite(options)) ||
|
|
208
|
+
// 参数为数字时为非整数
|
|
209
|
+
(aTypeOfJs.isNumber(options) && !Number.isInteger(options)) ||
|
|
210
|
+
// 参数为数字时为负数
|
|
211
|
+
(aTypeOfJs.isNumber(options) && Number.isInteger(options) && options < 1) ||
|
|
212
|
+
// 参数为数值然而却小于 1
|
|
213
|
+
(aTypeOfJs.isNumber(options) && options < 1) ||
|
|
214
|
+
// 参数为对象但是 length 属性非数值
|
|
215
|
+
(aTypeOfJs.isPlainObject(options) &&
|
|
216
|
+
(!aTypeOfJs.isNumber(options.length) ||
|
|
217
|
+
options.length < 1 ||
|
|
218
|
+
!Number.isInteger(options.length))))
|
|
219
|
+
throw new TypeError('参数类型错误 ❌ (getRandomString)');
|
|
220
|
+
const initOptions = {
|
|
221
|
+
length: 32,
|
|
222
|
+
chars: 'abcdefghijklmnopqrstuvwxyz',
|
|
223
|
+
chars2: '0123456789',
|
|
224
|
+
chars3: '!@#$%^&*()_+~`|}{[]:;?><,./-=',
|
|
225
|
+
type: 'string',
|
|
226
|
+
includeUppercaseLetters: false,
|
|
227
|
+
includeNumbers: false,
|
|
228
|
+
includeSpecial: false,
|
|
229
|
+
};
|
|
230
|
+
/// 生成 UUID
|
|
231
|
+
if (initOptions.type === 'uuid')
|
|
232
|
+
return crypto.randomUUID();
|
|
233
|
+
// 验证输入参数
|
|
234
|
+
if (aTypeOfJs.isNumber(options) && Number.isInteger(options) && options > 0)
|
|
235
|
+
ObjectAssign(initOptions, { length: options });
|
|
236
|
+
if (aTypeOfJs.isPlainObject(options)) {
|
|
237
|
+
ObjectAssign(initOptions, options);
|
|
238
|
+
initOptions.length = initOptions.length < 1 ? 32 : initOptions.length;
|
|
239
|
+
}
|
|
240
|
+
/** 生成随机字符串 */
|
|
241
|
+
const templateCharsArr = initOptions.chars.split('');
|
|
242
|
+
// 添加大写字母
|
|
243
|
+
if (initOptions.includeUppercaseLetters)
|
|
244
|
+
interleaveString(templateCharsArr, initOptions.chars.toUpperCase());
|
|
245
|
+
// 添加数字
|
|
246
|
+
if (initOptions.includeNumbers)
|
|
247
|
+
interleaveString(templateCharsArr, initOptions.chars2);
|
|
248
|
+
// 添加特殊字符
|
|
249
|
+
if (initOptions.includeSpecial)
|
|
250
|
+
interleaveString(templateCharsArr, initOptions.chars3);
|
|
251
|
+
// 使用密码学安全的随机数生成器
|
|
252
|
+
const bytes = globalThis.crypto.getRandomValues(new Uint8Array(initOptions.length));
|
|
253
|
+
let result = '';
|
|
254
|
+
/** 获取最后的 chars 数据 */
|
|
255
|
+
const chars = templateCharsArr.join('');
|
|
256
|
+
// 循环遍历
|
|
257
|
+
bytes.forEach(byte => (result += chars.charAt(byte % chars.length)));
|
|
258
|
+
/**
|
|
259
|
+
*
|
|
260
|
+
* 字符串交叉函数
|
|
261
|
+
*
|
|
262
|
+
* 非线形串交叉,对相交叉
|
|
263
|
+
*
|
|
264
|
+
* @param str1 - 字符串1
|
|
265
|
+
* @param str2 - 字符串2
|
|
266
|
+
* @returns - 交叉后的字符串
|
|
267
|
+
* @example
|
|
268
|
+
* ```ts
|
|
269
|
+
* interleaveString('abc', '123') // 'a1b2c3'
|
|
270
|
+
* ```
|
|
271
|
+
*/
|
|
272
|
+
function interleaveString(str1, str2) {
|
|
273
|
+
const str1Length = str1.length, str2Length = str2.length;
|
|
274
|
+
const maxLength = Math.max(str1Length, str2Length);
|
|
275
|
+
for (let i = 0; i < maxLength; i++) {
|
|
276
|
+
if (i < str1Length && !aTypeOfJs.isUndefined(str2[i]))
|
|
277
|
+
str1[i] += str2[i];
|
|
278
|
+
else if (i < str2Length)
|
|
279
|
+
str1[i] = str2[i];
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
return result;
|
|
283
|
+
}
|
|
284
|
+
|
|
285
|
+
/**
|
|
286
|
+
* 防抖和节流
|
|
287
|
+
*
|
|
288
|
+
* @packageDocumentation
|
|
289
|
+
* @module @a-js-tools/performance
|
|
290
|
+
* @license MIT
|
|
291
|
+
*/
|
|
292
|
+
/**
|
|
293
|
+
*
|
|
294
|
+
* 防抖
|
|
295
|
+
*
|
|
296
|
+
* @param callback 回调函数
|
|
297
|
+
* @param options 延迟时间(毫秒),默认 200 (ms) 或包含 this 的配置
|
|
298
|
+
* @returns 返回的闭包函数
|
|
299
|
+
* @example
|
|
300
|
+
*
|
|
301
|
+
* ```ts
|
|
302
|
+
* const debounce = (callback: Function, delay = 300) => {
|
|
303
|
+
* let timer: any = null
|
|
304
|
+
* return (...args: any[]) => {
|
|
305
|
+
* clearTimeout(timer)
|
|
306
|
+
* }
|
|
307
|
+
* }
|
|
308
|
+
*
|
|
309
|
+
*/
|
|
310
|
+
function debounce(callback, options = 200) {
|
|
311
|
+
if (!aTypeOfJs.isFunction(callback))
|
|
312
|
+
throw new TypeError('callback must be a function');
|
|
313
|
+
if (aTypeOfJs.isNumber(options))
|
|
314
|
+
options = {
|
|
315
|
+
delay: options,
|
|
316
|
+
this: null,
|
|
317
|
+
};
|
|
318
|
+
if (aTypeOfJs.isUndefined(options.delay) ||
|
|
319
|
+
!isFinite(options.delay) ||
|
|
320
|
+
options.delay < 0)
|
|
321
|
+
// 强制转换非数值
|
|
322
|
+
options.delay = 200;
|
|
323
|
+
/** 定时器返回的 id */
|
|
324
|
+
let timeoutId;
|
|
325
|
+
const clear = () => {
|
|
326
|
+
if (timeoutId) {
|
|
327
|
+
clearTimeout(timeoutId);
|
|
328
|
+
timeoutId = undefined;
|
|
329
|
+
}
|
|
330
|
+
};
|
|
331
|
+
const delay = options && options.delay ? options.delay : 5;
|
|
332
|
+
const result = (...args) => {
|
|
333
|
+
clear();
|
|
334
|
+
timeoutId = setTimeout(() => {
|
|
335
|
+
try {
|
|
336
|
+
const _this = options && options.this ? options.this : null;
|
|
337
|
+
callback.apply(_this, args);
|
|
338
|
+
// Reflect.apply(callback, options?.this ?? null, args);
|
|
339
|
+
}
|
|
340
|
+
catch (error) {
|
|
341
|
+
console.log('Debounce callback throw an error', error);
|
|
342
|
+
}
|
|
343
|
+
}, Math.max(delay, 5));
|
|
344
|
+
};
|
|
345
|
+
result.cancel = () => clear();
|
|
346
|
+
return result;
|
|
347
|
+
}
|
|
348
|
+
/**
|
|
349
|
+
* 节流
|
|
350
|
+
*
|
|
351
|
+
* @param callback 回调函数
|
|
352
|
+
* @param options 延迟时间(毫秒),默认 200 (ms) 或设置 this
|
|
353
|
+
* @returns 返回的闭包函数
|
|
354
|
+
*/
|
|
355
|
+
function throttle(callback, options = 200) {
|
|
356
|
+
if (!aTypeOfJs.isFunction(callback))
|
|
357
|
+
throw new TypeError('callback must be a function');
|
|
358
|
+
if (aTypeOfJs.isNumber(options))
|
|
359
|
+
options = {
|
|
360
|
+
delay: options,
|
|
361
|
+
this: null,
|
|
362
|
+
};
|
|
363
|
+
if (aTypeOfJs.isUndefined(options.delay) ||
|
|
364
|
+
!isFinite(options.delay) ||
|
|
365
|
+
options.delay < 0)
|
|
366
|
+
// 强制转换非数值
|
|
367
|
+
options.delay = 200;
|
|
368
|
+
/** 延迟控制插销 */
|
|
369
|
+
let inThrottle = false;
|
|
370
|
+
/** 延迟控制 */
|
|
371
|
+
let timeoutId = null;
|
|
372
|
+
const delay = options && options.delay ? options.delay : 5;
|
|
373
|
+
const throttled = (...args) => {
|
|
374
|
+
if (inThrottle)
|
|
375
|
+
return;
|
|
376
|
+
try {
|
|
377
|
+
const _this = options && options.this ? options.this : null;
|
|
378
|
+
callback.apply(_this, args);
|
|
379
|
+
}
|
|
380
|
+
catch (error) {
|
|
381
|
+
console.error('Throttle 执行回调抛出问题', error);
|
|
382
|
+
}
|
|
383
|
+
inThrottle = true;
|
|
384
|
+
if (!aTypeOfJs.isNull(timeoutId))
|
|
385
|
+
clearTimeout(timeoutId);
|
|
386
|
+
timeoutId = setTimeout(() => {
|
|
387
|
+
inThrottle = false;
|
|
388
|
+
timeoutId = null;
|
|
389
|
+
}, Math.max(delay, 5));
|
|
390
|
+
};
|
|
391
|
+
throttled.cancel = () => {
|
|
392
|
+
if (!aTypeOfJs.isNull(timeoutId))
|
|
393
|
+
clearTimeout(timeoutId);
|
|
394
|
+
inThrottle = false;
|
|
395
|
+
timeoutId = null;
|
|
396
|
+
};
|
|
397
|
+
return throttled;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
/**
|
|
401
|
+
*
|
|
402
|
+
* 将一个字符串转化为符合正则要求的字符串
|
|
403
|
+
*
|
|
404
|
+
* @param str 需要转义的字符串
|
|
405
|
+
* @requires escapeRegExp 转化后字符串
|
|
406
|
+
* @example
|
|
407
|
+
*
|
|
408
|
+
* ```ts
|
|
409
|
+
* import { escapeRegExp } from 'a-js-tools';
|
|
410
|
+
*
|
|
411
|
+
* escapeRegExp('a.b.c'); // 'a\\.b\\.c'
|
|
412
|
+
* escapeRegExp('a\\.b\\.c'); // 'a\\\\.b\\\\.c'
|
|
413
|
+
* escapeRegExp('[a-z]'); // '\\[a-z\\]'
|
|
414
|
+
* escapeRegExp('^abc$'); // '\\^abc\\$'
|
|
415
|
+
* ```
|
|
416
|
+
*/
|
|
417
|
+
function escapeRegExp(str) {
|
|
418
|
+
return str.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
419
|
+
}
|
|
420
|
+
|
|
421
|
+
/**
|
|
422
|
+
*
|
|
423
|
+
* 解析 options
|
|
424
|
+
*
|
|
425
|
+
*/
|
|
426
|
+
function parse(options) {
|
|
427
|
+
// 处理 options
|
|
428
|
+
if (aTypeOfJs.isString(options)) {
|
|
429
|
+
options = {
|
|
430
|
+
flags: options,
|
|
431
|
+
};
|
|
432
|
+
}
|
|
433
|
+
// 处理 flags
|
|
434
|
+
if (!aTypeOfJs.isString(options.flags))
|
|
435
|
+
options.flags = '';
|
|
436
|
+
else {
|
|
437
|
+
// 需求是保留字符串中的某一部分,使用
|
|
438
|
+
const regexp = /[migsuy]/g;
|
|
439
|
+
const matchResult = options.flags.match(regexp);
|
|
440
|
+
if (aTypeOfJs.isNull(matchResult))
|
|
441
|
+
options.flags = '';
|
|
442
|
+
else
|
|
443
|
+
options.flags = [...new Set(matchResult)].join('');
|
|
444
|
+
}
|
|
445
|
+
return options;
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
*
|
|
450
|
+
* ## 适用于简单的文本字符串自动转化为简单模式正则表达式
|
|
451
|
+
*
|
|
452
|
+
* *若字符串包含且需保留字符类、组、反向引用、量词等时,该方法可能不适用*
|
|
453
|
+
*
|
|
454
|
+
* @param pattern 待转化的文本字符串
|
|
455
|
+
* @param options 转化选项。 为文本字符串时,默认为正则表达式的标志,还可指定是否匹配开头或结尾
|
|
456
|
+
* @returns 正则表达式
|
|
457
|
+
* @example
|
|
458
|
+
*
|
|
459
|
+
* ```ts
|
|
460
|
+
* import { autoEscapedRegExp } from 'a-regexp';
|
|
461
|
+
*
|
|
462
|
+
* autoEscapedRegExp('abc'); // => /abc/
|
|
463
|
+
* autoEscapedRegExp('abc', 'gim'); // => /abc/gim
|
|
464
|
+
* autoEscapedRegExp('abc', { flags: 'g', start: true }); // => /^abc/g
|
|
465
|
+
* autoEscapedRegExp('abc', { flags: 'g', end: true }); // => /abc$/g
|
|
466
|
+
* autoEscapedRegExp('abc', { start: true, end: true }); // => /^abc$/
|
|
467
|
+
*
|
|
468
|
+
* // 转化特殊字符类、组、反向引用、量词等
|
|
469
|
+
* // 无法保留匹配规则
|
|
470
|
+
* autoEscapedRegExp('a-zA-Z0-9'); // => /a-zA-Z0-9/
|
|
471
|
+
* autoEscapedRegExp('a-zA-Z0-9', 'g'); // => /a-zA-Z0-9/g
|
|
472
|
+
* autoEscapedRegExp('[a-zA-Z0-9]'); // => /\[a-zA-Z0-9\]/
|
|
473
|
+
* autoEscapedRegExp('^[a-zA-Z0-9]+$'); // => /\^\[a-zA-Z0-9\]\$/
|
|
474
|
+
*
|
|
475
|
+
* ```
|
|
476
|
+
*
|
|
477
|
+
*/
|
|
478
|
+
function autoEscapedRegExp(pattern, options) {
|
|
479
|
+
if (!aTypeOfJs.isString(pattern))
|
|
480
|
+
throw new TypeError('pattern must be a 字符串');
|
|
481
|
+
pattern = escapeRegExp(pattern);
|
|
482
|
+
/** 简单转化 */
|
|
483
|
+
if (aTypeOfJs.isUndefined(options))
|
|
484
|
+
return new RegExp(pattern);
|
|
485
|
+
options = parse(options);
|
|
486
|
+
return new RegExp(`${options.start ? '^' : ''}${pattern}${options.end ? '$' : ''}`, options.flags);
|
|
487
|
+
}
|
|
488
|
+
|
|
489
|
+
/**
|
|
490
|
+
*
|
|
491
|
+
* 判断当前环境是否为 node 环境
|
|
492
|
+
*
|
|
493
|
+
*/
|
|
494
|
+
function isNode() {
|
|
495
|
+
return !aTypeOfJs.isUndefined((globalThis &&
|
|
496
|
+
globalThis.process &&
|
|
497
|
+
globalThis.process.versions &&
|
|
498
|
+
globalThis.process.versions.node) ||
|
|
499
|
+
undefined);
|
|
500
|
+
}
|
|
501
|
+
/**
|
|
502
|
+
*
|
|
503
|
+
* 是否为浏览器环境
|
|
504
|
+
*
|
|
505
|
+
*/
|
|
506
|
+
function isBrowser() {
|
|
507
|
+
return !isNode();
|
|
508
|
+
}
|
|
509
|
+
|
|
510
|
+
/**
|
|
511
|
+
*
|
|
512
|
+
* 两个数组的交集
|
|
513
|
+
*
|
|
514
|
+
* @param a 数组 1️⃣
|
|
515
|
+
* @param b 数组 2️⃣
|
|
516
|
+
* @returns 返回两个数组的交集
|
|
517
|
+
* @example
|
|
518
|
+
*
|
|
519
|
+
* ```ts
|
|
520
|
+
* import { intersection } from 'a-js-tools';
|
|
521
|
+
*
|
|
522
|
+
* const log = console.log;
|
|
523
|
+
*
|
|
524
|
+
*
|
|
525
|
+
* log(intersection([1, 2, 3, 4], [2, 3])); // [2, 3]
|
|
526
|
+
* log(intersection([1, 3, 5, 7], [2, 3, 4])); // [3]
|
|
527
|
+
*
|
|
528
|
+
* ```
|
|
529
|
+
*
|
|
530
|
+
*/
|
|
531
|
+
function intersection(a, b) {
|
|
532
|
+
if (!aTypeOfJs.isArray(a) || !aTypeOfJs.isArray(b))
|
|
533
|
+
throw new TypeError('参数必须是数组类型数据');
|
|
534
|
+
// 任意数组为空,则返回空数组
|
|
535
|
+
if (aTypeOfJs.isEmptyArray(a) || aTypeOfJs.isEmptyArray(b))
|
|
536
|
+
return [];
|
|
537
|
+
/**
|
|
538
|
+
* 在实际运算中, new Set() 的 开销为 O(n) ,filter 的开销也为 O(n)
|
|
539
|
+
*
|
|
540
|
+
* 但是以较短的数组创建 Set ,可以节省内存开销
|
|
541
|
+
*/
|
|
542
|
+
const [shorter, longer] = a.length <= b.length ? [a, b] : [b, a];
|
|
543
|
+
// 提前创建工具 Set
|
|
544
|
+
const shortSet = new Set(shorter);
|
|
545
|
+
return longer.filter(item => shortSet.has(item));
|
|
546
|
+
}
|
|
547
|
+
|
|
548
|
+
/**
|
|
549
|
+
*
|
|
550
|
+
* 数组的并集
|
|
551
|
+
*
|
|
552
|
+
* <span style="color:#f36;">请注意,参数有不为数组时直接抛出 TypeError</span>
|
|
553
|
+
* @param arrays - 多个数组
|
|
554
|
+
* @returns 联合后的数组
|
|
555
|
+
*
|
|
556
|
+
*
|
|
557
|
+
* @example
|
|
558
|
+
*
|
|
559
|
+
* ```ts
|
|
560
|
+
* import { union } from 'a-js-tools';
|
|
561
|
+
*
|
|
562
|
+
* const log = console.log;
|
|
563
|
+
*
|
|
564
|
+
* // []
|
|
565
|
+
* log(union());
|
|
566
|
+
*
|
|
567
|
+
* // [1, 2, 3]
|
|
568
|
+
* log(union([1, 2, 3]));
|
|
569
|
+
*
|
|
570
|
+
* // TypeError
|
|
571
|
+
* log(union([1, 2, 3], 'i'));
|
|
572
|
+
* log(union([1, 2, 3], undefined));
|
|
573
|
+
* log(union([1, 2, 3], null));
|
|
574
|
+
* log(union([1, 2, 3], 4));
|
|
575
|
+
* log(union([1, 2, 3], {}));
|
|
576
|
+
* log(union([1, 2, 3], false));
|
|
577
|
+
*
|
|
578
|
+
* // [1, 2, 3, 4, 6]
|
|
579
|
+
* log(union([1, 2, 3], [2, 4, 6]));
|
|
580
|
+
*
|
|
581
|
+
* // [1, 2, 3, 4, 6]
|
|
582
|
+
* log(union([1, 2, 3], [2, 4, 6], [1, 2, 3]));
|
|
583
|
+
*
|
|
584
|
+
* // [1, 2, 3, 4, 6]
|
|
585
|
+
* log(union([1, 2, 3], [2, 4, 6], [1, 2, 3], [1, 2, 3]));
|
|
586
|
+
* ```
|
|
587
|
+
*
|
|
588
|
+
*/
|
|
589
|
+
function union(...arrays) {
|
|
590
|
+
if (aTypeOfJs.isEmptyArray(arrays))
|
|
591
|
+
return [];
|
|
592
|
+
if (arrays.some(i => !aTypeOfJs.isArray(i)))
|
|
593
|
+
throw new TypeError('参数必须都是数组形式的元素');
|
|
594
|
+
if (arrays.length === 1)
|
|
595
|
+
return [...arrays[0]];
|
|
596
|
+
const resultSet = new Set();
|
|
597
|
+
for (const array of arrays) {
|
|
598
|
+
for (const item of array)
|
|
599
|
+
resultSet.add(item);
|
|
600
|
+
}
|
|
601
|
+
return Array.from(resultSet);
|
|
602
|
+
}
|
|
603
|
+
|
|
604
|
+
/**
|
|
605
|
+
* 求给出的两个数组的差值(A - B)
|
|
606
|
+
*
|
|
607
|
+
* @param a - 第一个数组
|
|
608
|
+
* @param b - 第二个数组
|
|
609
|
+
* @throws {TypeError} 当两个参数有一个不是
|
|
610
|
+
* @description 当两个参数有一个不是数组时将抛出
|
|
611
|
+
* @returns 返回第一个参数相对第二个参数的差值
|
|
612
|
+
* @example
|
|
613
|
+
*
|
|
614
|
+
* ```ts
|
|
615
|
+
* import { difference} from 'a-js-tools';
|
|
616
|
+
*
|
|
617
|
+
* const log = console.log;
|
|
618
|
+
*
|
|
619
|
+
*
|
|
620
|
+
* log(difference([], [1, 2, 3])); // []
|
|
621
|
+
*
|
|
622
|
+
* log([1, 2, 3], []); //[1, 2, 3]
|
|
623
|
+
*
|
|
624
|
+
* log([1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5]); //[6, 7]
|
|
625
|
+
*
|
|
626
|
+
* // 将抛出 TypeError
|
|
627
|
+
* log(difference([1, 2, 3], 'a'));
|
|
628
|
+
* log(difference([1, 2, 3], 1));
|
|
629
|
+
* log(difference([1, 2, 3], undefined));
|
|
630
|
+
* log(difference([1, 2, 3], null));
|
|
631
|
+
* log(difference([1, 2, 3], true));
|
|
632
|
+
* ```
|
|
633
|
+
*
|
|
634
|
+
*/
|
|
635
|
+
function difference(a, b) {
|
|
636
|
+
if (!aTypeOfJs.isArray(a) || !aTypeOfJs.isArray(b))
|
|
637
|
+
throw new TypeError('参数需为数组');
|
|
638
|
+
if (aTypeOfJs.isEmptyArray(a) || aTypeOfJs.isEmptyArray(b))
|
|
639
|
+
return a;
|
|
640
|
+
/** 获取两个数组中长度较小的 */
|
|
641
|
+
// 参数有顺序要求
|
|
642
|
+
// const [shorter, longer] = a.length > b.length ? [b, a] : [a, b];
|
|
643
|
+
// const shorterSet = new Set(shorter);
|
|
644
|
+
const bSet = new Set(b);
|
|
645
|
+
return a.filter(i => !bSet.has(i));
|
|
646
|
+
}
|
|
647
|
+
|
|
648
|
+
/**
|
|
649
|
+
*
|
|
650
|
+
* 对称差集 ( A △ B)
|
|
651
|
+
*
|
|
652
|
+
* @param a - 数组 a
|
|
653
|
+
* @param b - 数组 b
|
|
654
|
+
* @returns - 返回一个全新的数组
|
|
655
|
+
*
|
|
656
|
+
* @example
|
|
657
|
+
*
|
|
658
|
+
* ```ts
|
|
659
|
+
* import { symmetricDifference } from 'a-js-tools';
|
|
660
|
+
*
|
|
661
|
+
* const log = console.log;
|
|
662
|
+
*
|
|
663
|
+
* log(symmetricDifference([1, 2], [2, 3])); // [1, 3]
|
|
664
|
+
*
|
|
665
|
+
* log(symmetricDifference([1, 2, 3], [1, 2, 4])); // [3, 4]
|
|
666
|
+
*
|
|
667
|
+
* log(symmetricDifference([1, 2, 3], [1, 2, 3])); // []
|
|
668
|
+
*
|
|
669
|
+
*
|
|
670
|
+
* /// TypeError
|
|
671
|
+
* log(symmetricDifference(1, []));
|
|
672
|
+
* log(symmetricDifference(undefined, []));
|
|
673
|
+
* log(symmetricDifference(null, []));
|
|
674
|
+
* log(symmetricDifference('a', []));
|
|
675
|
+
* log(symmetricDifference(true, []));
|
|
676
|
+
*
|
|
677
|
+
* ```
|
|
678
|
+
*
|
|
679
|
+
*/
|
|
680
|
+
function symmetricDifference(a, b) {
|
|
681
|
+
if (!aTypeOfJs.isArray(a) || !aTypeOfJs.isArray(b))
|
|
682
|
+
throw new TypeError('参数必须是数组');
|
|
683
|
+
if (aTypeOfJs.isEmptyArray(a))
|
|
684
|
+
return [...b];
|
|
685
|
+
if (aTypeOfJs.isEmptyArray(b))
|
|
686
|
+
return [...a];
|
|
687
|
+
return [...difference(a, b), ...difference(b, a)];
|
|
688
|
+
}
|
|
689
|
+
|
|
690
|
+
/**
|
|
691
|
+
*
|
|
692
|
+
* 数组的一些方法
|
|
693
|
+
*
|
|
694
|
+
* - union 两个数组的并集(排除共有项)
|
|
695
|
+
* - intersection 两个数组的交集(共有项)
|
|
696
|
+
* - difference 两个数组的差集 (A - B)
|
|
697
|
+
* - symmetricDifference 对称差集 ( A △ B)
|
|
698
|
+
*
|
|
699
|
+
*/
|
|
700
|
+
const enArr = {
|
|
701
|
+
/**
|
|
702
|
+
*
|
|
703
|
+
* 数组的并集
|
|
704
|
+
*
|
|
705
|
+
* <span style="color:#f36;">请注意,参数有不为数组时直接抛出 TypeError</span>
|
|
706
|
+
* @param arrays - 多个数组
|
|
707
|
+
* @returns 联合后的数组
|
|
708
|
+
*
|
|
709
|
+
*
|
|
710
|
+
* @example
|
|
711
|
+
*
|
|
712
|
+
* ```ts
|
|
713
|
+
* import { union } from 'a-js-tools';
|
|
714
|
+
*
|
|
715
|
+
* const log = console.log;
|
|
716
|
+
*
|
|
717
|
+
* // []
|
|
718
|
+
* log(union());
|
|
719
|
+
*
|
|
720
|
+
* // [1, 2, 3]
|
|
721
|
+
* log(union([1, 2, 3]));
|
|
722
|
+
*
|
|
723
|
+
* // TypeError
|
|
724
|
+
* log(union([1, 2, 3], 'i'));
|
|
725
|
+
* log(union([1, 2, 3], undefined));
|
|
726
|
+
* log(union([1, 2, 3], null));
|
|
727
|
+
* log(union([1, 2, 3], 4));
|
|
728
|
+
* log(union([1, 2, 3], {}));
|
|
729
|
+
* log(union([1, 2, 3], false));
|
|
730
|
+
*
|
|
731
|
+
* // [1, 2, 3, 4, 6]
|
|
732
|
+
* log(union([1, 2, 3], [2, 4, 6]));
|
|
733
|
+
*
|
|
734
|
+
* // [1, 2, 3, 4, 6]
|
|
735
|
+
* log(union([1, 2, 3], [2, 4, 6], [1, 2, 3]));
|
|
736
|
+
*
|
|
737
|
+
* // [1, 2, 3, 4, 6]
|
|
738
|
+
* log(union([1, 2, 3], [2, 4, 6], [1, 2, 3], [1, 2, 3]));
|
|
739
|
+
* ```
|
|
740
|
+
*
|
|
741
|
+
*/
|
|
742
|
+
union,
|
|
743
|
+
/**
|
|
744
|
+
*
|
|
745
|
+
* 两个数组的交集
|
|
746
|
+
*
|
|
747
|
+
* @param a 数组 1️⃣
|
|
748
|
+
* @param b 数组 2️⃣
|
|
749
|
+
* @returns 返回两个数组的交集
|
|
750
|
+
* @example
|
|
751
|
+
*
|
|
752
|
+
* ```ts
|
|
753
|
+
* import { intersection } from 'a-js-tools';
|
|
754
|
+
*
|
|
755
|
+
* const log = console.log;
|
|
756
|
+
*
|
|
757
|
+
*
|
|
758
|
+
* log(intersection([1, 2, 3, 4], [2, 3])); // [2, 3]
|
|
759
|
+
* log(intersection([1, 3, 5, 7], [2, 3, 4])); // [3]
|
|
760
|
+
*
|
|
761
|
+
* ```
|
|
762
|
+
*
|
|
763
|
+
*/
|
|
764
|
+
intersection,
|
|
765
|
+
/**
|
|
766
|
+
* 求给出的两个数组的差值(A - B)
|
|
767
|
+
*
|
|
768
|
+
* @param a - 第一个数组
|
|
769
|
+
* @param b - 第二个数组
|
|
770
|
+
* @throws {TypeError} 当两个参数有一个不是
|
|
771
|
+
* @description 当两个参数有一个不是数组时将抛出
|
|
772
|
+
* @returns 返回第一个参数相对第二个参数的差值
|
|
773
|
+
* @example
|
|
774
|
+
*
|
|
775
|
+
* ```ts
|
|
776
|
+
* import { difference} from 'a-js-tools';
|
|
777
|
+
*
|
|
778
|
+
* const log = console.log;
|
|
779
|
+
*
|
|
780
|
+
*
|
|
781
|
+
* log(difference([], [1, 2, 3])); // []
|
|
782
|
+
*
|
|
783
|
+
* log([1, 2, 3], []); //[1, 2, 3]
|
|
784
|
+
*
|
|
785
|
+
* log([1, 2, 3, 4, 5, 6, 7], [1, 2, 3, 4, 5]); //[6, 7]
|
|
786
|
+
*
|
|
787
|
+
* // 将抛出 TypeError
|
|
788
|
+
* log(difference([1, 2, 3], 'a'));
|
|
789
|
+
* log(difference([1, 2, 3], 1));
|
|
790
|
+
* log(difference([1, 2, 3], undefined));
|
|
791
|
+
* log(difference([1, 2, 3], null));
|
|
792
|
+
* log(difference([1, 2, 3], true));
|
|
793
|
+
* ```
|
|
794
|
+
*
|
|
795
|
+
*/
|
|
796
|
+
difference,
|
|
797
|
+
/**
|
|
798
|
+
*
|
|
799
|
+
* 对称差集 ( A △ B)
|
|
800
|
+
*
|
|
801
|
+
* @param a - 数组 a
|
|
802
|
+
* @param b - 数组 b
|
|
803
|
+
* @returns - 返回一个全新的数组
|
|
804
|
+
*
|
|
805
|
+
* @example
|
|
806
|
+
*
|
|
807
|
+
* ```ts
|
|
808
|
+
* import { symmetricDifference } from 'a-js-tools';
|
|
809
|
+
*
|
|
810
|
+
* const log = console.log;
|
|
811
|
+
*
|
|
812
|
+
* log(symmetricDifference([1, 2], [2, 3])); // [1, 3]
|
|
813
|
+
*
|
|
814
|
+
* log(symmetricDifference([1, 2, 3], [1, 2, 4])); // [3, 4]
|
|
815
|
+
*
|
|
816
|
+
* log(symmetricDifference([1, 2, 3], [1, 2, 3])); // []
|
|
817
|
+
*
|
|
818
|
+
*
|
|
819
|
+
* /// TypeError
|
|
820
|
+
* log(symmetricDifference(1, []));
|
|
821
|
+
* log(symmetricDifference(undefined, []));
|
|
822
|
+
* log(symmetricDifference(null, []));
|
|
823
|
+
* log(symmetricDifference('a', []));
|
|
824
|
+
* log(symmetricDifference(true, []));
|
|
825
|
+
*
|
|
826
|
+
* ```
|
|
827
|
+
*
|
|
828
|
+
*/
|
|
829
|
+
symmetricDifference,
|
|
830
|
+
};
|
|
831
|
+
|
|
832
|
+
/**
|
|
833
|
+
*
|
|
834
|
+
* ## 线程休息
|
|
835
|
+
*
|
|
836
|
+
* 但从调用到执行完毕总是与期望的时间并不相吻合,除非执行是线型的(也不保证时间的严格性)
|
|
837
|
+
*
|
|
838
|
+
* - 宏任务:整体代码、setTimeout、DOM 事件回调、requestAnimationFrame、setImmediate、setInterval、I/O操作、UI渲染等
|
|
839
|
+
* - 微任务:Promise的then/catch/finally、process.nextTick(Node.js)、MutationObserver、queueMicrotask(显示添加微任务)等
|
|
840
|
+
*
|
|
841
|
+
* <span style="color:#ff0;">*Node.js中的process.nextTick优先级高于其他微任务*</span>
|
|
842
|
+
*
|
|
843
|
+
* @param delay 睡觉时长(机器时间,毫秒为单位)
|
|
844
|
+
* @returns 🈳
|
|
845
|
+
* @example
|
|
846
|
+
*
|
|
847
|
+
* ```ts
|
|
848
|
+
* import { sleep } from 'a-js-tools';
|
|
849
|
+
*
|
|
850
|
+
* console.log(Date.now()); // 1748058118471
|
|
851
|
+
* await sleep(1000);
|
|
852
|
+
* console.log(Date.now()); // 1748058119473
|
|
853
|
+
*
|
|
854
|
+
* ```
|
|
855
|
+
*
|
|
856
|
+
*/
|
|
857
|
+
async function sleep(delay = 1000) {
|
|
858
|
+
if (!isFinite(delay) || delay < 0)
|
|
859
|
+
throw new TypeError('delay 应该是一个正常的数值');
|
|
860
|
+
if (aTypeOfJs.isZero(delay))
|
|
861
|
+
return Promise.resolve();
|
|
862
|
+
return new Promise(resolve => setTimeout(resolve, delay));
|
|
863
|
+
}
|
|
864
|
+
|
|
865
|
+
exports.ObjectAssign = ObjectAssign;
|
|
866
|
+
exports.autoEscapedRegExp = autoEscapedRegExp;
|
|
867
|
+
exports.createConstructor = createConstructor;
|
|
868
|
+
exports.debounce = debounce;
|
|
869
|
+
exports.difference = difference;
|
|
870
|
+
exports.enArr = enArr;
|
|
871
|
+
exports.escapeRegExp = escapeRegExp;
|
|
872
|
+
exports.getRandomFloat = getRandomFloat;
|
|
873
|
+
exports.getRandomInt = getRandomInt;
|
|
874
|
+
exports.getRandomString = getRandomString;
|
|
875
|
+
exports.intersection = intersection;
|
|
876
|
+
exports.isBrowser = isBrowser;
|
|
877
|
+
exports.isNode = isNode;
|
|
878
|
+
exports.sleep = sleep;
|
|
879
|
+
exports.symmetricDifference = symmetricDifference;
|
|
880
|
+
exports.throttle = throttle;
|
|
881
|
+
exports.toLowerCamelCase = toLowerCamelCase;
|
|
882
|
+
exports.toSplitCase = toSplitCase;
|
|
883
|
+
exports.union = union;
|