@ntnyq/utils 0.3.2 → 0.4.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 +212 -21
- package/dist/index.d.cts +90 -15
- package/dist/index.d.ts +90 -15
- package/dist/index.js +192 -97
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -15,7 +15,6 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
15
15
|
}
|
|
16
16
|
return to;
|
|
17
17
|
};
|
|
18
|
-
var __reExport = (target, mod, secondTarget) => (__copyProps(target, mod, "default"), secondTarget && __copyProps(secondTarget, mod, "default"));
|
|
19
18
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
20
19
|
|
|
21
20
|
// src/index.ts
|
|
@@ -24,13 +23,17 @@ __export(src_exports, {
|
|
|
24
23
|
NOOP: () => NOOP,
|
|
25
24
|
at: () => at,
|
|
26
25
|
cAF: () => cAF,
|
|
26
|
+
camelCase: () => camelCase,
|
|
27
27
|
capitalize: () => capitalize,
|
|
28
28
|
chunk: () => chunk,
|
|
29
29
|
clamp: () => clamp,
|
|
30
|
+
cleanObject: () => cleanObject,
|
|
30
31
|
days: () => days,
|
|
31
32
|
debounce: () => debounce,
|
|
32
33
|
ensurePrefix: () => ensurePrefix,
|
|
33
34
|
ensureSuffix: () => ensureSuffix,
|
|
35
|
+
escapeHtml: () => escapeHtml,
|
|
36
|
+
flatCase: () => flatCase,
|
|
34
37
|
flattenArrayable: () => flattenArrayable,
|
|
35
38
|
getObjectType: () => getObjectType,
|
|
36
39
|
hasOwn: () => hasOwn,
|
|
@@ -39,10 +42,14 @@ __export(src_exports, {
|
|
|
39
42
|
isArrayEqual: () => isArrayEqual,
|
|
40
43
|
isBoolean: () => isBoolean,
|
|
41
44
|
isBrowser: () => isBrowser,
|
|
45
|
+
isDeepEqual: () => isDeepEqual,
|
|
46
|
+
isEmptyArray: () => isEmptyArray,
|
|
47
|
+
isEmptyObject: () => isEmptyObject,
|
|
42
48
|
isEmptyString: () => isEmptyString,
|
|
43
49
|
isEmptyStringOrWhitespace: () => isEmptyStringOrWhitespace,
|
|
44
50
|
isFunction: () => isFunction,
|
|
45
51
|
isInteger: () => isInteger,
|
|
52
|
+
isNaN: () => isNaN,
|
|
46
53
|
isNativePromise: () => isNativePromise,
|
|
47
54
|
isNil: () => isNil,
|
|
48
55
|
isNonEmptyString: () => isNonEmptyString,
|
|
@@ -55,40 +62,88 @@ __export(src_exports, {
|
|
|
55
62
|
isSet: () => isSet,
|
|
56
63
|
isString: () => isString,
|
|
57
64
|
isUndefined: () => isUndefined,
|
|
65
|
+
isUppercase: () => isUppercase,
|
|
58
66
|
isWhitespaceString: () => isWhitespaceString,
|
|
67
|
+
isZero: () => isZero,
|
|
59
68
|
join: () => join,
|
|
69
|
+
kebabCase: () => kebabCase,
|
|
60
70
|
last: () => last,
|
|
71
|
+
lowerFirst: () => lowerFirst,
|
|
61
72
|
mergeArrayable: () => mergeArrayable,
|
|
62
73
|
minutes: () => minutes,
|
|
63
74
|
noop: () => noop,
|
|
64
75
|
omit: () => omit,
|
|
65
76
|
once: () => once,
|
|
77
|
+
pascalCase: () => pascalCase,
|
|
66
78
|
pick: () => pick,
|
|
67
79
|
rAF: () => rAF,
|
|
68
80
|
seconds: () => seconds,
|
|
69
81
|
slash: () => slash,
|
|
82
|
+
snakeCase: () => snakeCase,
|
|
70
83
|
sortObject: () => sortObject,
|
|
84
|
+
splitByCase: () => splitByCase,
|
|
71
85
|
throttle: () => throttle,
|
|
86
|
+
titleCase: () => titleCase,
|
|
72
87
|
toArray: () => toArray,
|
|
88
|
+
trainCase: () => trainCase,
|
|
73
89
|
unindent: () => unindent,
|
|
74
90
|
unique: () => unique,
|
|
75
91
|
uniqueBy: () => uniqueBy,
|
|
92
|
+
upperFirst: () => upperFirst,
|
|
76
93
|
waitFor: () => waitFor,
|
|
77
94
|
warnOnce: () => warnOnce,
|
|
78
95
|
weeks: () => weeks
|
|
79
96
|
});
|
|
80
97
|
module.exports = __toCommonJS(src_exports);
|
|
81
98
|
|
|
99
|
+
// src/is/isDeepEqual.ts
|
|
100
|
+
function isDeepEqual(value1, value2) {
|
|
101
|
+
const type1 = getObjectType(value1);
|
|
102
|
+
const type2 = getObjectType(value2);
|
|
103
|
+
if (type1 !== type2) {
|
|
104
|
+
return false;
|
|
105
|
+
}
|
|
106
|
+
if (isArray(value1)) {
|
|
107
|
+
if (value1.length !== value2.length) {
|
|
108
|
+
return false;
|
|
109
|
+
}
|
|
110
|
+
return value1.every((item, index) => isDeepEqual(item, value2[index]));
|
|
111
|
+
}
|
|
112
|
+
if (isObject(value1)) {
|
|
113
|
+
const keys = Object.keys(value1);
|
|
114
|
+
if (keys.length !== Object.keys(value2).length) {
|
|
115
|
+
return false;
|
|
116
|
+
}
|
|
117
|
+
return keys.every((key) => isDeepEqual(value1[key], value2[key]));
|
|
118
|
+
}
|
|
119
|
+
return Object.is(value1, value2);
|
|
120
|
+
}
|
|
121
|
+
|
|
82
122
|
// src/is/index.ts
|
|
83
123
|
function getObjectType(value) {
|
|
84
124
|
return Object.prototype.toString.call(value).slice(8, -1);
|
|
85
125
|
}
|
|
126
|
+
function isUndefined(value) {
|
|
127
|
+
return value === void 0;
|
|
128
|
+
}
|
|
129
|
+
function isNull(value) {
|
|
130
|
+
return value === null;
|
|
131
|
+
}
|
|
132
|
+
function isNil(value) {
|
|
133
|
+
return isNull(value) || isUndefined(value);
|
|
134
|
+
}
|
|
86
135
|
function isString(value) {
|
|
87
136
|
return typeof value === "string";
|
|
88
137
|
}
|
|
89
138
|
function isNumber(value) {
|
|
90
139
|
return typeof value === "number";
|
|
91
140
|
}
|
|
141
|
+
function isZero(value) {
|
|
142
|
+
return value === 0;
|
|
143
|
+
}
|
|
144
|
+
function isNaN(value) {
|
|
145
|
+
return Number.isNaN(value);
|
|
146
|
+
}
|
|
92
147
|
function isEmptyString(value) {
|
|
93
148
|
return isString(value) && value.length === 0;
|
|
94
149
|
}
|
|
@@ -116,18 +171,15 @@ function isFunction(value) {
|
|
|
116
171
|
function isArray(value) {
|
|
117
172
|
return Array.isArray(value);
|
|
118
173
|
}
|
|
119
|
-
function
|
|
120
|
-
return value ===
|
|
121
|
-
}
|
|
122
|
-
function isNull(value) {
|
|
123
|
-
return value === null;
|
|
124
|
-
}
|
|
125
|
-
function isNil(value) {
|
|
126
|
-
return isNull(value) || isUndefined(value);
|
|
174
|
+
function isEmptyArray(value) {
|
|
175
|
+
return isArray(value) && value.length === 0;
|
|
127
176
|
}
|
|
128
177
|
function isObject(value) {
|
|
129
178
|
return getObjectType(value) === "Object";
|
|
130
179
|
}
|
|
180
|
+
function isEmptyObject(value) {
|
|
181
|
+
return isObject(value) && Object.keys(value).length === 0;
|
|
182
|
+
}
|
|
131
183
|
function isRegExp(value) {
|
|
132
184
|
return getObjectType(value) === "RegExp";
|
|
133
185
|
}
|
|
@@ -165,18 +217,6 @@ function once(func) {
|
|
|
165
217
|
// src/env/isBrowser.ts
|
|
166
218
|
var isBrowser = () => typeof document !== "undefined";
|
|
167
219
|
|
|
168
|
-
// src/case.ts
|
|
169
|
-
var case_exports = {};
|
|
170
|
-
__export(case_exports, {
|
|
171
|
-
capitalize: () => capitalize
|
|
172
|
-
});
|
|
173
|
-
var import_scule = require("scule");
|
|
174
|
-
__reExport(case_exports, require("scule"));
|
|
175
|
-
var capitalize = import_scule.upperFirst;
|
|
176
|
-
|
|
177
|
-
// src/index.ts
|
|
178
|
-
__reExport(src_exports, case_exports, module.exports);
|
|
179
|
-
|
|
180
220
|
// src/misc/raf.ts
|
|
181
221
|
var root = isBrowser() ? window : globalThis;
|
|
182
222
|
var prev = Date.now();
|
|
@@ -285,6 +325,11 @@ var warnOnce = (message) => {
|
|
|
285
325
|
console.warn(message);
|
|
286
326
|
};
|
|
287
327
|
|
|
328
|
+
// src/html/escapeHtml.ts
|
|
329
|
+
function escapeHtml(unsafe) {
|
|
330
|
+
return unsafe.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
331
|
+
}
|
|
332
|
+
|
|
288
333
|
// src/array/at.ts
|
|
289
334
|
function at(array, index) {
|
|
290
335
|
const length = array.length;
|
|
@@ -396,6 +441,9 @@ function omit(object, ...keys) {
|
|
|
396
441
|
|
|
397
442
|
// src/object/hasOwn.ts
|
|
398
443
|
function hasOwn(object, key) {
|
|
444
|
+
if (object === null) {
|
|
445
|
+
return false;
|
|
446
|
+
}
|
|
399
447
|
return Object.prototype.hasOwnProperty.call(object, key);
|
|
400
448
|
}
|
|
401
449
|
|
|
@@ -411,6 +459,48 @@ function pick(object, keys) {
|
|
|
411
459
|
);
|
|
412
460
|
}
|
|
413
461
|
|
|
462
|
+
// src/object/clean.ts
|
|
463
|
+
function cleanObject(obj, options = {}) {
|
|
464
|
+
const {
|
|
465
|
+
cleanUndefined = true,
|
|
466
|
+
cleanNull = true,
|
|
467
|
+
cleanZero = false,
|
|
468
|
+
cleanNaN = true,
|
|
469
|
+
cleanEmptyString = true,
|
|
470
|
+
cleanEmptyArray = true,
|
|
471
|
+
cleanEmptyObject = true,
|
|
472
|
+
recursive = true
|
|
473
|
+
} = options;
|
|
474
|
+
Object.keys(obj).forEach((key) => {
|
|
475
|
+
const v = obj[key];
|
|
476
|
+
if (cleanUndefined && isUndefined(v)) {
|
|
477
|
+
delete obj[key];
|
|
478
|
+
}
|
|
479
|
+
if (cleanNull && isNull(v)) {
|
|
480
|
+
delete obj[key];
|
|
481
|
+
}
|
|
482
|
+
if (cleanZero && isZero(v)) {
|
|
483
|
+
delete obj[key];
|
|
484
|
+
}
|
|
485
|
+
if (cleanNaN && isZero(v)) {
|
|
486
|
+
delete obj[key];
|
|
487
|
+
}
|
|
488
|
+
if (cleanEmptyString && isEmptyString(v)) {
|
|
489
|
+
delete obj[key];
|
|
490
|
+
}
|
|
491
|
+
if (cleanEmptyArray && isEmptyArray(v)) {
|
|
492
|
+
delete obj[key];
|
|
493
|
+
}
|
|
494
|
+
if (cleanEmptyObject && isEmptyObject(v)) {
|
|
495
|
+
delete obj[key];
|
|
496
|
+
}
|
|
497
|
+
if (recursive && isObject(v)) {
|
|
498
|
+
cleanObject(v, options);
|
|
499
|
+
}
|
|
500
|
+
});
|
|
501
|
+
return obj;
|
|
502
|
+
}
|
|
503
|
+
|
|
414
504
|
// src/object/isPlainObject.ts
|
|
415
505
|
function isPlainObject(value) {
|
|
416
506
|
if (!isObject(value)) return false;
|
|
@@ -441,18 +531,105 @@ function sortObject(obj, options = {}) {
|
|
|
441
531
|
}
|
|
442
532
|
return sortKeys(obj);
|
|
443
533
|
}
|
|
534
|
+
|
|
535
|
+
// node_modules/.pnpm/scule@1.3.0/node_modules/scule/dist/index.mjs
|
|
536
|
+
var NUMBER_CHAR_RE = /\d/;
|
|
537
|
+
var STR_SPLITTERS = ["-", "_", "/", "."];
|
|
538
|
+
function isUppercase(char = "") {
|
|
539
|
+
if (NUMBER_CHAR_RE.test(char)) {
|
|
540
|
+
return void 0;
|
|
541
|
+
}
|
|
542
|
+
return char !== char.toLowerCase();
|
|
543
|
+
}
|
|
544
|
+
function splitByCase(str, separators) {
|
|
545
|
+
const splitters = separators ?? STR_SPLITTERS;
|
|
546
|
+
const parts = [];
|
|
547
|
+
if (!str || typeof str !== "string") {
|
|
548
|
+
return parts;
|
|
549
|
+
}
|
|
550
|
+
let buff = "";
|
|
551
|
+
let previousUpper;
|
|
552
|
+
let previousSplitter;
|
|
553
|
+
for (const char of str) {
|
|
554
|
+
const isSplitter = splitters.includes(char);
|
|
555
|
+
if (isSplitter === true) {
|
|
556
|
+
parts.push(buff);
|
|
557
|
+
buff = "";
|
|
558
|
+
previousUpper = void 0;
|
|
559
|
+
continue;
|
|
560
|
+
}
|
|
561
|
+
const isUpper = isUppercase(char);
|
|
562
|
+
if (previousSplitter === false) {
|
|
563
|
+
if (previousUpper === false && isUpper === true) {
|
|
564
|
+
parts.push(buff);
|
|
565
|
+
buff = char;
|
|
566
|
+
previousUpper = isUpper;
|
|
567
|
+
continue;
|
|
568
|
+
}
|
|
569
|
+
if (previousUpper === true && isUpper === false && buff.length > 1) {
|
|
570
|
+
const lastChar = buff.at(-1);
|
|
571
|
+
parts.push(buff.slice(0, Math.max(0, buff.length - 1)));
|
|
572
|
+
buff = lastChar + char;
|
|
573
|
+
previousUpper = isUpper;
|
|
574
|
+
continue;
|
|
575
|
+
}
|
|
576
|
+
}
|
|
577
|
+
buff += char;
|
|
578
|
+
previousUpper = isUpper;
|
|
579
|
+
previousSplitter = isSplitter;
|
|
580
|
+
}
|
|
581
|
+
parts.push(buff);
|
|
582
|
+
return parts;
|
|
583
|
+
}
|
|
584
|
+
function upperFirst(str) {
|
|
585
|
+
return str ? str[0].toUpperCase() + str.slice(1) : "";
|
|
586
|
+
}
|
|
587
|
+
function lowerFirst(str) {
|
|
588
|
+
return str ? str[0].toLowerCase() + str.slice(1) : "";
|
|
589
|
+
}
|
|
590
|
+
function pascalCase(str, opts) {
|
|
591
|
+
return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => upperFirst(opts?.normalize ? p.toLowerCase() : p)).join("") : "";
|
|
592
|
+
}
|
|
593
|
+
function camelCase(str, opts) {
|
|
594
|
+
return lowerFirst(pascalCase(str || "", opts));
|
|
595
|
+
}
|
|
596
|
+
function kebabCase(str, joiner) {
|
|
597
|
+
return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => p.toLowerCase()).join(joiner ?? "-") : "";
|
|
598
|
+
}
|
|
599
|
+
function snakeCase(str) {
|
|
600
|
+
return kebabCase(str || "", "_");
|
|
601
|
+
}
|
|
602
|
+
function flatCase(str) {
|
|
603
|
+
return kebabCase(str || "", "");
|
|
604
|
+
}
|
|
605
|
+
function trainCase(str, opts) {
|
|
606
|
+
return (Array.isArray(str) ? str : splitByCase(str)).filter(Boolean).map((p) => upperFirst(opts?.normalize ? p.toLowerCase() : p)).join("-");
|
|
607
|
+
}
|
|
608
|
+
var titleCaseExceptions = /^(a|an|and|as|at|but|by|for|if|in|is|nor|of|on|or|the|to|with)$/i;
|
|
609
|
+
function titleCase(str, opts) {
|
|
610
|
+
return (Array.isArray(str) ? str : splitByCase(str)).filter(Boolean).map(
|
|
611
|
+
(p) => titleCaseExceptions.test(p) ? p.toLowerCase() : upperFirst(opts?.normalize ? p.toLowerCase() : p)
|
|
612
|
+
).join(" ");
|
|
613
|
+
}
|
|
614
|
+
|
|
615
|
+
// src/vendor/scule.ts
|
|
616
|
+
var capitalize = upperFirst;
|
|
444
617
|
// Annotate the CommonJS export names for ESM import in node:
|
|
445
618
|
0 && (module.exports = {
|
|
446
619
|
NOOP,
|
|
447
620
|
at,
|
|
448
621
|
cAF,
|
|
622
|
+
camelCase,
|
|
449
623
|
capitalize,
|
|
450
624
|
chunk,
|
|
451
625
|
clamp,
|
|
626
|
+
cleanObject,
|
|
452
627
|
days,
|
|
453
628
|
debounce,
|
|
454
629
|
ensurePrefix,
|
|
455
630
|
ensureSuffix,
|
|
631
|
+
escapeHtml,
|
|
632
|
+
flatCase,
|
|
456
633
|
flattenArrayable,
|
|
457
634
|
getObjectType,
|
|
458
635
|
hasOwn,
|
|
@@ -461,10 +638,14 @@ function sortObject(obj, options = {}) {
|
|
|
461
638
|
isArrayEqual,
|
|
462
639
|
isBoolean,
|
|
463
640
|
isBrowser,
|
|
641
|
+
isDeepEqual,
|
|
642
|
+
isEmptyArray,
|
|
643
|
+
isEmptyObject,
|
|
464
644
|
isEmptyString,
|
|
465
645
|
isEmptyStringOrWhitespace,
|
|
466
646
|
isFunction,
|
|
467
647
|
isInteger,
|
|
648
|
+
isNaN,
|
|
468
649
|
isNativePromise,
|
|
469
650
|
isNil,
|
|
470
651
|
isNonEmptyString,
|
|
@@ -477,24 +658,34 @@ function sortObject(obj, options = {}) {
|
|
|
477
658
|
isSet,
|
|
478
659
|
isString,
|
|
479
660
|
isUndefined,
|
|
661
|
+
isUppercase,
|
|
480
662
|
isWhitespaceString,
|
|
663
|
+
isZero,
|
|
481
664
|
join,
|
|
665
|
+
kebabCase,
|
|
482
666
|
last,
|
|
667
|
+
lowerFirst,
|
|
483
668
|
mergeArrayable,
|
|
484
669
|
minutes,
|
|
485
670
|
noop,
|
|
486
671
|
omit,
|
|
487
672
|
once,
|
|
673
|
+
pascalCase,
|
|
488
674
|
pick,
|
|
489
675
|
rAF,
|
|
490
676
|
seconds,
|
|
491
677
|
slash,
|
|
678
|
+
snakeCase,
|
|
492
679
|
sortObject,
|
|
680
|
+
splitByCase,
|
|
493
681
|
throttle,
|
|
682
|
+
titleCase,
|
|
494
683
|
toArray,
|
|
684
|
+
trainCase,
|
|
495
685
|
unindent,
|
|
496
686
|
unique,
|
|
497
687
|
uniqueBy,
|
|
688
|
+
upperFirst,
|
|
498
689
|
waitFor,
|
|
499
690
|
warnOnce,
|
|
500
691
|
weeks
|
package/dist/index.d.cts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { upperFirst } from 'scule';
|
|
2
2
|
export * from 'scule';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* check if two values are deeply equal
|
|
6
|
+
*/
|
|
7
|
+
declare function isDeepEqual(value1: any, value2: any): boolean;
|
|
8
|
+
|
|
4
9
|
/**
|
|
5
10
|
* @file is utils
|
|
6
11
|
* @module is
|
|
@@ -11,8 +16,13 @@ type NonEmptyString = string & {
|
|
|
11
16
|
0: '';
|
|
12
17
|
};
|
|
13
18
|
declare function getObjectType(value: unknown): string;
|
|
19
|
+
declare function isUndefined(value: unknown): value is undefined;
|
|
20
|
+
declare function isNull(value: unknown): value is null;
|
|
21
|
+
declare function isNil(value: unknown): value is null | undefined;
|
|
14
22
|
declare function isString(value: unknown): value is string;
|
|
15
23
|
declare function isNumber(value: unknown): value is number;
|
|
24
|
+
declare function isZero(value: unknown): value is 0;
|
|
25
|
+
declare function isNaN(value: unknown): value is typeof Number.NaN;
|
|
16
26
|
declare function isEmptyString(value: unknown): value is '';
|
|
17
27
|
declare function isNonEmptyString(value: unknown): value is NonEmptyString;
|
|
18
28
|
declare function isWhitespaceString(value: unknown): value is Whitespace;
|
|
@@ -22,10 +32,9 @@ declare function isInteger(value: unknown): value is number;
|
|
|
22
32
|
declare function isBoolean(value: unknown): value is boolean;
|
|
23
33
|
declare function isFunction(value: unknown): value is Function;
|
|
24
34
|
declare function isArray(value: unknown): value is unknown[];
|
|
25
|
-
declare function
|
|
26
|
-
declare function isNull(value: unknown): value is null;
|
|
27
|
-
declare function isNil(value: unknown): value is null | undefined;
|
|
35
|
+
declare function isEmptyArray(value: unknown): value is [];
|
|
28
36
|
declare function isObject(value: unknown): value is object;
|
|
37
|
+
declare function isEmptyObject(value: unknown): value is {};
|
|
29
38
|
declare function isRegExp(value: unknown): value is RegExp;
|
|
30
39
|
declare function isSet<Value = unknown>(value: unknown): value is Set<Value>;
|
|
31
40
|
declare function isNativePromise<T = unknown>(value: unknown): value is Promise<T>;
|
|
@@ -52,16 +61,6 @@ declare function once<T extends unknown[]>(func: (...args: T) => void): (this: u
|
|
|
52
61
|
*/
|
|
53
62
|
declare const isBrowser: () => boolean;
|
|
54
63
|
|
|
55
|
-
/**
|
|
56
|
-
* @file case utils
|
|
57
|
-
* @module Case
|
|
58
|
-
*/
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* @deprecated use upperFirst instead
|
|
62
|
-
*/
|
|
63
|
-
declare const capitalize: typeof upperFirst;
|
|
64
|
-
|
|
65
64
|
/**
|
|
66
65
|
* @file raf.ts
|
|
67
66
|
*/
|
|
@@ -137,6 +136,8 @@ declare function debounce<T extends ((...args: any[]) => undefined | void) | und
|
|
|
137
136
|
|
|
138
137
|
declare const warnOnce: (message: string) => void;
|
|
139
138
|
|
|
139
|
+
declare function escapeHtml(unsafe: string): string;
|
|
140
|
+
|
|
140
141
|
/**
|
|
141
142
|
* Get array item by index, negative for backward
|
|
142
143
|
* @param array - given array
|
|
@@ -269,7 +270,71 @@ declare function omit<T, K extends keyof T>(object: T, ...keys: K[]): Omit<T, K>
|
|
|
269
270
|
|
|
270
271
|
declare function pick<T, K extends keyof T>(object: T, keys: K[]): Pick<T, K>;
|
|
271
272
|
|
|
272
|
-
|
|
273
|
+
interface CleanObjectOptions {
|
|
274
|
+
/**
|
|
275
|
+
* clean undefined
|
|
276
|
+
*
|
|
277
|
+
* @default true
|
|
278
|
+
*/
|
|
279
|
+
cleanUndefined?: boolean;
|
|
280
|
+
/**
|
|
281
|
+
* clean null
|
|
282
|
+
*
|
|
283
|
+
* @default true
|
|
284
|
+
*/
|
|
285
|
+
cleanNull?: boolean;
|
|
286
|
+
/**
|
|
287
|
+
* clean zero
|
|
288
|
+
*
|
|
289
|
+
* @default false
|
|
290
|
+
*/
|
|
291
|
+
cleanZero?: boolean;
|
|
292
|
+
/**
|
|
293
|
+
* clean NaN
|
|
294
|
+
*
|
|
295
|
+
* @default true
|
|
296
|
+
*/
|
|
297
|
+
cleanNaN?: boolean;
|
|
298
|
+
/**
|
|
299
|
+
* clean empty string
|
|
300
|
+
*
|
|
301
|
+
* @default true
|
|
302
|
+
*/
|
|
303
|
+
cleanEmptyString?: boolean;
|
|
304
|
+
/**
|
|
305
|
+
* clean empty array
|
|
306
|
+
*
|
|
307
|
+
* @default true
|
|
308
|
+
*/
|
|
309
|
+
cleanEmptyArray?: boolean;
|
|
310
|
+
/**
|
|
311
|
+
* clean empty object
|
|
312
|
+
*
|
|
313
|
+
* @default true
|
|
314
|
+
*/
|
|
315
|
+
cleanEmptyObject?: boolean;
|
|
316
|
+
/**
|
|
317
|
+
* recursive clean object
|
|
318
|
+
*
|
|
319
|
+
* @default true
|
|
320
|
+
*/
|
|
321
|
+
recursive?: boolean;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* clean undefined, null, zero, empty string, empty array, empty object from object
|
|
325
|
+
* @param obj - object to be cleaned
|
|
326
|
+
* @param options - clean options
|
|
327
|
+
* @returns cleaned object
|
|
328
|
+
*/
|
|
329
|
+
declare function cleanObject<T extends object>(obj: T, options?: CleanObjectOptions): T;
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* check object has a property with given key
|
|
333
|
+
* @param object - the object to check
|
|
334
|
+
* @param key - the key to check
|
|
335
|
+
* @returns true if object has a property with given key, false otherwise
|
|
336
|
+
*/
|
|
337
|
+
declare function hasOwn<T>(object: T, key: PropertyKey): boolean;
|
|
273
338
|
|
|
274
339
|
interface SortObjectOptions {
|
|
275
340
|
/**
|
|
@@ -287,4 +352,14 @@ interface SortObjectOptions {
|
|
|
287
352
|
*/
|
|
288
353
|
declare function sortObject<T extends Record<string, any>>(obj: T, options?: SortObjectOptions): T;
|
|
289
354
|
|
|
290
|
-
|
|
355
|
+
/**
|
|
356
|
+
* @file case utils
|
|
357
|
+
* @module vendor
|
|
358
|
+
*/
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* @deprecated use upperFirst instead
|
|
362
|
+
*/
|
|
363
|
+
declare const capitalize: typeof upperFirst;
|
|
364
|
+
|
|
365
|
+
export { type AnyFn, type Arrayable, type Awaitable, type CleanObjectOptions, type InteropModuleDefault, type MayBe, NOOP, type NonEmptyString, type Nullable, type Overwrite, type Prettify, type PrettifyV2, type PrimitiveType, type ResolvedOptions, type SortObjectOptions, type ThrottleDebounceOptions, type Whitespace, at, cAF, capitalize, chunk, clamp, cleanObject, days, debounce, ensurePrefix, ensureSuffix, escapeHtml, flattenArrayable, getObjectType, hasOwn, hours, isArray, isArrayEqual, isBoolean, isBrowser, isDeepEqual, isEmptyArray, isEmptyObject, isEmptyString, isEmptyStringOrWhitespace, isFunction, isInteger, isNaN, isNativePromise, isNil, isNonEmptyString, isNull, isNumber, isNumbericString, isObject, isPromise, isRegExp, isSet, isString, isUndefined, isWhitespaceString, isZero, join, last, mergeArrayable, minutes, noop, omit, once, pick, rAF, seconds, slash, sortObject, throttle, toArray, unindent, unique, uniqueBy, waitFor, warnOnce, weeks };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,6 +1,11 @@
|
|
|
1
1
|
import { upperFirst } from 'scule';
|
|
2
2
|
export * from 'scule';
|
|
3
3
|
|
|
4
|
+
/**
|
|
5
|
+
* check if two values are deeply equal
|
|
6
|
+
*/
|
|
7
|
+
declare function isDeepEqual(value1: any, value2: any): boolean;
|
|
8
|
+
|
|
4
9
|
/**
|
|
5
10
|
* @file is utils
|
|
6
11
|
* @module is
|
|
@@ -11,8 +16,13 @@ type NonEmptyString = string & {
|
|
|
11
16
|
0: '';
|
|
12
17
|
};
|
|
13
18
|
declare function getObjectType(value: unknown): string;
|
|
19
|
+
declare function isUndefined(value: unknown): value is undefined;
|
|
20
|
+
declare function isNull(value: unknown): value is null;
|
|
21
|
+
declare function isNil(value: unknown): value is null | undefined;
|
|
14
22
|
declare function isString(value: unknown): value is string;
|
|
15
23
|
declare function isNumber(value: unknown): value is number;
|
|
24
|
+
declare function isZero(value: unknown): value is 0;
|
|
25
|
+
declare function isNaN(value: unknown): value is typeof Number.NaN;
|
|
16
26
|
declare function isEmptyString(value: unknown): value is '';
|
|
17
27
|
declare function isNonEmptyString(value: unknown): value is NonEmptyString;
|
|
18
28
|
declare function isWhitespaceString(value: unknown): value is Whitespace;
|
|
@@ -22,10 +32,9 @@ declare function isInteger(value: unknown): value is number;
|
|
|
22
32
|
declare function isBoolean(value: unknown): value is boolean;
|
|
23
33
|
declare function isFunction(value: unknown): value is Function;
|
|
24
34
|
declare function isArray(value: unknown): value is unknown[];
|
|
25
|
-
declare function
|
|
26
|
-
declare function isNull(value: unknown): value is null;
|
|
27
|
-
declare function isNil(value: unknown): value is null | undefined;
|
|
35
|
+
declare function isEmptyArray(value: unknown): value is [];
|
|
28
36
|
declare function isObject(value: unknown): value is object;
|
|
37
|
+
declare function isEmptyObject(value: unknown): value is {};
|
|
29
38
|
declare function isRegExp(value: unknown): value is RegExp;
|
|
30
39
|
declare function isSet<Value = unknown>(value: unknown): value is Set<Value>;
|
|
31
40
|
declare function isNativePromise<T = unknown>(value: unknown): value is Promise<T>;
|
|
@@ -52,16 +61,6 @@ declare function once<T extends unknown[]>(func: (...args: T) => void): (this: u
|
|
|
52
61
|
*/
|
|
53
62
|
declare const isBrowser: () => boolean;
|
|
54
63
|
|
|
55
|
-
/**
|
|
56
|
-
* @file case utils
|
|
57
|
-
* @module Case
|
|
58
|
-
*/
|
|
59
|
-
|
|
60
|
-
/**
|
|
61
|
-
* @deprecated use upperFirst instead
|
|
62
|
-
*/
|
|
63
|
-
declare const capitalize: typeof upperFirst;
|
|
64
|
-
|
|
65
64
|
/**
|
|
66
65
|
* @file raf.ts
|
|
67
66
|
*/
|
|
@@ -137,6 +136,8 @@ declare function debounce<T extends ((...args: any[]) => undefined | void) | und
|
|
|
137
136
|
|
|
138
137
|
declare const warnOnce: (message: string) => void;
|
|
139
138
|
|
|
139
|
+
declare function escapeHtml(unsafe: string): string;
|
|
140
|
+
|
|
140
141
|
/**
|
|
141
142
|
* Get array item by index, negative for backward
|
|
142
143
|
* @param array - given array
|
|
@@ -269,7 +270,71 @@ declare function omit<T, K extends keyof T>(object: T, ...keys: K[]): Omit<T, K>
|
|
|
269
270
|
|
|
270
271
|
declare function pick<T, K extends keyof T>(object: T, keys: K[]): Pick<T, K>;
|
|
271
272
|
|
|
272
|
-
|
|
273
|
+
interface CleanObjectOptions {
|
|
274
|
+
/**
|
|
275
|
+
* clean undefined
|
|
276
|
+
*
|
|
277
|
+
* @default true
|
|
278
|
+
*/
|
|
279
|
+
cleanUndefined?: boolean;
|
|
280
|
+
/**
|
|
281
|
+
* clean null
|
|
282
|
+
*
|
|
283
|
+
* @default true
|
|
284
|
+
*/
|
|
285
|
+
cleanNull?: boolean;
|
|
286
|
+
/**
|
|
287
|
+
* clean zero
|
|
288
|
+
*
|
|
289
|
+
* @default false
|
|
290
|
+
*/
|
|
291
|
+
cleanZero?: boolean;
|
|
292
|
+
/**
|
|
293
|
+
* clean NaN
|
|
294
|
+
*
|
|
295
|
+
* @default true
|
|
296
|
+
*/
|
|
297
|
+
cleanNaN?: boolean;
|
|
298
|
+
/**
|
|
299
|
+
* clean empty string
|
|
300
|
+
*
|
|
301
|
+
* @default true
|
|
302
|
+
*/
|
|
303
|
+
cleanEmptyString?: boolean;
|
|
304
|
+
/**
|
|
305
|
+
* clean empty array
|
|
306
|
+
*
|
|
307
|
+
* @default true
|
|
308
|
+
*/
|
|
309
|
+
cleanEmptyArray?: boolean;
|
|
310
|
+
/**
|
|
311
|
+
* clean empty object
|
|
312
|
+
*
|
|
313
|
+
* @default true
|
|
314
|
+
*/
|
|
315
|
+
cleanEmptyObject?: boolean;
|
|
316
|
+
/**
|
|
317
|
+
* recursive clean object
|
|
318
|
+
*
|
|
319
|
+
* @default true
|
|
320
|
+
*/
|
|
321
|
+
recursive?: boolean;
|
|
322
|
+
}
|
|
323
|
+
/**
|
|
324
|
+
* clean undefined, null, zero, empty string, empty array, empty object from object
|
|
325
|
+
* @param obj - object to be cleaned
|
|
326
|
+
* @param options - clean options
|
|
327
|
+
* @returns cleaned object
|
|
328
|
+
*/
|
|
329
|
+
declare function cleanObject<T extends object>(obj: T, options?: CleanObjectOptions): T;
|
|
330
|
+
|
|
331
|
+
/**
|
|
332
|
+
* check object has a property with given key
|
|
333
|
+
* @param object - the object to check
|
|
334
|
+
* @param key - the key to check
|
|
335
|
+
* @returns true if object has a property with given key, false otherwise
|
|
336
|
+
*/
|
|
337
|
+
declare function hasOwn<T>(object: T, key: PropertyKey): boolean;
|
|
273
338
|
|
|
274
339
|
interface SortObjectOptions {
|
|
275
340
|
/**
|
|
@@ -287,4 +352,14 @@ interface SortObjectOptions {
|
|
|
287
352
|
*/
|
|
288
353
|
declare function sortObject<T extends Record<string, any>>(obj: T, options?: SortObjectOptions): T;
|
|
289
354
|
|
|
290
|
-
|
|
355
|
+
/**
|
|
356
|
+
* @file case utils
|
|
357
|
+
* @module vendor
|
|
358
|
+
*/
|
|
359
|
+
|
|
360
|
+
/**
|
|
361
|
+
* @deprecated use upperFirst instead
|
|
362
|
+
*/
|
|
363
|
+
declare const capitalize: typeof upperFirst;
|
|
364
|
+
|
|
365
|
+
export { type AnyFn, type Arrayable, type Awaitable, type CleanObjectOptions, type InteropModuleDefault, type MayBe, NOOP, type NonEmptyString, type Nullable, type Overwrite, type Prettify, type PrettifyV2, type PrimitiveType, type ResolvedOptions, type SortObjectOptions, type ThrottleDebounceOptions, type Whitespace, at, cAF, capitalize, chunk, clamp, cleanObject, days, debounce, ensurePrefix, ensureSuffix, escapeHtml, flattenArrayable, getObjectType, hasOwn, hours, isArray, isArrayEqual, isBoolean, isBrowser, isDeepEqual, isEmptyArray, isEmptyObject, isEmptyString, isEmptyStringOrWhitespace, isFunction, isInteger, isNaN, isNativePromise, isNil, isNonEmptyString, isNull, isNumber, isNumbericString, isObject, isPromise, isRegExp, isSet, isString, isUndefined, isWhitespaceString, isZero, join, last, mergeArrayable, minutes, noop, omit, once, pick, rAF, seconds, slash, sortObject, throttle, toArray, unindent, unique, uniqueBy, waitFor, warnOnce, weeks };
|
package/dist/index.js
CHANGED
|
@@ -1,91 +1,51 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
__defProp(target, name, { get: all[name], enumerable: true });
|
|
8
|
-
};
|
|
9
|
-
var __copyProps = (to, from, except, desc) => {
|
|
10
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11
|
-
for (let key of __getOwnPropNames(from))
|
|
12
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
13
|
-
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
1
|
+
// src/is/isDeepEqual.ts
|
|
2
|
+
function isDeepEqual(value1, value2) {
|
|
3
|
+
const type1 = getObjectType(value1);
|
|
4
|
+
const type2 = getObjectType(value2);
|
|
5
|
+
if (type1 !== type2) {
|
|
6
|
+
return false;
|
|
14
7
|
}
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
ensurePrefix: () => ensurePrefix,
|
|
31
|
-
ensureSuffix: () => ensureSuffix,
|
|
32
|
-
flattenArrayable: () => flattenArrayable,
|
|
33
|
-
getObjectType: () => getObjectType,
|
|
34
|
-
hasOwn: () => hasOwn,
|
|
35
|
-
hours: () => hours,
|
|
36
|
-
isArray: () => isArray,
|
|
37
|
-
isArrayEqual: () => isArrayEqual,
|
|
38
|
-
isBoolean: () => isBoolean,
|
|
39
|
-
isBrowser: () => isBrowser,
|
|
40
|
-
isEmptyString: () => isEmptyString,
|
|
41
|
-
isEmptyStringOrWhitespace: () => isEmptyStringOrWhitespace,
|
|
42
|
-
isFunction: () => isFunction,
|
|
43
|
-
isInteger: () => isInteger,
|
|
44
|
-
isNativePromise: () => isNativePromise,
|
|
45
|
-
isNil: () => isNil,
|
|
46
|
-
isNonEmptyString: () => isNonEmptyString,
|
|
47
|
-
isNull: () => isNull,
|
|
48
|
-
isNumber: () => isNumber,
|
|
49
|
-
isNumbericString: () => isNumbericString,
|
|
50
|
-
isObject: () => isObject,
|
|
51
|
-
isPromise: () => isPromise,
|
|
52
|
-
isRegExp: () => isRegExp,
|
|
53
|
-
isSet: () => isSet,
|
|
54
|
-
isString: () => isString,
|
|
55
|
-
isUndefined: () => isUndefined,
|
|
56
|
-
isWhitespaceString: () => isWhitespaceString,
|
|
57
|
-
join: () => join,
|
|
58
|
-
last: () => last,
|
|
59
|
-
mergeArrayable: () => mergeArrayable,
|
|
60
|
-
minutes: () => minutes,
|
|
61
|
-
noop: () => noop,
|
|
62
|
-
omit: () => omit,
|
|
63
|
-
once: () => once,
|
|
64
|
-
pick: () => pick,
|
|
65
|
-
rAF: () => rAF,
|
|
66
|
-
seconds: () => seconds,
|
|
67
|
-
slash: () => slash,
|
|
68
|
-
sortObject: () => sortObject,
|
|
69
|
-
throttle: () => throttle,
|
|
70
|
-
toArray: () => toArray,
|
|
71
|
-
unindent: () => unindent,
|
|
72
|
-
unique: () => unique,
|
|
73
|
-
uniqueBy: () => uniqueBy,
|
|
74
|
-
waitFor: () => waitFor,
|
|
75
|
-
warnOnce: () => warnOnce,
|
|
76
|
-
weeks: () => weeks
|
|
77
|
-
});
|
|
8
|
+
if (isArray(value1)) {
|
|
9
|
+
if (value1.length !== value2.length) {
|
|
10
|
+
return false;
|
|
11
|
+
}
|
|
12
|
+
return value1.every((item, index) => isDeepEqual(item, value2[index]));
|
|
13
|
+
}
|
|
14
|
+
if (isObject(value1)) {
|
|
15
|
+
const keys = Object.keys(value1);
|
|
16
|
+
if (keys.length !== Object.keys(value2).length) {
|
|
17
|
+
return false;
|
|
18
|
+
}
|
|
19
|
+
return keys.every((key) => isDeepEqual(value1[key], value2[key]));
|
|
20
|
+
}
|
|
21
|
+
return Object.is(value1, value2);
|
|
22
|
+
}
|
|
78
23
|
|
|
79
24
|
// src/is/index.ts
|
|
80
25
|
function getObjectType(value) {
|
|
81
26
|
return Object.prototype.toString.call(value).slice(8, -1);
|
|
82
27
|
}
|
|
28
|
+
function isUndefined(value) {
|
|
29
|
+
return value === void 0;
|
|
30
|
+
}
|
|
31
|
+
function isNull(value) {
|
|
32
|
+
return value === null;
|
|
33
|
+
}
|
|
34
|
+
function isNil(value) {
|
|
35
|
+
return isNull(value) || isUndefined(value);
|
|
36
|
+
}
|
|
83
37
|
function isString(value) {
|
|
84
38
|
return typeof value === "string";
|
|
85
39
|
}
|
|
86
40
|
function isNumber(value) {
|
|
87
41
|
return typeof value === "number";
|
|
88
42
|
}
|
|
43
|
+
function isZero(value) {
|
|
44
|
+
return value === 0;
|
|
45
|
+
}
|
|
46
|
+
function isNaN(value) {
|
|
47
|
+
return Number.isNaN(value);
|
|
48
|
+
}
|
|
89
49
|
function isEmptyString(value) {
|
|
90
50
|
return isString(value) && value.length === 0;
|
|
91
51
|
}
|
|
@@ -113,18 +73,15 @@ function isFunction(value) {
|
|
|
113
73
|
function isArray(value) {
|
|
114
74
|
return Array.isArray(value);
|
|
115
75
|
}
|
|
116
|
-
function
|
|
117
|
-
return value ===
|
|
118
|
-
}
|
|
119
|
-
function isNull(value) {
|
|
120
|
-
return value === null;
|
|
121
|
-
}
|
|
122
|
-
function isNil(value) {
|
|
123
|
-
return isNull(value) || isUndefined(value);
|
|
76
|
+
function isEmptyArray(value) {
|
|
77
|
+
return isArray(value) && value.length === 0;
|
|
124
78
|
}
|
|
125
79
|
function isObject(value) {
|
|
126
80
|
return getObjectType(value) === "Object";
|
|
127
81
|
}
|
|
82
|
+
function isEmptyObject(value) {
|
|
83
|
+
return isObject(value) && Object.keys(value).length === 0;
|
|
84
|
+
}
|
|
128
85
|
function isRegExp(value) {
|
|
129
86
|
return getObjectType(value) === "RegExp";
|
|
130
87
|
}
|
|
@@ -162,19 +119,6 @@ function once(func) {
|
|
|
162
119
|
// src/env/isBrowser.ts
|
|
163
120
|
var isBrowser = () => typeof document !== "undefined";
|
|
164
121
|
|
|
165
|
-
// src/case.ts
|
|
166
|
-
var case_exports = {};
|
|
167
|
-
__export(case_exports, {
|
|
168
|
-
capitalize: () => capitalize
|
|
169
|
-
});
|
|
170
|
-
__reExport(case_exports, scule_star);
|
|
171
|
-
import { upperFirst } from "scule";
|
|
172
|
-
import * as scule_star from "scule";
|
|
173
|
-
var capitalize = upperFirst;
|
|
174
|
-
|
|
175
|
-
// src/index.ts
|
|
176
|
-
__reExport(src_exports, case_exports);
|
|
177
|
-
|
|
178
122
|
// src/misc/raf.ts
|
|
179
123
|
var root = isBrowser() ? window : globalThis;
|
|
180
124
|
var prev = Date.now();
|
|
@@ -283,6 +227,11 @@ var warnOnce = (message) => {
|
|
|
283
227
|
console.warn(message);
|
|
284
228
|
};
|
|
285
229
|
|
|
230
|
+
// src/html/escapeHtml.ts
|
|
231
|
+
function escapeHtml(unsafe) {
|
|
232
|
+
return unsafe.replace(/&/g, "&").replace(/</g, "<").replace(/>/g, ">").replace(/"/g, """).replace(/'/g, "'");
|
|
233
|
+
}
|
|
234
|
+
|
|
286
235
|
// src/array/at.ts
|
|
287
236
|
function at(array, index) {
|
|
288
237
|
const length = array.length;
|
|
@@ -394,6 +343,9 @@ function omit(object, ...keys) {
|
|
|
394
343
|
|
|
395
344
|
// src/object/hasOwn.ts
|
|
396
345
|
function hasOwn(object, key) {
|
|
346
|
+
if (object === null) {
|
|
347
|
+
return false;
|
|
348
|
+
}
|
|
397
349
|
return Object.prototype.hasOwnProperty.call(object, key);
|
|
398
350
|
}
|
|
399
351
|
|
|
@@ -409,6 +361,48 @@ function pick(object, keys) {
|
|
|
409
361
|
);
|
|
410
362
|
}
|
|
411
363
|
|
|
364
|
+
// src/object/clean.ts
|
|
365
|
+
function cleanObject(obj, options = {}) {
|
|
366
|
+
const {
|
|
367
|
+
cleanUndefined = true,
|
|
368
|
+
cleanNull = true,
|
|
369
|
+
cleanZero = false,
|
|
370
|
+
cleanNaN = true,
|
|
371
|
+
cleanEmptyString = true,
|
|
372
|
+
cleanEmptyArray = true,
|
|
373
|
+
cleanEmptyObject = true,
|
|
374
|
+
recursive = true
|
|
375
|
+
} = options;
|
|
376
|
+
Object.keys(obj).forEach((key) => {
|
|
377
|
+
const v = obj[key];
|
|
378
|
+
if (cleanUndefined && isUndefined(v)) {
|
|
379
|
+
delete obj[key];
|
|
380
|
+
}
|
|
381
|
+
if (cleanNull && isNull(v)) {
|
|
382
|
+
delete obj[key];
|
|
383
|
+
}
|
|
384
|
+
if (cleanZero && isZero(v)) {
|
|
385
|
+
delete obj[key];
|
|
386
|
+
}
|
|
387
|
+
if (cleanNaN && isZero(v)) {
|
|
388
|
+
delete obj[key];
|
|
389
|
+
}
|
|
390
|
+
if (cleanEmptyString && isEmptyString(v)) {
|
|
391
|
+
delete obj[key];
|
|
392
|
+
}
|
|
393
|
+
if (cleanEmptyArray && isEmptyArray(v)) {
|
|
394
|
+
delete obj[key];
|
|
395
|
+
}
|
|
396
|
+
if (cleanEmptyObject && isEmptyObject(v)) {
|
|
397
|
+
delete obj[key];
|
|
398
|
+
}
|
|
399
|
+
if (recursive && isObject(v)) {
|
|
400
|
+
cleanObject(v, options);
|
|
401
|
+
}
|
|
402
|
+
});
|
|
403
|
+
return obj;
|
|
404
|
+
}
|
|
405
|
+
|
|
412
406
|
// src/object/isPlainObject.ts
|
|
413
407
|
function isPlainObject(value) {
|
|
414
408
|
if (!isObject(value)) return false;
|
|
@@ -439,17 +433,104 @@ function sortObject(obj, options = {}) {
|
|
|
439
433
|
}
|
|
440
434
|
return sortKeys(obj);
|
|
441
435
|
}
|
|
436
|
+
|
|
437
|
+
// node_modules/.pnpm/scule@1.3.0/node_modules/scule/dist/index.mjs
|
|
438
|
+
var NUMBER_CHAR_RE = /\d/;
|
|
439
|
+
var STR_SPLITTERS = ["-", "_", "/", "."];
|
|
440
|
+
function isUppercase(char = "") {
|
|
441
|
+
if (NUMBER_CHAR_RE.test(char)) {
|
|
442
|
+
return void 0;
|
|
443
|
+
}
|
|
444
|
+
return char !== char.toLowerCase();
|
|
445
|
+
}
|
|
446
|
+
function splitByCase(str, separators) {
|
|
447
|
+
const splitters = separators ?? STR_SPLITTERS;
|
|
448
|
+
const parts = [];
|
|
449
|
+
if (!str || typeof str !== "string") {
|
|
450
|
+
return parts;
|
|
451
|
+
}
|
|
452
|
+
let buff = "";
|
|
453
|
+
let previousUpper;
|
|
454
|
+
let previousSplitter;
|
|
455
|
+
for (const char of str) {
|
|
456
|
+
const isSplitter = splitters.includes(char);
|
|
457
|
+
if (isSplitter === true) {
|
|
458
|
+
parts.push(buff);
|
|
459
|
+
buff = "";
|
|
460
|
+
previousUpper = void 0;
|
|
461
|
+
continue;
|
|
462
|
+
}
|
|
463
|
+
const isUpper = isUppercase(char);
|
|
464
|
+
if (previousSplitter === false) {
|
|
465
|
+
if (previousUpper === false && isUpper === true) {
|
|
466
|
+
parts.push(buff);
|
|
467
|
+
buff = char;
|
|
468
|
+
previousUpper = isUpper;
|
|
469
|
+
continue;
|
|
470
|
+
}
|
|
471
|
+
if (previousUpper === true && isUpper === false && buff.length > 1) {
|
|
472
|
+
const lastChar = buff.at(-1);
|
|
473
|
+
parts.push(buff.slice(0, Math.max(0, buff.length - 1)));
|
|
474
|
+
buff = lastChar + char;
|
|
475
|
+
previousUpper = isUpper;
|
|
476
|
+
continue;
|
|
477
|
+
}
|
|
478
|
+
}
|
|
479
|
+
buff += char;
|
|
480
|
+
previousUpper = isUpper;
|
|
481
|
+
previousSplitter = isSplitter;
|
|
482
|
+
}
|
|
483
|
+
parts.push(buff);
|
|
484
|
+
return parts;
|
|
485
|
+
}
|
|
486
|
+
function upperFirst(str) {
|
|
487
|
+
return str ? str[0].toUpperCase() + str.slice(1) : "";
|
|
488
|
+
}
|
|
489
|
+
function lowerFirst(str) {
|
|
490
|
+
return str ? str[0].toLowerCase() + str.slice(1) : "";
|
|
491
|
+
}
|
|
492
|
+
function pascalCase(str, opts) {
|
|
493
|
+
return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => upperFirst(opts?.normalize ? p.toLowerCase() : p)).join("") : "";
|
|
494
|
+
}
|
|
495
|
+
function camelCase(str, opts) {
|
|
496
|
+
return lowerFirst(pascalCase(str || "", opts));
|
|
497
|
+
}
|
|
498
|
+
function kebabCase(str, joiner) {
|
|
499
|
+
return str ? (Array.isArray(str) ? str : splitByCase(str)).map((p) => p.toLowerCase()).join(joiner ?? "-") : "";
|
|
500
|
+
}
|
|
501
|
+
function snakeCase(str) {
|
|
502
|
+
return kebabCase(str || "", "_");
|
|
503
|
+
}
|
|
504
|
+
function flatCase(str) {
|
|
505
|
+
return kebabCase(str || "", "");
|
|
506
|
+
}
|
|
507
|
+
function trainCase(str, opts) {
|
|
508
|
+
return (Array.isArray(str) ? str : splitByCase(str)).filter(Boolean).map((p) => upperFirst(opts?.normalize ? p.toLowerCase() : p)).join("-");
|
|
509
|
+
}
|
|
510
|
+
var titleCaseExceptions = /^(a|an|and|as|at|but|by|for|if|in|is|nor|of|on|or|the|to|with)$/i;
|
|
511
|
+
function titleCase(str, opts) {
|
|
512
|
+
return (Array.isArray(str) ? str : splitByCase(str)).filter(Boolean).map(
|
|
513
|
+
(p) => titleCaseExceptions.test(p) ? p.toLowerCase() : upperFirst(opts?.normalize ? p.toLowerCase() : p)
|
|
514
|
+
).join(" ");
|
|
515
|
+
}
|
|
516
|
+
|
|
517
|
+
// src/vendor/scule.ts
|
|
518
|
+
var capitalize = upperFirst;
|
|
442
519
|
export {
|
|
443
520
|
NOOP,
|
|
444
521
|
at,
|
|
445
522
|
cAF,
|
|
523
|
+
camelCase,
|
|
446
524
|
capitalize,
|
|
447
525
|
chunk,
|
|
448
526
|
clamp,
|
|
527
|
+
cleanObject,
|
|
449
528
|
days,
|
|
450
529
|
debounce,
|
|
451
530
|
ensurePrefix,
|
|
452
531
|
ensureSuffix,
|
|
532
|
+
escapeHtml,
|
|
533
|
+
flatCase,
|
|
453
534
|
flattenArrayable,
|
|
454
535
|
getObjectType,
|
|
455
536
|
hasOwn,
|
|
@@ -458,10 +539,14 @@ export {
|
|
|
458
539
|
isArrayEqual,
|
|
459
540
|
isBoolean,
|
|
460
541
|
isBrowser,
|
|
542
|
+
isDeepEqual,
|
|
543
|
+
isEmptyArray,
|
|
544
|
+
isEmptyObject,
|
|
461
545
|
isEmptyString,
|
|
462
546
|
isEmptyStringOrWhitespace,
|
|
463
547
|
isFunction,
|
|
464
548
|
isInteger,
|
|
549
|
+
isNaN,
|
|
465
550
|
isNativePromise,
|
|
466
551
|
isNil,
|
|
467
552
|
isNonEmptyString,
|
|
@@ -474,24 +559,34 @@ export {
|
|
|
474
559
|
isSet,
|
|
475
560
|
isString,
|
|
476
561
|
isUndefined,
|
|
562
|
+
isUppercase,
|
|
477
563
|
isWhitespaceString,
|
|
564
|
+
isZero,
|
|
478
565
|
join,
|
|
566
|
+
kebabCase,
|
|
479
567
|
last,
|
|
568
|
+
lowerFirst,
|
|
480
569
|
mergeArrayable,
|
|
481
570
|
minutes,
|
|
482
571
|
noop,
|
|
483
572
|
omit,
|
|
484
573
|
once,
|
|
574
|
+
pascalCase,
|
|
485
575
|
pick,
|
|
486
576
|
rAF,
|
|
487
577
|
seconds,
|
|
488
578
|
slash,
|
|
579
|
+
snakeCase,
|
|
489
580
|
sortObject,
|
|
581
|
+
splitByCase,
|
|
490
582
|
throttle,
|
|
583
|
+
titleCase,
|
|
491
584
|
toArray,
|
|
585
|
+
trainCase,
|
|
492
586
|
unindent,
|
|
493
587
|
unique,
|
|
494
588
|
uniqueBy,
|
|
589
|
+
upperFirst,
|
|
495
590
|
waitFor,
|
|
496
591
|
warnOnce,
|
|
497
592
|
weeks
|