@hairy/utils 1.32.0 → 1.33.0
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/dist/index.cjs +317 -160
- package/dist/index.d.ts +82 -19
- package/dist/index.global.js +271 -158
- package/dist/index.js +294 -159
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -54,6 +54,8 @@ __export(index_exports, {
|
|
|
54
54
|
dotCase: () => dotCase,
|
|
55
55
|
downloadBlobFile: () => downloadBlobFile,
|
|
56
56
|
downloadNetworkFile: () => downloadNetworkFile,
|
|
57
|
+
ensurePrefix: () => ensurePrefix,
|
|
58
|
+
ensureSuffix: () => ensureSuffix,
|
|
57
59
|
find: () => find_default,
|
|
58
60
|
formToObject: () => formToObject,
|
|
59
61
|
formatNumeric: () => formatNumeric,
|
|
@@ -65,15 +67,21 @@ __export(index_exports, {
|
|
|
65
67
|
gte: () => gte,
|
|
66
68
|
integer: () => integer,
|
|
67
69
|
isAndroid: () => isAndroid,
|
|
70
|
+
isArguments: () => isArguments_default,
|
|
68
71
|
isArray: () => isArray_default,
|
|
72
|
+
isArrayBuffer: () => isArrayBuffer_default,
|
|
69
73
|
isArrayLike: () => isArrayLike_default,
|
|
74
|
+
isArrayLikeObject: () => isArrayLikeObject_default,
|
|
70
75
|
isBoolean: () => isBoolean_default,
|
|
71
76
|
isBrowser: () => isBrowser,
|
|
77
|
+
isBuffer: () => isBuffer_default,
|
|
72
78
|
isChrome: () => isChrome,
|
|
73
79
|
isDate: () => isDate_default,
|
|
74
80
|
isEdge: () => isEdge,
|
|
81
|
+
isElement: () => isElement_default,
|
|
75
82
|
isEmpty: () => isEmpty_default,
|
|
76
83
|
isEqual: () => isEqual_default,
|
|
84
|
+
isEqualWith: () => isEqualWith_default,
|
|
77
85
|
isError: () => isError_default,
|
|
78
86
|
isFF: () => isFF,
|
|
79
87
|
isFormData: () => isFormData,
|
|
@@ -82,18 +90,28 @@ __export(index_exports, {
|
|
|
82
90
|
isIE11: () => isIE11,
|
|
83
91
|
isIE9: () => isIE9,
|
|
84
92
|
isIOS: () => isIOS,
|
|
93
|
+
isInteger: () => isInteger_default,
|
|
94
|
+
isMap: () => isMap_default,
|
|
95
|
+
isMatch: () => isMatch_default,
|
|
96
|
+
isMatchWith: () => isMatchWith_default,
|
|
85
97
|
isMobile: () => isMobile,
|
|
86
98
|
isNaN: () => isNaN_default,
|
|
87
99
|
isNative: () => isNative_default,
|
|
88
100
|
isNull: () => isNull_default,
|
|
89
101
|
isNumber: () => isNumber_default,
|
|
90
102
|
isObject: () => isObject_default,
|
|
103
|
+
isObjectLike: () => isObjectLike_default,
|
|
91
104
|
isPhantomJS: () => isPhantomJS,
|
|
92
105
|
isPlainObject: () => isPlainObject_default,
|
|
106
|
+
isRegexp: () => isRegExp_default,
|
|
107
|
+
isSet: () => isSet_default,
|
|
93
108
|
isString: () => isString_default,
|
|
109
|
+
isSymbol: () => isSymbol_default,
|
|
94
110
|
isTruthy: () => isTruthy,
|
|
95
111
|
isTypeof: () => isTypeof,
|
|
96
112
|
isUndefined: () => isUndefined_default,
|
|
113
|
+
isWeakMap: () => isWeakMap_default,
|
|
114
|
+
isWeakSet: () => isWeakSet_default,
|
|
97
115
|
isWeex: () => isWeex,
|
|
98
116
|
isWindow: () => isWindow,
|
|
99
117
|
join: () => join_default,
|
|
@@ -120,7 +138,8 @@ __export(index_exports, {
|
|
|
120
138
|
plus: () => plus,
|
|
121
139
|
proxy: () => proxy,
|
|
122
140
|
randomArray: () => randomArray,
|
|
123
|
-
|
|
141
|
+
randomNumber: () => randomNumber,
|
|
142
|
+
randomString: () => randomString,
|
|
124
143
|
readFileReader: () => readFileReader,
|
|
125
144
|
redirectTo: () => redirectTo,
|
|
126
145
|
riposte: () => riposte,
|
|
@@ -128,10 +147,13 @@ __export(index_exports, {
|
|
|
128
147
|
sentenceCase: () => sentenceCase,
|
|
129
148
|
showOpenFilePicker: () => showOpenFilePicker,
|
|
130
149
|
showOpenImagePicker: () => showOpenImagePicker,
|
|
150
|
+
slash: () => slash,
|
|
131
151
|
snakeCase: () => snakeCase,
|
|
152
|
+
template: () => template,
|
|
132
153
|
to: () => to,
|
|
133
154
|
trainCase: () => trainCase,
|
|
134
155
|
truncate: () => truncate_default,
|
|
156
|
+
unindent: () => unindent,
|
|
135
157
|
uniq: () => uniq_default,
|
|
136
158
|
uniqBy: () => uniqBy_default,
|
|
137
159
|
uniqWith: () => uniqWith_default,
|
|
@@ -218,142 +240,6 @@ function off(obj, ...args) {
|
|
|
218
240
|
obj.removeEventListener(...args);
|
|
219
241
|
}
|
|
220
242
|
|
|
221
|
-
// ../../node_modules/.pnpm/change-case@5.4.4/node_modules/change-case/dist/index.js
|
|
222
|
-
var SPLIT_LOWER_UPPER_RE = /([\p{Ll}\d])(\p{Lu})/gu;
|
|
223
|
-
var SPLIT_UPPER_UPPER_RE = /(\p{Lu})([\p{Lu}][\p{Ll}])/gu;
|
|
224
|
-
var SPLIT_SEPARATE_NUMBER_RE = /(\d)\p{Ll}|(\p{L})\d/u;
|
|
225
|
-
var DEFAULT_STRIP_REGEXP = /[^\p{L}\d]+/giu;
|
|
226
|
-
var SPLIT_REPLACE_VALUE = "$1\0$2";
|
|
227
|
-
var DEFAULT_PREFIX_SUFFIX_CHARACTERS = "";
|
|
228
|
-
function split(value) {
|
|
229
|
-
let result = value.trim();
|
|
230
|
-
result = result.replace(SPLIT_LOWER_UPPER_RE, SPLIT_REPLACE_VALUE).replace(SPLIT_UPPER_UPPER_RE, SPLIT_REPLACE_VALUE);
|
|
231
|
-
result = result.replace(DEFAULT_STRIP_REGEXP, "\0");
|
|
232
|
-
let start = 0;
|
|
233
|
-
let end = result.length;
|
|
234
|
-
while (result.charAt(start) === "\0")
|
|
235
|
-
start++;
|
|
236
|
-
if (start === end)
|
|
237
|
-
return [];
|
|
238
|
-
while (result.charAt(end - 1) === "\0")
|
|
239
|
-
end--;
|
|
240
|
-
return result.slice(start, end).split(/\0/g);
|
|
241
|
-
}
|
|
242
|
-
function splitSeparateNumbers(value) {
|
|
243
|
-
const words = split(value);
|
|
244
|
-
for (let i = 0; i < words.length; i++) {
|
|
245
|
-
const word = words[i];
|
|
246
|
-
const match = SPLIT_SEPARATE_NUMBER_RE.exec(word);
|
|
247
|
-
if (match) {
|
|
248
|
-
const offset = match.index + (match[1] ?? match[2]).length;
|
|
249
|
-
words.splice(i, 1, word.slice(0, offset), word.slice(offset));
|
|
250
|
-
}
|
|
251
|
-
}
|
|
252
|
-
return words;
|
|
253
|
-
}
|
|
254
|
-
function noCase(input, options) {
|
|
255
|
-
const [prefix, words, suffix] = splitPrefixSuffix(input, options);
|
|
256
|
-
return prefix + words.map(lowerFactory(options?.locale)).join(options?.delimiter ?? " ") + suffix;
|
|
257
|
-
}
|
|
258
|
-
function camelCase(input, options) {
|
|
259
|
-
const [prefix, words, suffix] = splitPrefixSuffix(input, options);
|
|
260
|
-
const lower = lowerFactory(options?.locale);
|
|
261
|
-
const upper = upperFactory(options?.locale);
|
|
262
|
-
const transform = options?.mergeAmbiguousCharacters ? capitalCaseTransformFactory(lower, upper) : pascalCaseTransformFactory(lower, upper);
|
|
263
|
-
return prefix + words.map((word, index) => {
|
|
264
|
-
if (index === 0)
|
|
265
|
-
return lower(word);
|
|
266
|
-
return transform(word, index);
|
|
267
|
-
}).join(options?.delimiter ?? "") + suffix;
|
|
268
|
-
}
|
|
269
|
-
function pascalCase(input, options) {
|
|
270
|
-
const [prefix, words, suffix] = splitPrefixSuffix(input, options);
|
|
271
|
-
const lower = lowerFactory(options?.locale);
|
|
272
|
-
const upper = upperFactory(options?.locale);
|
|
273
|
-
const transform = options?.mergeAmbiguousCharacters ? capitalCaseTransformFactory(lower, upper) : pascalCaseTransformFactory(lower, upper);
|
|
274
|
-
return prefix + words.map(transform).join(options?.delimiter ?? "") + suffix;
|
|
275
|
-
}
|
|
276
|
-
function pascalSnakeCase(input, options) {
|
|
277
|
-
return capitalCase(input, { delimiter: "_", ...options });
|
|
278
|
-
}
|
|
279
|
-
function capitalCase(input, options) {
|
|
280
|
-
const [prefix, words, suffix] = splitPrefixSuffix(input, options);
|
|
281
|
-
const lower = lowerFactory(options?.locale);
|
|
282
|
-
const upper = upperFactory(options?.locale);
|
|
283
|
-
return prefix + words.map(capitalCaseTransformFactory(lower, upper)).join(options?.delimiter ?? " ") + suffix;
|
|
284
|
-
}
|
|
285
|
-
function constantCase(input, options) {
|
|
286
|
-
const [prefix, words, suffix] = splitPrefixSuffix(input, options);
|
|
287
|
-
return prefix + words.map(upperFactory(options?.locale)).join(options?.delimiter ?? "_") + suffix;
|
|
288
|
-
}
|
|
289
|
-
function dotCase(input, options) {
|
|
290
|
-
return noCase(input, { delimiter: ".", ...options });
|
|
291
|
-
}
|
|
292
|
-
function kebabCase(input, options) {
|
|
293
|
-
return noCase(input, { delimiter: "-", ...options });
|
|
294
|
-
}
|
|
295
|
-
function pathCase(input, options) {
|
|
296
|
-
return noCase(input, { delimiter: "/", ...options });
|
|
297
|
-
}
|
|
298
|
-
function sentenceCase(input, options) {
|
|
299
|
-
const [prefix, words, suffix] = splitPrefixSuffix(input, options);
|
|
300
|
-
const lower = lowerFactory(options?.locale);
|
|
301
|
-
const upper = upperFactory(options?.locale);
|
|
302
|
-
const transform = capitalCaseTransformFactory(lower, upper);
|
|
303
|
-
return prefix + words.map((word, index) => {
|
|
304
|
-
if (index === 0)
|
|
305
|
-
return transform(word);
|
|
306
|
-
return lower(word);
|
|
307
|
-
}).join(options?.delimiter ?? " ") + suffix;
|
|
308
|
-
}
|
|
309
|
-
function snakeCase(input, options) {
|
|
310
|
-
return noCase(input, { delimiter: "_", ...options });
|
|
311
|
-
}
|
|
312
|
-
function trainCase(input, options) {
|
|
313
|
-
return capitalCase(input, { delimiter: "-", ...options });
|
|
314
|
-
}
|
|
315
|
-
function lowerFactory(locale) {
|
|
316
|
-
return locale === false ? (input) => input.toLowerCase() : (input) => input.toLocaleLowerCase(locale);
|
|
317
|
-
}
|
|
318
|
-
function upperFactory(locale) {
|
|
319
|
-
return locale === false ? (input) => input.toUpperCase() : (input) => input.toLocaleUpperCase(locale);
|
|
320
|
-
}
|
|
321
|
-
function capitalCaseTransformFactory(lower, upper) {
|
|
322
|
-
return (word) => `${upper(word[0])}${lower(word.slice(1))}`;
|
|
323
|
-
}
|
|
324
|
-
function pascalCaseTransformFactory(lower, upper) {
|
|
325
|
-
return (word, index) => {
|
|
326
|
-
const char0 = word[0];
|
|
327
|
-
const initial = index > 0 && char0 >= "0" && char0 <= "9" ? "_" + char0 : upper(char0);
|
|
328
|
-
return initial + lower(word.slice(1));
|
|
329
|
-
};
|
|
330
|
-
}
|
|
331
|
-
function splitPrefixSuffix(input, options = {}) {
|
|
332
|
-
const splitFn = options.split ?? (options.separateNumbers ? splitSeparateNumbers : split);
|
|
333
|
-
const prefixCharacters = options.prefixCharacters ?? DEFAULT_PREFIX_SUFFIX_CHARACTERS;
|
|
334
|
-
const suffixCharacters = options.suffixCharacters ?? DEFAULT_PREFIX_SUFFIX_CHARACTERS;
|
|
335
|
-
let prefixIndex = 0;
|
|
336
|
-
let suffixIndex = input.length;
|
|
337
|
-
while (prefixIndex < input.length) {
|
|
338
|
-
const char = input.charAt(prefixIndex);
|
|
339
|
-
if (!prefixCharacters.includes(char))
|
|
340
|
-
break;
|
|
341
|
-
prefixIndex++;
|
|
342
|
-
}
|
|
343
|
-
while (suffixIndex > prefixIndex) {
|
|
344
|
-
const index = suffixIndex - 1;
|
|
345
|
-
const char = input.charAt(index);
|
|
346
|
-
if (!suffixCharacters.includes(char))
|
|
347
|
-
break;
|
|
348
|
-
suffixIndex = index;
|
|
349
|
-
}
|
|
350
|
-
return [
|
|
351
|
-
input.slice(0, prefixIndex),
|
|
352
|
-
splitFn(input.slice(prefixIndex, suffixIndex)),
|
|
353
|
-
input.slice(suffixIndex)
|
|
354
|
-
];
|
|
355
|
-
}
|
|
356
|
-
|
|
357
243
|
// ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_freeGlobal.js
|
|
358
244
|
var freeGlobal = typeof global == "object" && global && global.Object === Object && global;
|
|
359
245
|
var freeGlobal_default = freeGlobal;
|
|
@@ -2885,6 +2771,18 @@ function values(object) {
|
|
|
2885
2771
|
}
|
|
2886
2772
|
var values_default = values;
|
|
2887
2773
|
|
|
2774
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/_baseIsArrayBuffer.js
|
|
2775
|
+
var arrayBufferTag5 = "[object ArrayBuffer]";
|
|
2776
|
+
function baseIsArrayBuffer(value) {
|
|
2777
|
+
return isObjectLike_default(value) && baseGetTag_default(value) == arrayBufferTag5;
|
|
2778
|
+
}
|
|
2779
|
+
var baseIsArrayBuffer_default = baseIsArrayBuffer;
|
|
2780
|
+
|
|
2781
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isArrayBuffer.js
|
|
2782
|
+
var nodeIsArrayBuffer = nodeUtil_default && nodeUtil_default.isArrayBuffer;
|
|
2783
|
+
var isArrayBuffer = nodeIsArrayBuffer ? baseUnary_default(nodeIsArrayBuffer) : baseIsArrayBuffer_default;
|
|
2784
|
+
var isArrayBuffer_default = isArrayBuffer;
|
|
2785
|
+
|
|
2888
2786
|
// ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isBoolean.js
|
|
2889
2787
|
var boolTag5 = "[object Boolean]";
|
|
2890
2788
|
function isBoolean(value) {
|
|
@@ -2904,6 +2802,12 @@ var nodeIsDate = nodeUtil_default && nodeUtil_default.isDate;
|
|
|
2904
2802
|
var isDate = nodeIsDate ? baseUnary_default(nodeIsDate) : baseIsDate_default;
|
|
2905
2803
|
var isDate_default = isDate;
|
|
2906
2804
|
|
|
2805
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isElement.js
|
|
2806
|
+
function isElement(value) {
|
|
2807
|
+
return isObjectLike_default(value) && value.nodeType === 1 && !isPlainObject_default(value);
|
|
2808
|
+
}
|
|
2809
|
+
var isElement_default = isElement;
|
|
2810
|
+
|
|
2907
2811
|
// ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isEmpty.js
|
|
2908
2812
|
var mapTag7 = "[object Map]";
|
|
2909
2813
|
var setTag7 = "[object Set]";
|
|
@@ -2938,6 +2842,33 @@ function isEqual(value, other) {
|
|
|
2938
2842
|
}
|
|
2939
2843
|
var isEqual_default = isEqual;
|
|
2940
2844
|
|
|
2845
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isEqualWith.js
|
|
2846
|
+
function isEqualWith(value, other, customizer) {
|
|
2847
|
+
customizer = typeof customizer == "function" ? customizer : void 0;
|
|
2848
|
+
var result = customizer ? customizer(value, other) : void 0;
|
|
2849
|
+
return result === void 0 ? baseIsEqual_default(value, other, void 0, customizer) : !!result;
|
|
2850
|
+
}
|
|
2851
|
+
var isEqualWith_default = isEqualWith;
|
|
2852
|
+
|
|
2853
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isInteger.js
|
|
2854
|
+
function isInteger(value) {
|
|
2855
|
+
return typeof value == "number" && value == toInteger_default(value);
|
|
2856
|
+
}
|
|
2857
|
+
var isInteger_default = isInteger;
|
|
2858
|
+
|
|
2859
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isMatch.js
|
|
2860
|
+
function isMatch(object, source) {
|
|
2861
|
+
return object === source || baseIsMatch_default(object, source, getMatchData_default(source));
|
|
2862
|
+
}
|
|
2863
|
+
var isMatch_default = isMatch;
|
|
2864
|
+
|
|
2865
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isMatchWith.js
|
|
2866
|
+
function isMatchWith(object, source, customizer) {
|
|
2867
|
+
customizer = typeof customizer == "function" ? customizer : void 0;
|
|
2868
|
+
return baseIsMatch_default(object, source, getMatchData_default(source), customizer);
|
|
2869
|
+
}
|
|
2870
|
+
var isMatchWith_default = isMatchWith;
|
|
2871
|
+
|
|
2941
2872
|
// ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isNumber.js
|
|
2942
2873
|
var numberTag5 = "[object Number]";
|
|
2943
2874
|
function isNumber(value) {
|
|
@@ -2989,6 +2920,20 @@ function isUndefined(value) {
|
|
|
2989
2920
|
}
|
|
2990
2921
|
var isUndefined_default = isUndefined;
|
|
2991
2922
|
|
|
2923
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isWeakMap.js
|
|
2924
|
+
var weakMapTag4 = "[object WeakMap]";
|
|
2925
|
+
function isWeakMap(value) {
|
|
2926
|
+
return isObjectLike_default(value) && getTag_default(value) == weakMapTag4;
|
|
2927
|
+
}
|
|
2928
|
+
var isWeakMap_default = isWeakMap;
|
|
2929
|
+
|
|
2930
|
+
// ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/isWeakSet.js
|
|
2931
|
+
var weakSetTag = "[object WeakSet]";
|
|
2932
|
+
function isWeakSet(value) {
|
|
2933
|
+
return isObjectLike_default(value) && baseGetTag_default(value) == weakSetTag;
|
|
2934
|
+
}
|
|
2935
|
+
var isWeakSet_default = isWeakSet;
|
|
2936
|
+
|
|
2992
2937
|
// ../../node_modules/.pnpm/lodash-es@4.17.21/node_modules/lodash-es/join.js
|
|
2993
2938
|
var arrayProto2 = Array.prototype;
|
|
2994
2939
|
var nativeJoin = arrayProto2.join;
|
|
@@ -3166,6 +3111,161 @@ function uniqWith(array, comparator) {
|
|
|
3166
3111
|
}
|
|
3167
3112
|
var uniqWith_default = uniqWith;
|
|
3168
3113
|
|
|
3114
|
+
// src/is/index.ts
|
|
3115
|
+
var isBrowser = () => typeof window !== "undefined";
|
|
3116
|
+
var isWeex = () => typeof WXEnvironment !== "undefined" && !!WXEnvironment.platform;
|
|
3117
|
+
var weexPlatform = () => isWeex() && WXEnvironment.platform.toLowerCase();
|
|
3118
|
+
var UA = () => isBrowser() && window.navigator.userAgent.toLowerCase() || "";
|
|
3119
|
+
var isIE = () => UA() && /msie|trident/.test(UA());
|
|
3120
|
+
var isIE9 = () => UA() && UA().indexOf("msie 9.0") > 0;
|
|
3121
|
+
var isIE11 = () => isBrowser() && navigator.userAgent.includes("Trident") && navigator.userAgent.includes("rv:11.0");
|
|
3122
|
+
var isEdge = () => UA() && UA().indexOf("edge/") > 0;
|
|
3123
|
+
var isAndroid = () => UA() && UA().indexOf("android") > 0 || weexPlatform() === "android";
|
|
3124
|
+
var isIOS = () => UA() && /iphone|ipad|ipod|ios/.test(UA()) || weexPlatform() === "ios";
|
|
3125
|
+
var isChrome = () => UA() && /chrome\/\d+/.test(UA()) && !isEdge();
|
|
3126
|
+
var isPhantomJS = () => UA() && /phantomjs/.test(UA());
|
|
3127
|
+
var isFF = () => typeof UA() === "string" && UA().match(/firefox\/(\d+)/);
|
|
3128
|
+
var isMobile = () => isBrowser() && navigator.userAgent.toLowerCase().includes("mobile");
|
|
3129
|
+
var isFormData = (value) => isObject_default(value) && isBrowser() && value instanceof FormData;
|
|
3130
|
+
var isWindow = (value) => typeof window !== "undefined" && toString.call(value) === "[object Window]";
|
|
3131
|
+
var isTruthy = (value) => Boolean(value);
|
|
3132
|
+
|
|
3133
|
+
// ../../node_modules/.pnpm/change-case@5.4.4/node_modules/change-case/dist/index.js
|
|
3134
|
+
var SPLIT_LOWER_UPPER_RE = /([\p{Ll}\d])(\p{Lu})/gu;
|
|
3135
|
+
var SPLIT_UPPER_UPPER_RE = /(\p{Lu})([\p{Lu}][\p{Ll}])/gu;
|
|
3136
|
+
var SPLIT_SEPARATE_NUMBER_RE = /(\d)\p{Ll}|(\p{L})\d/u;
|
|
3137
|
+
var DEFAULT_STRIP_REGEXP = /[^\p{L}\d]+/giu;
|
|
3138
|
+
var SPLIT_REPLACE_VALUE = "$1\0$2";
|
|
3139
|
+
var DEFAULT_PREFIX_SUFFIX_CHARACTERS = "";
|
|
3140
|
+
function split(value) {
|
|
3141
|
+
let result = value.trim();
|
|
3142
|
+
result = result.replace(SPLIT_LOWER_UPPER_RE, SPLIT_REPLACE_VALUE).replace(SPLIT_UPPER_UPPER_RE, SPLIT_REPLACE_VALUE);
|
|
3143
|
+
result = result.replace(DEFAULT_STRIP_REGEXP, "\0");
|
|
3144
|
+
let start = 0;
|
|
3145
|
+
let end = result.length;
|
|
3146
|
+
while (result.charAt(start) === "\0")
|
|
3147
|
+
start++;
|
|
3148
|
+
if (start === end)
|
|
3149
|
+
return [];
|
|
3150
|
+
while (result.charAt(end - 1) === "\0")
|
|
3151
|
+
end--;
|
|
3152
|
+
return result.slice(start, end).split(/\0/g);
|
|
3153
|
+
}
|
|
3154
|
+
function splitSeparateNumbers(value) {
|
|
3155
|
+
const words = split(value);
|
|
3156
|
+
for (let i = 0; i < words.length; i++) {
|
|
3157
|
+
const word = words[i];
|
|
3158
|
+
const match = SPLIT_SEPARATE_NUMBER_RE.exec(word);
|
|
3159
|
+
if (match) {
|
|
3160
|
+
const offset = match.index + (match[1] ?? match[2]).length;
|
|
3161
|
+
words.splice(i, 1, word.slice(0, offset), word.slice(offset));
|
|
3162
|
+
}
|
|
3163
|
+
}
|
|
3164
|
+
return words;
|
|
3165
|
+
}
|
|
3166
|
+
function noCase(input, options) {
|
|
3167
|
+
const [prefix, words, suffix] = splitPrefixSuffix(input, options);
|
|
3168
|
+
return prefix + words.map(lowerFactory(options?.locale)).join(options?.delimiter ?? " ") + suffix;
|
|
3169
|
+
}
|
|
3170
|
+
function camelCase(input, options) {
|
|
3171
|
+
const [prefix, words, suffix] = splitPrefixSuffix(input, options);
|
|
3172
|
+
const lower = lowerFactory(options?.locale);
|
|
3173
|
+
const upper = upperFactory(options?.locale);
|
|
3174
|
+
const transform = options?.mergeAmbiguousCharacters ? capitalCaseTransformFactory(lower, upper) : pascalCaseTransformFactory(lower, upper);
|
|
3175
|
+
return prefix + words.map((word, index) => {
|
|
3176
|
+
if (index === 0)
|
|
3177
|
+
return lower(word);
|
|
3178
|
+
return transform(word, index);
|
|
3179
|
+
}).join(options?.delimiter ?? "") + suffix;
|
|
3180
|
+
}
|
|
3181
|
+
function pascalCase(input, options) {
|
|
3182
|
+
const [prefix, words, suffix] = splitPrefixSuffix(input, options);
|
|
3183
|
+
const lower = lowerFactory(options?.locale);
|
|
3184
|
+
const upper = upperFactory(options?.locale);
|
|
3185
|
+
const transform = options?.mergeAmbiguousCharacters ? capitalCaseTransformFactory(lower, upper) : pascalCaseTransformFactory(lower, upper);
|
|
3186
|
+
return prefix + words.map(transform).join(options?.delimiter ?? "") + suffix;
|
|
3187
|
+
}
|
|
3188
|
+
function pascalSnakeCase(input, options) {
|
|
3189
|
+
return capitalCase(input, { delimiter: "_", ...options });
|
|
3190
|
+
}
|
|
3191
|
+
function capitalCase(input, options) {
|
|
3192
|
+
const [prefix, words, suffix] = splitPrefixSuffix(input, options);
|
|
3193
|
+
const lower = lowerFactory(options?.locale);
|
|
3194
|
+
const upper = upperFactory(options?.locale);
|
|
3195
|
+
return prefix + words.map(capitalCaseTransformFactory(lower, upper)).join(options?.delimiter ?? " ") + suffix;
|
|
3196
|
+
}
|
|
3197
|
+
function constantCase(input, options) {
|
|
3198
|
+
const [prefix, words, suffix] = splitPrefixSuffix(input, options);
|
|
3199
|
+
return prefix + words.map(upperFactory(options?.locale)).join(options?.delimiter ?? "_") + suffix;
|
|
3200
|
+
}
|
|
3201
|
+
function dotCase(input, options) {
|
|
3202
|
+
return noCase(input, { delimiter: ".", ...options });
|
|
3203
|
+
}
|
|
3204
|
+
function kebabCase(input, options) {
|
|
3205
|
+
return noCase(input, { delimiter: "-", ...options });
|
|
3206
|
+
}
|
|
3207
|
+
function pathCase(input, options) {
|
|
3208
|
+
return noCase(input, { delimiter: "/", ...options });
|
|
3209
|
+
}
|
|
3210
|
+
function sentenceCase(input, options) {
|
|
3211
|
+
const [prefix, words, suffix] = splitPrefixSuffix(input, options);
|
|
3212
|
+
const lower = lowerFactory(options?.locale);
|
|
3213
|
+
const upper = upperFactory(options?.locale);
|
|
3214
|
+
const transform = capitalCaseTransformFactory(lower, upper);
|
|
3215
|
+
return prefix + words.map((word, index) => {
|
|
3216
|
+
if (index === 0)
|
|
3217
|
+
return transform(word);
|
|
3218
|
+
return lower(word);
|
|
3219
|
+
}).join(options?.delimiter ?? " ") + suffix;
|
|
3220
|
+
}
|
|
3221
|
+
function snakeCase(input, options) {
|
|
3222
|
+
return noCase(input, { delimiter: "_", ...options });
|
|
3223
|
+
}
|
|
3224
|
+
function trainCase(input, options) {
|
|
3225
|
+
return capitalCase(input, { delimiter: "-", ...options });
|
|
3226
|
+
}
|
|
3227
|
+
function lowerFactory(locale) {
|
|
3228
|
+
return locale === false ? (input) => input.toLowerCase() : (input) => input.toLocaleLowerCase(locale);
|
|
3229
|
+
}
|
|
3230
|
+
function upperFactory(locale) {
|
|
3231
|
+
return locale === false ? (input) => input.toUpperCase() : (input) => input.toLocaleUpperCase(locale);
|
|
3232
|
+
}
|
|
3233
|
+
function capitalCaseTransformFactory(lower, upper) {
|
|
3234
|
+
return (word) => `${upper(word[0])}${lower(word.slice(1))}`;
|
|
3235
|
+
}
|
|
3236
|
+
function pascalCaseTransformFactory(lower, upper) {
|
|
3237
|
+
return (word, index) => {
|
|
3238
|
+
const char0 = word[0];
|
|
3239
|
+
const initial = index > 0 && char0 >= "0" && char0 <= "9" ? "_" + char0 : upper(char0);
|
|
3240
|
+
return initial + lower(word.slice(1));
|
|
3241
|
+
};
|
|
3242
|
+
}
|
|
3243
|
+
function splitPrefixSuffix(input, options = {}) {
|
|
3244
|
+
const splitFn = options.split ?? (options.separateNumbers ? splitSeparateNumbers : split);
|
|
3245
|
+
const prefixCharacters = options.prefixCharacters ?? DEFAULT_PREFIX_SUFFIX_CHARACTERS;
|
|
3246
|
+
const suffixCharacters = options.suffixCharacters ?? DEFAULT_PREFIX_SUFFIX_CHARACTERS;
|
|
3247
|
+
let prefixIndex = 0;
|
|
3248
|
+
let suffixIndex = input.length;
|
|
3249
|
+
while (prefixIndex < input.length) {
|
|
3250
|
+
const char = input.charAt(prefixIndex);
|
|
3251
|
+
if (!prefixCharacters.includes(char))
|
|
3252
|
+
break;
|
|
3253
|
+
prefixIndex++;
|
|
3254
|
+
}
|
|
3255
|
+
while (suffixIndex > prefixIndex) {
|
|
3256
|
+
const index = suffixIndex - 1;
|
|
3257
|
+
const char = input.charAt(index);
|
|
3258
|
+
if (!suffixCharacters.includes(char))
|
|
3259
|
+
break;
|
|
3260
|
+
suffixIndex = index;
|
|
3261
|
+
}
|
|
3262
|
+
return [
|
|
3263
|
+
input.slice(0, prefixIndex),
|
|
3264
|
+
splitFn(input.slice(prefixIndex, suffixIndex)),
|
|
3265
|
+
input.slice(suffixIndex)
|
|
3266
|
+
];
|
|
3267
|
+
}
|
|
3268
|
+
|
|
3169
3269
|
// src/number/index.ts
|
|
3170
3270
|
var import_bignumber = __toESM(require("bignumber.js"), 1);
|
|
3171
3271
|
var BIG_INTS = {
|
|
@@ -3296,6 +3396,51 @@ function formatSize(dimension, unit) {
|
|
|
3296
3396
|
function cover(value, mode, symbol = "*") {
|
|
3297
3397
|
return value.slice(0, mode[0]) + symbol.repeat(mode[1]) + value.slice(-mode[2]);
|
|
3298
3398
|
}
|
|
3399
|
+
function slash(str) {
|
|
3400
|
+
return str.replace(/\\/g, "/");
|
|
3401
|
+
}
|
|
3402
|
+
function ensurePrefix(prefix, str) {
|
|
3403
|
+
if (!str.startsWith(prefix))
|
|
3404
|
+
return prefix + str;
|
|
3405
|
+
return str;
|
|
3406
|
+
}
|
|
3407
|
+
function ensureSuffix(suffix, str) {
|
|
3408
|
+
if (!str.endsWith(suffix))
|
|
3409
|
+
return str + suffix;
|
|
3410
|
+
return str;
|
|
3411
|
+
}
|
|
3412
|
+
function template(str, ...args) {
|
|
3413
|
+
const [firstArg, fallback] = args;
|
|
3414
|
+
if (isObject_default(firstArg)) {
|
|
3415
|
+
const vars = firstArg;
|
|
3416
|
+
return str.replace(/\{(\w+)\}/g, (_, key) => vars[key] || ((typeof fallback === "function" ? fallback(key) : fallback) ?? key));
|
|
3417
|
+
} else {
|
|
3418
|
+
return str.replace(/\{(\d+)\}/g, (_, key) => {
|
|
3419
|
+
const index = Number(key);
|
|
3420
|
+
if (Number.isNaN(index))
|
|
3421
|
+
return key;
|
|
3422
|
+
return args[index];
|
|
3423
|
+
});
|
|
3424
|
+
}
|
|
3425
|
+
}
|
|
3426
|
+
var _reFullWs = /^\s*$/;
|
|
3427
|
+
function unindent(str) {
|
|
3428
|
+
const lines = (typeof str === "string" ? str : str[0]).split("\n");
|
|
3429
|
+
const whitespaceLines = lines.map((line) => _reFullWs.test(line));
|
|
3430
|
+
const commonIndent = lines.reduce((min, line, idx) => {
|
|
3431
|
+
if (whitespaceLines[idx])
|
|
3432
|
+
return min;
|
|
3433
|
+
const indent = line.match(/^\s*/)?.[0].length;
|
|
3434
|
+
return indent === void 0 ? min : Math.min(min, indent);
|
|
3435
|
+
}, Number.POSITIVE_INFINITY);
|
|
3436
|
+
let emptyLinesHead = 0;
|
|
3437
|
+
while (emptyLinesHead < lines.length && whitespaceLines[emptyLinesHead])
|
|
3438
|
+
emptyLinesHead++;
|
|
3439
|
+
let emptyLinesTail = 0;
|
|
3440
|
+
while (emptyLinesTail < lines.length && whitespaceLines[lines.length - emptyLinesTail - 1])
|
|
3441
|
+
emptyLinesTail++;
|
|
3442
|
+
return lines.slice(emptyLinesHead, lines.length - emptyLinesTail).map((line) => line.slice(commonIndent)).join("\n");
|
|
3443
|
+
}
|
|
3299
3444
|
|
|
3300
3445
|
// src/typeof/index.ts
|
|
3301
3446
|
function getTypeof(target) {
|
|
@@ -3366,25 +3511,6 @@ function delay(ms) {
|
|
|
3366
3511
|
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
3367
3512
|
}
|
|
3368
3513
|
|
|
3369
|
-
// src/util/is.ts
|
|
3370
|
-
var isBrowser = () => typeof window !== "undefined";
|
|
3371
|
-
var isWeex = () => typeof WXEnvironment !== "undefined" && !!WXEnvironment.platform;
|
|
3372
|
-
var weexPlatform = () => isWeex() && WXEnvironment.platform.toLowerCase();
|
|
3373
|
-
var UA = () => isBrowser() && window.navigator.userAgent.toLowerCase() || "";
|
|
3374
|
-
var isIE = () => UA() && /msie|trident/.test(UA());
|
|
3375
|
-
var isIE9 = () => UA() && UA().indexOf("msie 9.0") > 0;
|
|
3376
|
-
var isIE11 = () => isBrowser() && navigator.userAgent.includes("Trident") && navigator.userAgent.includes("rv:11.0");
|
|
3377
|
-
var isEdge = () => UA() && UA().indexOf("edge/") > 0;
|
|
3378
|
-
var isAndroid = () => UA() && UA().indexOf("android") > 0 || weexPlatform() === "android";
|
|
3379
|
-
var isIOS = () => UA() && /iphone|ipad|ipod|ios/.test(UA()) || weexPlatform() === "ios";
|
|
3380
|
-
var isChrome = () => UA() && /chrome\/\d+/.test(UA()) && !isEdge();
|
|
3381
|
-
var isPhantomJS = () => UA() && /phantomjs/.test(UA());
|
|
3382
|
-
var isFF = () => typeof UA() === "string" && UA().match(/firefox\/(\d+)/);
|
|
3383
|
-
var isMobile = () => isBrowser() && navigator.userAgent.toLowerCase().includes("mobile");
|
|
3384
|
-
var isFormData = (value) => isObject_default(value) && isBrowser() && value instanceof FormData;
|
|
3385
|
-
var isWindow = (value) => typeof window !== "undefined" && toString.call(value) === "[object Window]";
|
|
3386
|
-
var isTruthy = (value) => Boolean(value);
|
|
3387
|
-
|
|
3388
3514
|
// src/util/json.ts
|
|
3389
3515
|
function jsonTryParse(text) {
|
|
3390
3516
|
try {
|
|
@@ -3467,12 +3593,21 @@ proxy.resolve = (target) => {
|
|
|
3467
3593
|
};
|
|
3468
3594
|
|
|
3469
3595
|
// src/util/random.ts
|
|
3470
|
-
function randomNumer(min, max) {
|
|
3471
|
-
return Math.random() * (max - min) + min;
|
|
3472
|
-
}
|
|
3473
3596
|
function randomArray(array) {
|
|
3474
3597
|
return array[Math.floor(Math.random() * array.length)];
|
|
3475
3598
|
}
|
|
3599
|
+
function randomNumber(min, max) {
|
|
3600
|
+
return Math.random() * (max - min) + min;
|
|
3601
|
+
}
|
|
3602
|
+
var urlAlphabet = "useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";
|
|
3603
|
+
function randomString(size, chars = urlAlphabet) {
|
|
3604
|
+
let id = "";
|
|
3605
|
+
let i = size;
|
|
3606
|
+
const len = chars.length;
|
|
3607
|
+
while (i--)
|
|
3608
|
+
id += chars[Math.random() * len | 0];
|
|
3609
|
+
return id;
|
|
3610
|
+
}
|
|
3476
3611
|
|
|
3477
3612
|
// src/util/to.ts
|
|
3478
3613
|
async function to(promise, error) {
|
|
@@ -3535,6 +3670,8 @@ function call(fn, ...args) {
|
|
|
3535
3670
|
dotCase,
|
|
3536
3671
|
downloadBlobFile,
|
|
3537
3672
|
downloadNetworkFile,
|
|
3673
|
+
ensurePrefix,
|
|
3674
|
+
ensureSuffix,
|
|
3538
3675
|
find,
|
|
3539
3676
|
formToObject,
|
|
3540
3677
|
formatNumeric,
|
|
@@ -3546,15 +3683,21 @@ function call(fn, ...args) {
|
|
|
3546
3683
|
gte,
|
|
3547
3684
|
integer,
|
|
3548
3685
|
isAndroid,
|
|
3686
|
+
isArguments,
|
|
3549
3687
|
isArray,
|
|
3688
|
+
isArrayBuffer,
|
|
3550
3689
|
isArrayLike,
|
|
3690
|
+
isArrayLikeObject,
|
|
3551
3691
|
isBoolean,
|
|
3552
3692
|
isBrowser,
|
|
3693
|
+
isBuffer,
|
|
3553
3694
|
isChrome,
|
|
3554
3695
|
isDate,
|
|
3555
3696
|
isEdge,
|
|
3697
|
+
isElement,
|
|
3556
3698
|
isEmpty,
|
|
3557
3699
|
isEqual,
|
|
3700
|
+
isEqualWith,
|
|
3558
3701
|
isError,
|
|
3559
3702
|
isFF,
|
|
3560
3703
|
isFormData,
|
|
@@ -3563,18 +3706,28 @@ function call(fn, ...args) {
|
|
|
3563
3706
|
isIE11,
|
|
3564
3707
|
isIE9,
|
|
3565
3708
|
isIOS,
|
|
3709
|
+
isInteger,
|
|
3710
|
+
isMap,
|
|
3711
|
+
isMatch,
|
|
3712
|
+
isMatchWith,
|
|
3566
3713
|
isMobile,
|
|
3567
3714
|
isNaN,
|
|
3568
3715
|
isNative,
|
|
3569
3716
|
isNull,
|
|
3570
3717
|
isNumber,
|
|
3571
3718
|
isObject,
|
|
3719
|
+
isObjectLike,
|
|
3572
3720
|
isPhantomJS,
|
|
3573
3721
|
isPlainObject,
|
|
3722
|
+
isRegexp,
|
|
3723
|
+
isSet,
|
|
3574
3724
|
isString,
|
|
3725
|
+
isSymbol,
|
|
3575
3726
|
isTruthy,
|
|
3576
3727
|
isTypeof,
|
|
3577
3728
|
isUndefined,
|
|
3729
|
+
isWeakMap,
|
|
3730
|
+
isWeakSet,
|
|
3578
3731
|
isWeex,
|
|
3579
3732
|
isWindow,
|
|
3580
3733
|
join,
|
|
@@ -3601,7 +3754,8 @@ function call(fn, ...args) {
|
|
|
3601
3754
|
plus,
|
|
3602
3755
|
proxy,
|
|
3603
3756
|
randomArray,
|
|
3604
|
-
|
|
3757
|
+
randomNumber,
|
|
3758
|
+
randomString,
|
|
3605
3759
|
readFileReader,
|
|
3606
3760
|
redirectTo,
|
|
3607
3761
|
riposte,
|
|
@@ -3609,10 +3763,13 @@ function call(fn, ...args) {
|
|
|
3609
3763
|
sentenceCase,
|
|
3610
3764
|
showOpenFilePicker,
|
|
3611
3765
|
showOpenImagePicker,
|
|
3766
|
+
slash,
|
|
3612
3767
|
snakeCase,
|
|
3768
|
+
template,
|
|
3613
3769
|
to,
|
|
3614
3770
|
trainCase,
|
|
3615
3771
|
truncate,
|
|
3772
|
+
unindent,
|
|
3616
3773
|
uniq,
|
|
3617
3774
|
uniqBy,
|
|
3618
3775
|
uniqWith,
|