es-toolkit 1.12.0-dev.280 → 1.12.0-dev.282
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/array/index.mjs +31 -31
- package/dist/{chunk-Y5V7UAZZ.mjs → chunk-32AEPQYI.mjs} +4 -4
- package/dist/chunk-54TK5BIS.mjs +1 -0
- package/dist/chunk-MIGAC7F4.mjs +25 -0
- package/dist/chunk-MIGAC7F4.mjs.map +1 -0
- package/dist/chunk-WGX4WINP.mjs +1 -0
- package/dist/chunk-XGQWTHW6.mjs +34 -0
- package/dist/chunk-XGQWTHW6.mjs.map +1 -0
- package/dist/compat/index.d.mts +26 -1
- package/dist/compat/index.d.ts +26 -1
- package/dist/compat/index.js +81 -0
- package/dist/compat/index.js.map +1 -1
- package/dist/compat/index.mjs +105 -69
- package/dist/compat/index.mjs.map +1 -1
- package/dist/function/index.mjs +6 -6
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +51 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +77 -69
- package/dist/object/flattenObject.d.mts +28 -0
- package/dist/object/flattenObject.d.ts +28 -0
- package/dist/object/flattenObject.js +77 -0
- package/dist/object/flattenObject.js.map +1 -0
- package/dist/object/flattenObject.mjs +9 -0
- package/dist/object/flattenObject.mjs.map +1 -0
- package/dist/object/index.d.mts +1 -0
- package/dist/object/index.d.ts +1 -0
- package/dist/object/index.js +49 -0
- package/dist/object/index.js.map +1 -1
- package/dist/object/index.mjs +9 -4
- package/dist/predicate/index.d.mts +1 -0
- package/dist/predicate/index.d.ts +1 -0
- package/dist/predicate/index.js +23 -0
- package/dist/predicate/index.js.map +1 -1
- package/dist/predicate/index.mjs +7 -3
- package/dist/predicate/isPlainObject.d.mts +16 -0
- package/dist/predicate/isPlainObject.d.ts +16 -0
- package/dist/predicate/isPlainObject.js +49 -0
- package/dist/predicate/isPlainObject.js.map +1 -0
- package/dist/predicate/isPlainObject.mjs +8 -0
- package/dist/predicate/isPlainObject.mjs.map +1 -0
- package/dist/string/camelCase.mjs +2 -2
- package/dist/string/index.mjs +8 -8
- package/package.json +1 -1
- package/dist/chunk-ASJF5D6C.mjs +0 -1
- package/dist/chunk-OSOLEQLZ.mjs +0 -1
- /package/dist/{chunk-Y5V7UAZZ.mjs.map → chunk-32AEPQYI.mjs.map} +0 -0
- /package/dist/{chunk-ASJF5D6C.mjs.map → chunk-54TK5BIS.mjs.map} +0 -0
- /package/dist/{chunk-OSOLEQLZ.mjs.map → chunk-WGX4WINP.mjs.map} +0 -0
package/dist/array/index.mjs
CHANGED
|
@@ -1,4 +1,13 @@
|
|
|
1
1
|
import "../chunk-DDH7K4QM.mjs";
|
|
2
|
+
import {
|
|
3
|
+
zipWith
|
|
4
|
+
} from "../chunk-4KYXHZ4R.mjs";
|
|
5
|
+
import {
|
|
6
|
+
unzip
|
|
7
|
+
} from "../chunk-UYZKMBDO.mjs";
|
|
8
|
+
import {
|
|
9
|
+
unzipWith
|
|
10
|
+
} from "../chunk-IFNXROZR.mjs";
|
|
2
11
|
import {
|
|
3
12
|
without
|
|
4
13
|
} from "../chunk-PYEYV7BY.mjs";
|
|
@@ -18,8 +27,11 @@ import {
|
|
|
18
27
|
zipObject
|
|
19
28
|
} from "../chunk-6GWEY5EL.mjs";
|
|
20
29
|
import {
|
|
21
|
-
|
|
22
|
-
} from "../chunk-
|
|
30
|
+
takeWhile
|
|
31
|
+
} from "../chunk-2IXFGSUA.mjs";
|
|
32
|
+
import {
|
|
33
|
+
toFilled
|
|
34
|
+
} from "../chunk-OP4OAKQJ.mjs";
|
|
23
35
|
import {
|
|
24
36
|
union
|
|
25
37
|
} from "../chunk-R6QA7PLZ.mjs";
|
|
@@ -39,11 +51,11 @@ import {
|
|
|
39
51
|
uniqWith
|
|
40
52
|
} from "../chunk-237HGSZS.mjs";
|
|
41
53
|
import {
|
|
42
|
-
|
|
43
|
-
} from "../chunk-
|
|
54
|
+
partition
|
|
55
|
+
} from "../chunk-DN3NOZ3H.mjs";
|
|
44
56
|
import {
|
|
45
|
-
|
|
46
|
-
} from "../chunk-
|
|
57
|
+
sample
|
|
58
|
+
} from "../chunk-2KNLZB7V.mjs";
|
|
47
59
|
import {
|
|
48
60
|
sampleSize
|
|
49
61
|
} from "../chunk-EHSKB6DF.mjs";
|
|
@@ -65,11 +77,11 @@ import {
|
|
|
65
77
|
takeRightWhile
|
|
66
78
|
} from "../chunk-NTLX2MPV.mjs";
|
|
67
79
|
import {
|
|
68
|
-
|
|
69
|
-
} from "../chunk-
|
|
80
|
+
intersection
|
|
81
|
+
} from "../chunk-FVVSE2F2.mjs";
|
|
70
82
|
import {
|
|
71
|
-
|
|
72
|
-
} from "../chunk-
|
|
83
|
+
intersectionBy
|
|
84
|
+
} from "../chunk-O6UXZR3U.mjs";
|
|
73
85
|
import {
|
|
74
86
|
intersectionWith
|
|
75
87
|
} from "../chunk-XI7KRD2C.mjs";
|
|
@@ -89,14 +101,14 @@ import {
|
|
|
89
101
|
orderBy
|
|
90
102
|
} from "../chunk-7B7W36UP.mjs";
|
|
91
103
|
import {
|
|
92
|
-
|
|
93
|
-
} from "../chunk-
|
|
94
|
-
import {
|
|
95
|
-
sample
|
|
96
|
-
} from "../chunk-2KNLZB7V.mjs";
|
|
104
|
+
flatMap
|
|
105
|
+
} from "../chunk-UY76KTPE.mjs";
|
|
97
106
|
import {
|
|
98
107
|
flattenDeep
|
|
99
108
|
} from "../chunk-ML727RRJ.mjs";
|
|
109
|
+
import {
|
|
110
|
+
flatten
|
|
111
|
+
} from "../chunk-33MSBDC6.mjs";
|
|
100
112
|
import {
|
|
101
113
|
forEachRight
|
|
102
114
|
} from "../chunk-IEA53J7P.mjs";
|
|
@@ -110,11 +122,11 @@ import {
|
|
|
110
122
|
initial
|
|
111
123
|
} from "../chunk-XPSOKBRZ.mjs";
|
|
112
124
|
import {
|
|
113
|
-
|
|
114
|
-
} from "../chunk-
|
|
125
|
+
difference
|
|
126
|
+
} from "../chunk-JPUKH67K.mjs";
|
|
115
127
|
import {
|
|
116
|
-
|
|
117
|
-
} from "../chunk-
|
|
128
|
+
differenceBy
|
|
129
|
+
} from "../chunk-LVWX5B43.mjs";
|
|
118
130
|
import {
|
|
119
131
|
differenceWith
|
|
120
132
|
} from "../chunk-6NVQAHXP.mjs";
|
|
@@ -133,12 +145,6 @@ import {
|
|
|
133
145
|
import {
|
|
134
146
|
fill
|
|
135
147
|
} from "../chunk-YFN6KOC4.mjs";
|
|
136
|
-
import {
|
|
137
|
-
flatMap
|
|
138
|
-
} from "../chunk-UY76KTPE.mjs";
|
|
139
|
-
import {
|
|
140
|
-
flatten
|
|
141
|
-
} from "../chunk-33MSBDC6.mjs";
|
|
142
148
|
import {
|
|
143
149
|
chunk
|
|
144
150
|
} from "../chunk-E6C5EZQA.mjs";
|
|
@@ -148,12 +154,6 @@ import {
|
|
|
148
154
|
import {
|
|
149
155
|
countBy
|
|
150
156
|
} from "../chunk-CRSKT4WW.mjs";
|
|
151
|
-
import {
|
|
152
|
-
difference
|
|
153
|
-
} from "../chunk-JPUKH67K.mjs";
|
|
154
|
-
import {
|
|
155
|
-
differenceBy
|
|
156
|
-
} from "../chunk-LVWX5B43.mjs";
|
|
157
157
|
import "../chunk-424M7IR7.mjs";
|
|
158
158
|
export {
|
|
159
159
|
chunk,
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
2
|
-
capitalize
|
|
3
|
-
} from "./chunk-U56ZOM7L.mjs";
|
|
4
1
|
import {
|
|
5
2
|
getWords
|
|
6
3
|
} from "./chunk-WVQ7YVRK.mjs";
|
|
4
|
+
import {
|
|
5
|
+
capitalize
|
|
6
|
+
} from "./chunk-U56ZOM7L.mjs";
|
|
7
7
|
|
|
8
8
|
// src/string/camelCase.ts
|
|
9
9
|
function camelCase(str) {
|
|
@@ -18,4 +18,4 @@ function camelCase(str) {
|
|
|
18
18
|
export {
|
|
19
19
|
camelCase
|
|
20
20
|
};
|
|
21
|
-
//# sourceMappingURL=chunk-
|
|
21
|
+
//# sourceMappingURL=chunk-32AEPQYI.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-54TK5BIS.mjs.map
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
// src/predicate/isPlainObject.ts
|
|
2
|
+
function isPlainObject(object) {
|
|
3
|
+
if (typeof object !== "object") {
|
|
4
|
+
return false;
|
|
5
|
+
}
|
|
6
|
+
if (object == null) {
|
|
7
|
+
return false;
|
|
8
|
+
}
|
|
9
|
+
if (Object.getPrototypeOf(object) === null) {
|
|
10
|
+
return true;
|
|
11
|
+
}
|
|
12
|
+
if (object.toString() !== "[object Object]") {
|
|
13
|
+
return false;
|
|
14
|
+
}
|
|
15
|
+
let proto = object;
|
|
16
|
+
while (Object.getPrototypeOf(proto) !== null) {
|
|
17
|
+
proto = Object.getPrototypeOf(proto);
|
|
18
|
+
}
|
|
19
|
+
return Object.getPrototypeOf(object) === proto;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
export {
|
|
23
|
+
isPlainObject
|
|
24
|
+
};
|
|
25
|
+
//# sourceMappingURL=chunk-MIGAC7F4.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/predicate/isPlainObject.ts"],"sourcesContent":["/**\n * Checks if a given value is a plain object.\n * \n * @param {object} object - The value to check.\n * @returns {boolean} - True if the value is a plain object, otherwise false.\n * \n * @example\n * console.log(isPlainObject({})); // true\n * console.log(isPlainObject([])); // false\n * console.log(isPlainObject(null)); // false\n * console.log(isPlainObject(Object.create(null))); // true\n * console.log(Buffer.from('hello, world')); // false\n */\nexport function isPlainObject(object: object): boolean {\n if (typeof object !== 'object') {\n return false;\n }\n\n if (object == null) {\n return false;\n }\n\n if (Object.getPrototypeOf(object) === null) {\n return true;\n }\n\n if (object.toString() !== '[object Object]') {\n return false;\n }\n\n let proto = object;\n\n while (Object.getPrototypeOf(proto) !== null) {\n proto = Object.getPrototypeOf(proto);\n }\n\n return Object.getPrototypeOf(object) === proto;\n}"],"mappings":";AAaO,SAAS,cAAc,QAAyB;AACrD,MAAI,OAAO,WAAW,UAAU;AAC9B,WAAO;AAAA,EACT;AAEA,MAAI,UAAU,MAAM;AAClB,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,eAAe,MAAM,MAAM,MAAM;AAC1C,WAAO;AAAA,EACT;AAEA,MAAI,OAAO,SAAS,MAAM,mBAAmB;AAC3C,WAAO;AAAA,EACT;AAEA,MAAI,QAAQ;AAEZ,SAAO,OAAO,eAAe,KAAK,MAAM,MAAM;AAC5C,YAAQ,OAAO,eAAe,KAAK;AAAA,EACrC;AAEA,SAAO,OAAO,eAAe,MAAM,MAAM;AAC3C;","names":[]}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
//# sourceMappingURL=chunk-WGX4WINP.mjs.map
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isPlainObject
|
|
3
|
+
} from "./chunk-MIGAC7F4.mjs";
|
|
4
|
+
|
|
5
|
+
// src/object/flattenObject.ts
|
|
6
|
+
function flattenObject(object) {
|
|
7
|
+
return flattenObjectImpl(object);
|
|
8
|
+
}
|
|
9
|
+
function flattenObjectImpl(object, prefix = "") {
|
|
10
|
+
const result = {};
|
|
11
|
+
const keys = Object.keys(object);
|
|
12
|
+
for (let i = 0; i < keys.length; i++) {
|
|
13
|
+
const key = keys[i];
|
|
14
|
+
const value = object[key];
|
|
15
|
+
const prefixedKey = prefix ? `${prefix}.${key}` : key;
|
|
16
|
+
if (isPlainObject(value) && Object.keys(value).length > 0) {
|
|
17
|
+
Object.assign(result, flattenObjectImpl(value, prefixedKey));
|
|
18
|
+
continue;
|
|
19
|
+
}
|
|
20
|
+
if (Array.isArray(value)) {
|
|
21
|
+
for (let index = 0; index < value.length; index++) {
|
|
22
|
+
result[`${prefixedKey}.${index}`] = value[index];
|
|
23
|
+
}
|
|
24
|
+
continue;
|
|
25
|
+
}
|
|
26
|
+
result[prefixedKey] = value;
|
|
27
|
+
}
|
|
28
|
+
return result;
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export {
|
|
32
|
+
flattenObject
|
|
33
|
+
};
|
|
34
|
+
//# sourceMappingURL=chunk-XGQWTHW6.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/object/flattenObject.ts"],"sourcesContent":["import { isPlainObject } from \"../predicate/isPlainObject.ts\";\n\n/**\n * Flattens a nested object into a single level object with dot-separated keys.\n * \n * @param {object} object - The object to flatten.\n * @returns {Record<string, any>} - The flattened object.\n * \n * @example\n * const nestedObject = {\n * a: {\n * b: {\n * c: 1\n * }\n * },\n * d: [2, 3]\n * };\n * \n * const flattened = flattenObject(nestedObject);\n * console.log(flattened); \n * // Output:\n * // {\n * // 'a.b.c': 1,\n * // 'd.0': 2,\n * // 'd.1': 3\n * // }\n */\nexport function flattenObject(object: object): Record<string, any> {\n return flattenObjectImpl(object);\n}\n\nfunction flattenObjectImpl(object: object, prefix = ''): Record<string, any> {\n const result: Record<string, any> = {};\n const keys = Object.keys(object);\n\n for (let i = 0; i < keys.length; i++) {\n const key = keys[i];\n const value = (object as any)[key];\n\n const prefixedKey = prefix ? `${prefix}.${key}` : key;\n\n if (isPlainObject(value) && Object.keys(value).length > 0) {\n Object.assign(result, flattenObjectImpl(value, prefixedKey));\n continue;\n }\n\n if (Array.isArray(value)) {\n for (let index = 0; index < value.length; index++) {\n result[`${prefixedKey}.${index}`] = value[index];\n }\n continue;\n }\n\n result[prefixedKey] = value;\n }\n\n return result;\n}"],"mappings":";;;;;AA2BO,SAAS,cAAc,QAAqC;AACjE,SAAO,kBAAkB,MAAM;AACjC;AAEA,SAAS,kBAAkB,QAAgB,SAAS,IAAyB;AAC3E,QAAM,SAA8B,CAAC;AACrC,QAAM,OAAO,OAAO,KAAK,MAAM;AAE/B,WAAS,IAAI,GAAG,IAAI,KAAK,QAAQ,KAAK;AACpC,UAAM,MAAM,KAAK,CAAC;AAClB,UAAM,QAAS,OAAe,GAAG;AAEjC,UAAM,cAAc,SAAS,GAAG,MAAM,IAAI,GAAG,KAAK;AAElD,QAAI,cAAc,KAAK,KAAK,OAAO,KAAK,KAAK,EAAE,SAAS,GAAG;AACzD,aAAO,OAAO,QAAQ,kBAAkB,OAAO,WAAW,CAAC;AAC3D;AAAA,IACF;AAEA,QAAI,MAAM,QAAQ,KAAK,GAAG;AACxB,eAAS,QAAQ,GAAG,QAAQ,MAAM,QAAQ,SAAS;AACjD,eAAO,GAAG,WAAW,IAAI,KAAK,EAAE,IAAI,MAAM,KAAK;AAAA,MACjD;AACA;AAAA,IACF;AAEA,WAAO,WAAW,IAAI;AAAA,EACxB;AAEA,SAAO;AACT;","names":[]}
|
package/dist/compat/index.d.mts
CHANGED
|
@@ -70,6 +70,7 @@ export { pick } from '../object/pick.mjs';
|
|
|
70
70
|
export { pickBy } from '../object/pickBy.mjs';
|
|
71
71
|
export { invert } from '../object/invert.mjs';
|
|
72
72
|
export { clone } from '../object/clone.mjs';
|
|
73
|
+
export { flattenObject } from '../object/flattenObject.mjs';
|
|
73
74
|
export { isEqual } from '../predicate/isEqual.mjs';
|
|
74
75
|
export { isNil } from '../predicate/isNil.mjs';
|
|
75
76
|
export { isNotNil } from '../predicate/isNotNil.mjs';
|
|
@@ -457,6 +458,30 @@ declare function get(object: unknown, path: PropertyKey | readonly PropertyKey[]
|
|
|
457
458
|
*/
|
|
458
459
|
declare function set<T>(obj: object, path: PropertyKey | readonly PropertyKey[], value: unknown): T;
|
|
459
460
|
|
|
461
|
+
/**
|
|
462
|
+
* Checks if a given value is a plain object.
|
|
463
|
+
*
|
|
464
|
+
* A plain object is an object created by the `{}` literal, `new Object()`, or
|
|
465
|
+
* `Object.create(null)`.
|
|
466
|
+
*
|
|
467
|
+
* This function also handles objects with custom
|
|
468
|
+
* `Symbol.toStringTag` properties.
|
|
469
|
+
*
|
|
470
|
+
* `Symbol.toStringTag` is a built-in symbol that a constructor can use to customize the
|
|
471
|
+
* default string description of objects.
|
|
472
|
+
*
|
|
473
|
+
* @param {unknown} [object] - The value to check.
|
|
474
|
+
* @returns {boolean} - True if the value is a plain object, otherwise false.
|
|
475
|
+
*
|
|
476
|
+
* @example
|
|
477
|
+
* console.log(isPlainObject({})); // true
|
|
478
|
+
* console.log(isPlainObject([])); // false
|
|
479
|
+
* console.log(isPlainObject(null)); // false
|
|
480
|
+
* console.log(isPlainObject(Object.create(null))); // true
|
|
481
|
+
* console.log(isPlainObject(new Map())); // false
|
|
482
|
+
*/
|
|
483
|
+
declare function isPlainObject(object?: unknown): boolean;
|
|
484
|
+
|
|
460
485
|
/**
|
|
461
486
|
* Checks if a string contains another string at the beginning of the string.
|
|
462
487
|
*
|
|
@@ -527,4 +552,4 @@ declare function max<T>(items?: readonly T[]): T;
|
|
|
527
552
|
*/
|
|
528
553
|
declare function min<T>(items?: readonly T[]): T;
|
|
529
554
|
|
|
530
|
-
export { chunk, concat, difference, endsWith, get, max, min, set, startsWith, zipObjectDeep };
|
|
555
|
+
export { chunk, concat, difference, endsWith, get, isPlainObject, max, min, set, startsWith, zipObjectDeep };
|
package/dist/compat/index.d.ts
CHANGED
|
@@ -70,6 +70,7 @@ export { pick } from '../object/pick.js';
|
|
|
70
70
|
export { pickBy } from '../object/pickBy.js';
|
|
71
71
|
export { invert } from '../object/invert.js';
|
|
72
72
|
export { clone } from '../object/clone.js';
|
|
73
|
+
export { flattenObject } from '../object/flattenObject.js';
|
|
73
74
|
export { isEqual } from '../predicate/isEqual.js';
|
|
74
75
|
export { isNil } from '../predicate/isNil.js';
|
|
75
76
|
export { isNotNil } from '../predicate/isNotNil.js';
|
|
@@ -457,6 +458,30 @@ declare function get(object: unknown, path: PropertyKey | readonly PropertyKey[]
|
|
|
457
458
|
*/
|
|
458
459
|
declare function set<T>(obj: object, path: PropertyKey | readonly PropertyKey[], value: unknown): T;
|
|
459
460
|
|
|
461
|
+
/**
|
|
462
|
+
* Checks if a given value is a plain object.
|
|
463
|
+
*
|
|
464
|
+
* A plain object is an object created by the `{}` literal, `new Object()`, or
|
|
465
|
+
* `Object.create(null)`.
|
|
466
|
+
*
|
|
467
|
+
* This function also handles objects with custom
|
|
468
|
+
* `Symbol.toStringTag` properties.
|
|
469
|
+
*
|
|
470
|
+
* `Symbol.toStringTag` is a built-in symbol that a constructor can use to customize the
|
|
471
|
+
* default string description of objects.
|
|
472
|
+
*
|
|
473
|
+
* @param {unknown} [object] - The value to check.
|
|
474
|
+
* @returns {boolean} - True if the value is a plain object, otherwise false.
|
|
475
|
+
*
|
|
476
|
+
* @example
|
|
477
|
+
* console.log(isPlainObject({})); // true
|
|
478
|
+
* console.log(isPlainObject([])); // false
|
|
479
|
+
* console.log(isPlainObject(null)); // false
|
|
480
|
+
* console.log(isPlainObject(Object.create(null))); // true
|
|
481
|
+
* console.log(isPlainObject(new Map())); // false
|
|
482
|
+
*/
|
|
483
|
+
declare function isPlainObject(object?: unknown): boolean;
|
|
484
|
+
|
|
460
485
|
/**
|
|
461
486
|
* Checks if a string contains another string at the beginning of the string.
|
|
462
487
|
*
|
|
@@ -527,4 +552,4 @@ declare function max<T>(items?: readonly T[]): T;
|
|
|
527
552
|
*/
|
|
528
553
|
declare function min<T>(items?: readonly T[]): T;
|
|
529
554
|
|
|
530
|
-
export { chunk, concat, difference, endsWith, get, max, min, set, startsWith, zipObjectDeep };
|
|
555
|
+
export { chunk, concat, difference, endsWith, get, isPlainObject, max, min, set, startsWith, zipObjectDeep };
|
package/dist/compat/index.js
CHANGED
|
@@ -79,6 +79,7 @@ __export(compat_exports, {
|
|
|
79
79
|
flatMap: () => flatMap,
|
|
80
80
|
flatten: () => flatten,
|
|
81
81
|
flattenDeep: () => flattenDeep,
|
|
82
|
+
flattenObject: () => flattenObject,
|
|
82
83
|
forEachRight: () => forEachRight,
|
|
83
84
|
get: () => get,
|
|
84
85
|
groupBy: () => groupBy,
|
|
@@ -93,6 +94,7 @@ __export(compat_exports, {
|
|
|
93
94
|
isNil: () => isNil,
|
|
94
95
|
isNotNil: () => isNotNil,
|
|
95
96
|
isNull: () => isNull,
|
|
97
|
+
isPlainObject: () => isPlainObject2,
|
|
96
98
|
isUndefined: () => isUndefined,
|
|
97
99
|
kebabCase: () => kebabCase,
|
|
98
100
|
keyBy: () => keyBy,
|
|
@@ -926,6 +928,53 @@ function isPrimitive(value) {
|
|
|
926
928
|
return value == null || typeof value !== "object" && typeof value !== "function";
|
|
927
929
|
}
|
|
928
930
|
|
|
931
|
+
// src/predicate/isPlainObject.ts
|
|
932
|
+
function isPlainObject(object) {
|
|
933
|
+
if (typeof object !== "object") {
|
|
934
|
+
return false;
|
|
935
|
+
}
|
|
936
|
+
if (object == null) {
|
|
937
|
+
return false;
|
|
938
|
+
}
|
|
939
|
+
if (Object.getPrototypeOf(object) === null) {
|
|
940
|
+
return true;
|
|
941
|
+
}
|
|
942
|
+
if (object.toString() !== "[object Object]") {
|
|
943
|
+
return false;
|
|
944
|
+
}
|
|
945
|
+
let proto = object;
|
|
946
|
+
while (Object.getPrototypeOf(proto) !== null) {
|
|
947
|
+
proto = Object.getPrototypeOf(proto);
|
|
948
|
+
}
|
|
949
|
+
return Object.getPrototypeOf(object) === proto;
|
|
950
|
+
}
|
|
951
|
+
|
|
952
|
+
// src/object/flattenObject.ts
|
|
953
|
+
function flattenObject(object) {
|
|
954
|
+
return flattenObjectImpl(object);
|
|
955
|
+
}
|
|
956
|
+
function flattenObjectImpl(object, prefix = "") {
|
|
957
|
+
const result = {};
|
|
958
|
+
const keys = Object.keys(object);
|
|
959
|
+
for (let i = 0; i < keys.length; i++) {
|
|
960
|
+
const key = keys[i];
|
|
961
|
+
const value = object[key];
|
|
962
|
+
const prefixedKey = prefix ? `${prefix}.${key}` : key;
|
|
963
|
+
if (isPlainObject(value) && Object.keys(value).length > 0) {
|
|
964
|
+
Object.assign(result, flattenObjectImpl(value, prefixedKey));
|
|
965
|
+
continue;
|
|
966
|
+
}
|
|
967
|
+
if (Array.isArray(value)) {
|
|
968
|
+
for (let index = 0; index < value.length; index++) {
|
|
969
|
+
result[`${prefixedKey}.${index}`] = value[index];
|
|
970
|
+
}
|
|
971
|
+
continue;
|
|
972
|
+
}
|
|
973
|
+
result[prefixedKey] = value;
|
|
974
|
+
}
|
|
975
|
+
return result;
|
|
976
|
+
}
|
|
977
|
+
|
|
929
978
|
// src/predicate/isEqual.ts
|
|
930
979
|
function isEqual(a, b) {
|
|
931
980
|
if (Object.is(a, b)) {
|
|
@@ -1211,6 +1260,36 @@ function get(object, path, defaultValue) {
|
|
|
1211
1260
|
return current != null ? current : defaultValue;
|
|
1212
1261
|
}
|
|
1213
1262
|
|
|
1263
|
+
// src/compat/predicate/isPlainObject.ts
|
|
1264
|
+
function isPlainObject2(object) {
|
|
1265
|
+
var _a;
|
|
1266
|
+
if (typeof object !== "object") {
|
|
1267
|
+
return false;
|
|
1268
|
+
}
|
|
1269
|
+
if (object == null) {
|
|
1270
|
+
return false;
|
|
1271
|
+
}
|
|
1272
|
+
if (Object.getPrototypeOf(object) === null) {
|
|
1273
|
+
return true;
|
|
1274
|
+
}
|
|
1275
|
+
if (object.toString() !== "[object Object]") {
|
|
1276
|
+
const tag = object[Symbol.toStringTag];
|
|
1277
|
+
if (tag == null) {
|
|
1278
|
+
return false;
|
|
1279
|
+
}
|
|
1280
|
+
const isTagReadonly = !((_a = Object.getOwnPropertyDescriptor(object, Symbol.toStringTag)) == null ? void 0 : _a.writable);
|
|
1281
|
+
if (isTagReadonly) {
|
|
1282
|
+
return false;
|
|
1283
|
+
}
|
|
1284
|
+
return object.toString() === `[object ${tag}]`;
|
|
1285
|
+
}
|
|
1286
|
+
let proto = object;
|
|
1287
|
+
while (Object.getPrototypeOf(proto) !== null) {
|
|
1288
|
+
proto = Object.getPrototypeOf(proto);
|
|
1289
|
+
}
|
|
1290
|
+
return Object.getPrototypeOf(object) === proto;
|
|
1291
|
+
}
|
|
1292
|
+
|
|
1214
1293
|
// src/compat/string/startsWith.ts
|
|
1215
1294
|
var startsWith = (str, target, position = 0) => {
|
|
1216
1295
|
return str.startsWith(target, position);
|
|
@@ -1273,6 +1352,7 @@ function min(items = []) {
|
|
|
1273
1352
|
flatMap,
|
|
1274
1353
|
flatten,
|
|
1275
1354
|
flattenDeep,
|
|
1355
|
+
flattenObject,
|
|
1276
1356
|
forEachRight,
|
|
1277
1357
|
get,
|
|
1278
1358
|
groupBy,
|
|
@@ -1287,6 +1367,7 @@ function min(items = []) {
|
|
|
1287
1367
|
isNil,
|
|
1288
1368
|
isNotNil,
|
|
1289
1369
|
isNull,
|
|
1370
|
+
isPlainObject,
|
|
1290
1371
|
isUndefined,
|
|
1291
1372
|
kebabCase,
|
|
1292
1373
|
keyBy,
|