es-toolkit 1.35.0 → 1.36.0-dev.1215
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/CHANGELOG.md +12 -0
- package/dist/_chunk/{isPromise-ByAybB.js → isPromise-CxqI1v.js} +122 -36
- package/dist/_chunk/{reverseString-D-wK2p.js → reverseString-BixeGz.js} +84 -13
- package/dist/_chunk/toSnakeCaseKeys-DZO2eB.js +4901 -0
- package/dist/_chunk/{unary-BsNWRM.js → unary-EIEhcF.js} +46 -0
- package/dist/_chunk/{zip-_HttSl.js → zip-BJSrRi.js} +38 -57
- package/dist/array/index.js +55 -6
- package/dist/array/pullAt.d.mts +0 -2
- package/dist/array/pullAt.d.ts +0 -2
- package/dist/array/take.d.mts +1 -1
- package/dist/array/take.d.ts +1 -1
- package/dist/array/take.mjs +4 -1
- package/dist/array/takeRight.d.mts +1 -1
- package/dist/array/takeRight.d.ts +1 -1
- package/dist/array/takeRight.mjs +5 -2
- package/dist/browser.global.js +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/compat/_internal/copyArray.mjs +12 -0
- package/dist/compat/_internal/mapToEntries.mjs +11 -0
- package/dist/compat/_internal/setToEntries.mjs +11 -0
- package/dist/compat/_internal/toKey.mjs +2 -2
- package/dist/compat/array/find.mjs +3 -3
- package/dist/compat/array/findLast.mjs +2 -2
- package/dist/compat/array/flatMap.d.mts +20 -0
- package/dist/compat/array/flatMap.d.ts +20 -0
- package/dist/compat/array/flatMap.mjs +13 -0
- package/dist/compat/array/forEachRight.d.mts +106 -0
- package/dist/compat/array/forEachRight.d.ts +106 -0
- package/dist/compat/array/forEachRight.mjs +21 -0
- package/dist/compat/array/groupBy.d.mts +55 -0
- package/dist/compat/array/groupBy.d.ts +55 -0
- package/dist/compat/array/groupBy.mjs +15 -0
- package/dist/compat/array/partition.d.mts +65 -0
- package/dist/compat/array/partition.d.ts +65 -0
- package/dist/compat/array/partition.mjs +24 -0
- package/dist/compat/array/pullAllWith.d.mts +59 -0
- package/dist/compat/array/pullAllWith.d.ts +59 -0
- package/dist/compat/array/pullAllWith.mjs +33 -0
- package/dist/compat/array/pullAt.d.mts +32 -0
- package/dist/compat/array/pullAt.d.ts +32 -0
- package/dist/compat/array/pullAt.mjs +34 -0
- package/dist/compat/compat.d.mts +310 -0
- package/dist/compat/compat.d.ts +310 -0
- package/dist/compat/compat.mjs +312 -0
- package/dist/compat/function/partial.d.mts +575 -0
- package/dist/compat/function/partial.d.ts +575 -0
- package/dist/compat/function/partial.mjs +8 -0
- package/dist/compat/function/partialRight.d.mts +651 -0
- package/dist/compat/function/partialRight.d.ts +651 -0
- package/dist/compat/function/partialRight.mjs +8 -0
- package/dist/compat/index.d.mts +16 -7
- package/dist/compat/index.d.ts +16 -7
- package/dist/compat/index.js +290 -3771
- package/dist/compat/index.mjs +19 -8
- package/dist/compat/object/defaults.mjs +7 -1
- package/dist/compat/object/forIn.d.mts +58 -0
- package/dist/compat/object/forIn.d.ts +58 -0
- package/dist/compat/object/forIn.mjs +16 -0
- package/dist/compat/object/forInRight.d.mts +58 -0
- package/dist/compat/object/forInRight.d.ts +58 -0
- package/dist/compat/object/forInRight.mjs +21 -0
- package/dist/compat/object/forOwn.d.mts +54 -0
- package/dist/compat/object/forOwn.d.ts +54 -0
- package/dist/compat/object/forOwn.mjs +19 -0
- package/dist/compat/object/forOwnRight.d.mts +54 -0
- package/dist/compat/object/forOwnRight.d.ts +54 -0
- package/dist/compat/object/forOwnRight.mjs +19 -0
- package/dist/compat/object/hasIn.d.mts +40 -0
- package/dist/compat/object/hasIn.d.ts +40 -0
- package/dist/compat/object/hasIn.mjs +34 -0
- package/dist/compat/object/toPairs.mjs +7 -2
- package/dist/compat/object/toPairsIn.mjs +7 -2
- package/dist/compat/string/repeat.d.mts +1 -1
- package/dist/compat/string/repeat.d.ts +1 -1
- package/dist/compat/string/repeat.mjs +12 -2
- package/dist/compat/string/words.d.mts +1 -1
- package/dist/compat/string/words.d.ts +1 -1
- package/dist/compat/string/words.mjs +2 -1
- package/dist/compat/toolkit.d.mts +9 -0
- package/dist/compat/toolkit.d.ts +9 -0
- package/dist/compat/toolkit.mjs +10 -0
- package/dist/compat/util/overEvery.d.mts +67 -0
- package/dist/compat/util/overEvery.d.ts +67 -0
- package/dist/compat/util/overEvery.mjs +23 -0
- package/dist/compat/util/overSome.d.mts +69 -0
- package/dist/compat/util/overSome.d.ts +69 -0
- package/dist/compat/util/overSome.mjs +23 -0
- package/dist/function/index.js +3 -5
- package/dist/function/partial.d.mts +3 -3
- package/dist/function/partial.d.ts +3 -3
- package/dist/function/partial.mjs +17 -19
- package/dist/function/partialRight.d.mts +3 -3
- package/dist/function/partialRight.d.ts +3 -3
- package/dist/function/partialRight.mjs +18 -20
- package/dist/function/throttle.mjs +0 -1
- package/dist/index.js +39 -42
- package/dist/object/index.js +15 -15
- package/dist/object/toCamelCaseKeys.mjs +3 -0
- package/dist/object/toSnakeCaseKeys.mjs +3 -0
- package/dist/predicate/index.js +4 -5
- package/dist/string/index.js +7 -8
- package/package.json +1 -1
- package/dist/_chunk/isPlainObject-Xaozpc.js +0 -93
- package/dist/_chunk/partialRight-B0_CSB.js +0 -50
- package/dist/_chunk/snakeCase-BtVEeB.js +0 -75
- package/dist/_chunk/toSnakeCaseKeys-BNpS71.js +0 -569
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
function capitalize(str) {
|
|
4
|
-
return (str.charAt(0).toUpperCase() + str.slice(1).toLowerCase());
|
|
5
|
-
}
|
|
6
|
-
|
|
7
|
-
const CASE_SPLIT_PATTERN = /\p{Lu}?\p{Ll}+|[0-9]+|\p{Lu}+(?!\p{Ll})|\p{Emoji_Presentation}|\p{Extended_Pictographic}|\p{L}+/gu;
|
|
8
|
-
function words(str) {
|
|
9
|
-
return Array.from(str.match(CASE_SPLIT_PATTERN) ?? []);
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
function camelCase(str) {
|
|
13
|
-
const words$1 = words(str);
|
|
14
|
-
if (words$1.length === 0) {
|
|
15
|
-
return '';
|
|
16
|
-
}
|
|
17
|
-
const [first, ...rest] = words$1;
|
|
18
|
-
return `${first.toLowerCase()}${rest.map(word => capitalize(word)).join('')}`;
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
const deburrMap = new Map(Object.entries({
|
|
22
|
-
Æ: 'Ae',
|
|
23
|
-
Ð: 'D',
|
|
24
|
-
Ø: 'O',
|
|
25
|
-
Þ: 'Th',
|
|
26
|
-
ß: 'ss',
|
|
27
|
-
æ: 'ae',
|
|
28
|
-
ð: 'd',
|
|
29
|
-
ø: 'o',
|
|
30
|
-
þ: 'th',
|
|
31
|
-
Đ: 'D',
|
|
32
|
-
đ: 'd',
|
|
33
|
-
Ħ: 'H',
|
|
34
|
-
ħ: 'h',
|
|
35
|
-
ı: 'i',
|
|
36
|
-
IJ: 'IJ',
|
|
37
|
-
ij: 'ij',
|
|
38
|
-
ĸ: 'k',
|
|
39
|
-
Ŀ: 'L',
|
|
40
|
-
ŀ: 'l',
|
|
41
|
-
Ł: 'L',
|
|
42
|
-
ł: 'l',
|
|
43
|
-
ʼn: "'n",
|
|
44
|
-
Ŋ: 'N',
|
|
45
|
-
ŋ: 'n',
|
|
46
|
-
Œ: 'Oe',
|
|
47
|
-
œ: 'oe',
|
|
48
|
-
Ŧ: 'T',
|
|
49
|
-
ŧ: 't',
|
|
50
|
-
ſ: 's',
|
|
51
|
-
}));
|
|
52
|
-
function deburr(str) {
|
|
53
|
-
str = str.normalize('NFD');
|
|
54
|
-
let result = '';
|
|
55
|
-
for (let i = 0; i < str.length; i++) {
|
|
56
|
-
const char = str[i];
|
|
57
|
-
if ((char >= '\u0300' && char <= '\u036f') || (char >= '\ufe20' && char <= '\ufe23')) {
|
|
58
|
-
continue;
|
|
59
|
-
}
|
|
60
|
-
result += deburrMap.get(char) ?? char;
|
|
61
|
-
}
|
|
62
|
-
return result;
|
|
63
|
-
}
|
|
64
|
-
|
|
65
|
-
function snakeCase(str) {
|
|
66
|
-
const words$1 = words(str);
|
|
67
|
-
return words$1.map(word => word.toLowerCase()).join('_');
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
exports.CASE_SPLIT_PATTERN = CASE_SPLIT_PATTERN;
|
|
71
|
-
exports.camelCase = camelCase;
|
|
72
|
-
exports.capitalize = capitalize;
|
|
73
|
-
exports.deburr = deburr;
|
|
74
|
-
exports.snakeCase = snakeCase;
|
|
75
|
-
exports.words = words;
|
|
@@ -1,569 +0,0 @@
|
|
|
1
|
-
'use strict';
|
|
2
|
-
|
|
3
|
-
const isPlainObject$1 = require('./isPlainObject-Xaozpc.js');
|
|
4
|
-
require('./partialRight-B0_CSB.js');
|
|
5
|
-
const snakeCase = require('./snakeCase-BtVEeB.js');
|
|
6
|
-
|
|
7
|
-
function clone(obj) {
|
|
8
|
-
if (isPlainObject$1.isPrimitive(obj)) {
|
|
9
|
-
return obj;
|
|
10
|
-
}
|
|
11
|
-
if (Array.isArray(obj) ||
|
|
12
|
-
isPlainObject$1.isTypedArray(obj) ||
|
|
13
|
-
obj instanceof ArrayBuffer ||
|
|
14
|
-
(typeof SharedArrayBuffer !== 'undefined' && obj instanceof SharedArrayBuffer)) {
|
|
15
|
-
return obj.slice(0);
|
|
16
|
-
}
|
|
17
|
-
const prototype = Object.getPrototypeOf(obj);
|
|
18
|
-
const Constructor = prototype.constructor;
|
|
19
|
-
if (obj instanceof Date || obj instanceof Map || obj instanceof Set) {
|
|
20
|
-
return new Constructor(obj);
|
|
21
|
-
}
|
|
22
|
-
if (obj instanceof RegExp) {
|
|
23
|
-
const newRegExp = new Constructor(obj);
|
|
24
|
-
newRegExp.lastIndex = obj.lastIndex;
|
|
25
|
-
return newRegExp;
|
|
26
|
-
}
|
|
27
|
-
if (obj instanceof DataView) {
|
|
28
|
-
return new Constructor(obj.buffer.slice(0));
|
|
29
|
-
}
|
|
30
|
-
if (obj instanceof Error) {
|
|
31
|
-
const newError = new Constructor(obj.message);
|
|
32
|
-
newError.stack = obj.stack;
|
|
33
|
-
newError.name = obj.name;
|
|
34
|
-
newError.cause = obj.cause;
|
|
35
|
-
return newError;
|
|
36
|
-
}
|
|
37
|
-
if (typeof File !== 'undefined' && obj instanceof File) {
|
|
38
|
-
const newFile = new Constructor([obj], obj.name, { type: obj.type, lastModified: obj.lastModified });
|
|
39
|
-
return newFile;
|
|
40
|
-
}
|
|
41
|
-
if (typeof obj === 'object') {
|
|
42
|
-
const newObject = Object.create(prototype);
|
|
43
|
-
return Object.assign(newObject, obj);
|
|
44
|
-
}
|
|
45
|
-
return obj;
|
|
46
|
-
}
|
|
47
|
-
|
|
48
|
-
function cloneDeepWith(obj, cloneValue) {
|
|
49
|
-
return cloneDeepWithImpl(obj, undefined, obj, new Map(), cloneValue);
|
|
50
|
-
}
|
|
51
|
-
function cloneDeepWithImpl(valueToClone, keyToClone, objectToClone, stack = new Map(), cloneValue = undefined) {
|
|
52
|
-
const cloned = cloneValue?.(valueToClone, keyToClone, objectToClone, stack);
|
|
53
|
-
if (cloned != null) {
|
|
54
|
-
return cloned;
|
|
55
|
-
}
|
|
56
|
-
if (isPlainObject$1.isPrimitive(valueToClone)) {
|
|
57
|
-
return valueToClone;
|
|
58
|
-
}
|
|
59
|
-
if (stack.has(valueToClone)) {
|
|
60
|
-
return stack.get(valueToClone);
|
|
61
|
-
}
|
|
62
|
-
if (Array.isArray(valueToClone)) {
|
|
63
|
-
const result = new Array(valueToClone.length);
|
|
64
|
-
stack.set(valueToClone, result);
|
|
65
|
-
for (let i = 0; i < valueToClone.length; i++) {
|
|
66
|
-
result[i] = cloneDeepWithImpl(valueToClone[i], i, objectToClone, stack, cloneValue);
|
|
67
|
-
}
|
|
68
|
-
if (Object.hasOwn(valueToClone, 'index')) {
|
|
69
|
-
result.index = valueToClone.index;
|
|
70
|
-
}
|
|
71
|
-
if (Object.hasOwn(valueToClone, 'input')) {
|
|
72
|
-
result.input = valueToClone.input;
|
|
73
|
-
}
|
|
74
|
-
return result;
|
|
75
|
-
}
|
|
76
|
-
if (valueToClone instanceof Date) {
|
|
77
|
-
return new Date(valueToClone.getTime());
|
|
78
|
-
}
|
|
79
|
-
if (valueToClone instanceof RegExp) {
|
|
80
|
-
const result = new RegExp(valueToClone.source, valueToClone.flags);
|
|
81
|
-
result.lastIndex = valueToClone.lastIndex;
|
|
82
|
-
return result;
|
|
83
|
-
}
|
|
84
|
-
if (valueToClone instanceof Map) {
|
|
85
|
-
const result = new Map();
|
|
86
|
-
stack.set(valueToClone, result);
|
|
87
|
-
for (const [key, value] of valueToClone) {
|
|
88
|
-
result.set(key, cloneDeepWithImpl(value, key, objectToClone, stack, cloneValue));
|
|
89
|
-
}
|
|
90
|
-
return result;
|
|
91
|
-
}
|
|
92
|
-
if (valueToClone instanceof Set) {
|
|
93
|
-
const result = new Set();
|
|
94
|
-
stack.set(valueToClone, result);
|
|
95
|
-
for (const value of valueToClone) {
|
|
96
|
-
result.add(cloneDeepWithImpl(value, undefined, objectToClone, stack, cloneValue));
|
|
97
|
-
}
|
|
98
|
-
return result;
|
|
99
|
-
}
|
|
100
|
-
if (typeof Buffer !== 'undefined' && Buffer.isBuffer(valueToClone)) {
|
|
101
|
-
return valueToClone.subarray();
|
|
102
|
-
}
|
|
103
|
-
if (isPlainObject$1.isTypedArray(valueToClone)) {
|
|
104
|
-
const result = new (Object.getPrototypeOf(valueToClone).constructor)(valueToClone.length);
|
|
105
|
-
stack.set(valueToClone, result);
|
|
106
|
-
for (let i = 0; i < valueToClone.length; i++) {
|
|
107
|
-
result[i] = cloneDeepWithImpl(valueToClone[i], i, objectToClone, stack, cloneValue);
|
|
108
|
-
}
|
|
109
|
-
return result;
|
|
110
|
-
}
|
|
111
|
-
if (valueToClone instanceof ArrayBuffer ||
|
|
112
|
-
(typeof SharedArrayBuffer !== 'undefined' && valueToClone instanceof SharedArrayBuffer)) {
|
|
113
|
-
return valueToClone.slice(0);
|
|
114
|
-
}
|
|
115
|
-
if (valueToClone instanceof DataView) {
|
|
116
|
-
const result = new DataView(valueToClone.buffer.slice(0), valueToClone.byteOffset, valueToClone.byteLength);
|
|
117
|
-
stack.set(valueToClone, result);
|
|
118
|
-
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
|
119
|
-
return result;
|
|
120
|
-
}
|
|
121
|
-
if (typeof File !== 'undefined' && valueToClone instanceof File) {
|
|
122
|
-
const result = new File([valueToClone], valueToClone.name, {
|
|
123
|
-
type: valueToClone.type,
|
|
124
|
-
});
|
|
125
|
-
stack.set(valueToClone, result);
|
|
126
|
-
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
|
127
|
-
return result;
|
|
128
|
-
}
|
|
129
|
-
if (valueToClone instanceof Blob) {
|
|
130
|
-
const result = new Blob([valueToClone], { type: valueToClone.type });
|
|
131
|
-
stack.set(valueToClone, result);
|
|
132
|
-
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
|
133
|
-
return result;
|
|
134
|
-
}
|
|
135
|
-
if (valueToClone instanceof Error) {
|
|
136
|
-
const result = new valueToClone.constructor();
|
|
137
|
-
stack.set(valueToClone, result);
|
|
138
|
-
result.message = valueToClone.message;
|
|
139
|
-
result.name = valueToClone.name;
|
|
140
|
-
result.stack = valueToClone.stack;
|
|
141
|
-
result.cause = valueToClone.cause;
|
|
142
|
-
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
|
143
|
-
return result;
|
|
144
|
-
}
|
|
145
|
-
if (typeof valueToClone === 'object' && isCloneableObject(valueToClone)) {
|
|
146
|
-
const result = Object.create(Object.getPrototypeOf(valueToClone));
|
|
147
|
-
stack.set(valueToClone, result);
|
|
148
|
-
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
|
149
|
-
return result;
|
|
150
|
-
}
|
|
151
|
-
return valueToClone;
|
|
152
|
-
}
|
|
153
|
-
function copyProperties(target, source, objectToClone = target, stack, cloneValue) {
|
|
154
|
-
const keys = [...Object.keys(source), ...isPlainObject$1.getSymbols(source)];
|
|
155
|
-
for (let i = 0; i < keys.length; i++) {
|
|
156
|
-
const key = keys[i];
|
|
157
|
-
const descriptor = Object.getOwnPropertyDescriptor(target, key);
|
|
158
|
-
if (descriptor == null || descriptor.writable) {
|
|
159
|
-
target[key] = cloneDeepWithImpl(source[key], key, objectToClone, stack, cloneValue);
|
|
160
|
-
}
|
|
161
|
-
}
|
|
162
|
-
}
|
|
163
|
-
function isCloneableObject(object) {
|
|
164
|
-
switch (isPlainObject$1.getTag(object)) {
|
|
165
|
-
case isPlainObject$1.argumentsTag:
|
|
166
|
-
case isPlainObject$1.arrayTag:
|
|
167
|
-
case isPlainObject$1.arrayBufferTag:
|
|
168
|
-
case isPlainObject$1.dataViewTag:
|
|
169
|
-
case isPlainObject$1.booleanTag:
|
|
170
|
-
case isPlainObject$1.dateTag:
|
|
171
|
-
case isPlainObject$1.float32ArrayTag:
|
|
172
|
-
case isPlainObject$1.float64ArrayTag:
|
|
173
|
-
case isPlainObject$1.int8ArrayTag:
|
|
174
|
-
case isPlainObject$1.int16ArrayTag:
|
|
175
|
-
case isPlainObject$1.int32ArrayTag:
|
|
176
|
-
case isPlainObject$1.mapTag:
|
|
177
|
-
case isPlainObject$1.numberTag:
|
|
178
|
-
case isPlainObject$1.objectTag:
|
|
179
|
-
case isPlainObject$1.regexpTag:
|
|
180
|
-
case isPlainObject$1.setTag:
|
|
181
|
-
case isPlainObject$1.stringTag:
|
|
182
|
-
case isPlainObject$1.symbolTag:
|
|
183
|
-
case isPlainObject$1.uint8ArrayTag:
|
|
184
|
-
case isPlainObject$1.uint8ClampedArrayTag:
|
|
185
|
-
case isPlainObject$1.uint16ArrayTag:
|
|
186
|
-
case isPlainObject$1.uint32ArrayTag: {
|
|
187
|
-
return true;
|
|
188
|
-
}
|
|
189
|
-
default: {
|
|
190
|
-
return false;
|
|
191
|
-
}
|
|
192
|
-
}
|
|
193
|
-
}
|
|
194
|
-
|
|
195
|
-
function cloneDeep(obj) {
|
|
196
|
-
return cloneDeepWithImpl(obj, undefined, obj, new Map(), undefined);
|
|
197
|
-
}
|
|
198
|
-
|
|
199
|
-
function findKey(obj, predicate) {
|
|
200
|
-
const keys = Object.keys(obj);
|
|
201
|
-
return keys.find(key => predicate(obj[key], key, obj));
|
|
202
|
-
}
|
|
203
|
-
|
|
204
|
-
function flattenObject(object, { delimiter = '.' } = {}) {
|
|
205
|
-
return flattenObjectImpl(object, '', delimiter);
|
|
206
|
-
}
|
|
207
|
-
function flattenObjectImpl(object, prefix = '', delimiter = '.') {
|
|
208
|
-
const result = {};
|
|
209
|
-
const keys = Object.keys(object);
|
|
210
|
-
for (let i = 0; i < keys.length; i++) {
|
|
211
|
-
const key = keys[i];
|
|
212
|
-
const value = object[key];
|
|
213
|
-
const prefixedKey = prefix ? `${prefix}${delimiter}${key}` : key;
|
|
214
|
-
if (isPlainObject$1.isPlainObject(value) && Object.keys(value).length > 0) {
|
|
215
|
-
Object.assign(result, flattenObjectImpl(value, prefixedKey, delimiter));
|
|
216
|
-
continue;
|
|
217
|
-
}
|
|
218
|
-
if (Array.isArray(value)) {
|
|
219
|
-
Object.assign(result, flattenObjectImpl(value, prefixedKey, delimiter));
|
|
220
|
-
continue;
|
|
221
|
-
}
|
|
222
|
-
result[prefixedKey] = value;
|
|
223
|
-
}
|
|
224
|
-
return result;
|
|
225
|
-
}
|
|
226
|
-
|
|
227
|
-
function invert(obj) {
|
|
228
|
-
const result = {};
|
|
229
|
-
const keys = Object.keys(obj);
|
|
230
|
-
for (let i = 0; i < keys.length; i++) {
|
|
231
|
-
const key = keys[i];
|
|
232
|
-
const value = obj[key];
|
|
233
|
-
result[value] = key;
|
|
234
|
-
}
|
|
235
|
-
return result;
|
|
236
|
-
}
|
|
237
|
-
|
|
238
|
-
function mapKeys(object, getNewKey) {
|
|
239
|
-
const result = {};
|
|
240
|
-
const keys = Object.keys(object);
|
|
241
|
-
for (let i = 0; i < keys.length; i++) {
|
|
242
|
-
const key = keys[i];
|
|
243
|
-
const value = object[key];
|
|
244
|
-
result[getNewKey(value, key, object)] = value;
|
|
245
|
-
}
|
|
246
|
-
return result;
|
|
247
|
-
}
|
|
248
|
-
|
|
249
|
-
function mapValues(object, getNewValue) {
|
|
250
|
-
const result = {};
|
|
251
|
-
const keys = Object.keys(object);
|
|
252
|
-
for (let i = 0; i < keys.length; i++) {
|
|
253
|
-
const key = keys[i];
|
|
254
|
-
const value = object[key];
|
|
255
|
-
result[key] = getNewValue(value, key, object);
|
|
256
|
-
}
|
|
257
|
-
return result;
|
|
258
|
-
}
|
|
259
|
-
|
|
260
|
-
function merge(target, source) {
|
|
261
|
-
const sourceKeys = Object.keys(source);
|
|
262
|
-
for (let i = 0; i < sourceKeys.length; i++) {
|
|
263
|
-
const key = sourceKeys[i];
|
|
264
|
-
const sourceValue = source[key];
|
|
265
|
-
const targetValue = target[key];
|
|
266
|
-
if (Array.isArray(sourceValue)) {
|
|
267
|
-
if (Array.isArray(targetValue)) {
|
|
268
|
-
target[key] = merge(targetValue, sourceValue);
|
|
269
|
-
}
|
|
270
|
-
else {
|
|
271
|
-
target[key] = merge([], sourceValue);
|
|
272
|
-
}
|
|
273
|
-
}
|
|
274
|
-
else if (isPlainObject$1.isPlainObject(sourceValue)) {
|
|
275
|
-
if (isPlainObject$1.isPlainObject(targetValue)) {
|
|
276
|
-
target[key] = merge(targetValue, sourceValue);
|
|
277
|
-
}
|
|
278
|
-
else {
|
|
279
|
-
target[key] = merge({}, sourceValue);
|
|
280
|
-
}
|
|
281
|
-
}
|
|
282
|
-
else if (targetValue === undefined || sourceValue !== undefined) {
|
|
283
|
-
target[key] = sourceValue;
|
|
284
|
-
}
|
|
285
|
-
}
|
|
286
|
-
return target;
|
|
287
|
-
}
|
|
288
|
-
|
|
289
|
-
function isObjectLike(value) {
|
|
290
|
-
return typeof value === 'object' && value !== null;
|
|
291
|
-
}
|
|
292
|
-
|
|
293
|
-
function omitBy(obj, shouldOmit) {
|
|
294
|
-
const result = {};
|
|
295
|
-
const keys = Object.keys(obj);
|
|
296
|
-
for (let i = 0; i < keys.length; i++) {
|
|
297
|
-
const key = keys[i];
|
|
298
|
-
const value = obj[key];
|
|
299
|
-
if (!shouldOmit(value, key)) {
|
|
300
|
-
result[key] = value;
|
|
301
|
-
}
|
|
302
|
-
}
|
|
303
|
-
return result;
|
|
304
|
-
}
|
|
305
|
-
|
|
306
|
-
function isArray(value) {
|
|
307
|
-
return Array.isArray(value);
|
|
308
|
-
}
|
|
309
|
-
|
|
310
|
-
function bind(func, thisObj, ...partialArgs) {
|
|
311
|
-
const bound = function (...providedArgs) {
|
|
312
|
-
const args = [];
|
|
313
|
-
let startIndex = 0;
|
|
314
|
-
for (let i = 0; i < partialArgs.length; i++) {
|
|
315
|
-
const arg = partialArgs[i];
|
|
316
|
-
if (arg === bind.placeholder) {
|
|
317
|
-
args.push(providedArgs[startIndex++]);
|
|
318
|
-
}
|
|
319
|
-
else {
|
|
320
|
-
args.push(arg);
|
|
321
|
-
}
|
|
322
|
-
}
|
|
323
|
-
for (let i = startIndex; i < providedArgs.length; i++) {
|
|
324
|
-
args.push(providedArgs[i]);
|
|
325
|
-
}
|
|
326
|
-
if (this instanceof bound) {
|
|
327
|
-
return new func(...args);
|
|
328
|
-
}
|
|
329
|
-
return func.apply(thisObj, args);
|
|
330
|
-
};
|
|
331
|
-
return bound;
|
|
332
|
-
}
|
|
333
|
-
const bindPlaceholder = Symbol('bind.placeholder');
|
|
334
|
-
bind.placeholder = bindPlaceholder;
|
|
335
|
-
|
|
336
|
-
function bindKey(object, key, ...partialArgs) {
|
|
337
|
-
const bound = function (...providedArgs) {
|
|
338
|
-
const args = [];
|
|
339
|
-
let startIndex = 0;
|
|
340
|
-
for (let i = 0; i < partialArgs.length; i++) {
|
|
341
|
-
const arg = partialArgs[i];
|
|
342
|
-
if (arg === bindKey.placeholder) {
|
|
343
|
-
args.push(providedArgs[startIndex++]);
|
|
344
|
-
}
|
|
345
|
-
else {
|
|
346
|
-
args.push(arg);
|
|
347
|
-
}
|
|
348
|
-
}
|
|
349
|
-
for (let i = startIndex; i < providedArgs.length; i++) {
|
|
350
|
-
args.push(providedArgs[i]);
|
|
351
|
-
}
|
|
352
|
-
if (this instanceof bound) {
|
|
353
|
-
return new object[key](...args);
|
|
354
|
-
}
|
|
355
|
-
return object[key].apply(object, args);
|
|
356
|
-
};
|
|
357
|
-
return bound;
|
|
358
|
-
}
|
|
359
|
-
const bindKeyPlaceholder = Symbol('bindKey.placeholder');
|
|
360
|
-
bindKey.placeholder = bindKeyPlaceholder;
|
|
361
|
-
|
|
362
|
-
function curry(func, arity = func.length, guard) {
|
|
363
|
-
arity = guard ? func.length : arity;
|
|
364
|
-
arity = Number.parseInt(arity, 10);
|
|
365
|
-
if (Number.isNaN(arity) || arity < 1) {
|
|
366
|
-
arity = 0;
|
|
367
|
-
}
|
|
368
|
-
const wrapper = function (...partialArgs) {
|
|
369
|
-
const holders = partialArgs.filter(item => item === curry.placeholder);
|
|
370
|
-
const length = partialArgs.length - holders.length;
|
|
371
|
-
if (length < arity) {
|
|
372
|
-
return makeCurry(func, arity - length, partialArgs);
|
|
373
|
-
}
|
|
374
|
-
if (this instanceof wrapper) {
|
|
375
|
-
return new func(...partialArgs);
|
|
376
|
-
}
|
|
377
|
-
return func.apply(this, partialArgs);
|
|
378
|
-
};
|
|
379
|
-
wrapper.placeholder = curryPlaceholder;
|
|
380
|
-
return wrapper;
|
|
381
|
-
}
|
|
382
|
-
function makeCurry(func, arity, partialArgs) {
|
|
383
|
-
function wrapper(...providedArgs) {
|
|
384
|
-
const holders = providedArgs.filter(item => item === curry.placeholder);
|
|
385
|
-
const length = providedArgs.length - holders.length;
|
|
386
|
-
providedArgs = composeArgs$1(providedArgs, partialArgs);
|
|
387
|
-
if (length < arity) {
|
|
388
|
-
return makeCurry(func, arity - length, providedArgs);
|
|
389
|
-
}
|
|
390
|
-
if (this instanceof wrapper) {
|
|
391
|
-
return new func(...providedArgs);
|
|
392
|
-
}
|
|
393
|
-
return func.apply(this, providedArgs);
|
|
394
|
-
}
|
|
395
|
-
wrapper.placeholder = curryPlaceholder;
|
|
396
|
-
return wrapper;
|
|
397
|
-
}
|
|
398
|
-
function composeArgs$1(providedArgs, partialArgs) {
|
|
399
|
-
const args = [];
|
|
400
|
-
let startIndex = 0;
|
|
401
|
-
for (let i = 0; i < partialArgs.length; i++) {
|
|
402
|
-
const arg = partialArgs[i];
|
|
403
|
-
if (arg === curry.placeholder && startIndex < providedArgs.length) {
|
|
404
|
-
args.push(providedArgs[startIndex++]);
|
|
405
|
-
}
|
|
406
|
-
else {
|
|
407
|
-
args.push(arg);
|
|
408
|
-
}
|
|
409
|
-
}
|
|
410
|
-
for (let i = startIndex; i < providedArgs.length; i++) {
|
|
411
|
-
args.push(providedArgs[i]);
|
|
412
|
-
}
|
|
413
|
-
return args;
|
|
414
|
-
}
|
|
415
|
-
const curryPlaceholder = Symbol('curry.placeholder');
|
|
416
|
-
curry.placeholder = curryPlaceholder;
|
|
417
|
-
|
|
418
|
-
function curryRight(func, arity = func.length, guard) {
|
|
419
|
-
arity = guard ? func.length : arity;
|
|
420
|
-
arity = Number.parseInt(arity, 10);
|
|
421
|
-
if (Number.isNaN(arity) || arity < 1) {
|
|
422
|
-
arity = 0;
|
|
423
|
-
}
|
|
424
|
-
const wrapper = function (...partialArgs) {
|
|
425
|
-
const holders = partialArgs.filter(item => item === curryRight.placeholder);
|
|
426
|
-
const length = partialArgs.length - holders.length;
|
|
427
|
-
if (length < arity) {
|
|
428
|
-
return makeCurryRight(func, arity - length, partialArgs);
|
|
429
|
-
}
|
|
430
|
-
if (this instanceof wrapper) {
|
|
431
|
-
return new func(...partialArgs);
|
|
432
|
-
}
|
|
433
|
-
return func.apply(this, partialArgs);
|
|
434
|
-
};
|
|
435
|
-
wrapper.placeholder = curryRightPlaceholder;
|
|
436
|
-
return wrapper;
|
|
437
|
-
}
|
|
438
|
-
function makeCurryRight(func, arity, partialArgs) {
|
|
439
|
-
function wrapper(...providedArgs) {
|
|
440
|
-
const holders = providedArgs.filter(item => item === curryRight.placeholder);
|
|
441
|
-
const length = providedArgs.length - holders.length;
|
|
442
|
-
providedArgs = composeArgs(providedArgs, partialArgs);
|
|
443
|
-
if (length < arity) {
|
|
444
|
-
return makeCurryRight(func, arity - length, providedArgs);
|
|
445
|
-
}
|
|
446
|
-
if (this instanceof wrapper) {
|
|
447
|
-
return new func(...providedArgs);
|
|
448
|
-
}
|
|
449
|
-
return func.apply(this, providedArgs);
|
|
450
|
-
}
|
|
451
|
-
wrapper.placeholder = curryRightPlaceholder;
|
|
452
|
-
return wrapper;
|
|
453
|
-
}
|
|
454
|
-
function composeArgs(providedArgs, partialArgs) {
|
|
455
|
-
const placeholderLength = partialArgs.filter(arg => arg === curryRight.placeholder).length;
|
|
456
|
-
const rangeLength = Math.max(providedArgs.length - placeholderLength, 0);
|
|
457
|
-
const args = [];
|
|
458
|
-
let providedIndex = 0;
|
|
459
|
-
for (let i = 0; i < rangeLength; i++) {
|
|
460
|
-
args.push(providedArgs[providedIndex++]);
|
|
461
|
-
}
|
|
462
|
-
for (let i = 0; i < partialArgs.length; i++) {
|
|
463
|
-
const arg = partialArgs[i];
|
|
464
|
-
if (arg === curryRight.placeholder) {
|
|
465
|
-
if (providedIndex < providedArgs.length) {
|
|
466
|
-
args.push(providedArgs[providedIndex++]);
|
|
467
|
-
}
|
|
468
|
-
else {
|
|
469
|
-
args.push(arg);
|
|
470
|
-
}
|
|
471
|
-
}
|
|
472
|
-
else {
|
|
473
|
-
args.push(arg);
|
|
474
|
-
}
|
|
475
|
-
}
|
|
476
|
-
return args;
|
|
477
|
-
}
|
|
478
|
-
const curryRightPlaceholder = Symbol('curryRight.placeholder');
|
|
479
|
-
curryRight.placeholder = curryRightPlaceholder;
|
|
480
|
-
|
|
481
|
-
function isPlainObject(object) {
|
|
482
|
-
if (typeof object !== 'object') {
|
|
483
|
-
return false;
|
|
484
|
-
}
|
|
485
|
-
if (object == null) {
|
|
486
|
-
return false;
|
|
487
|
-
}
|
|
488
|
-
if (Object.getPrototypeOf(object) === null) {
|
|
489
|
-
return true;
|
|
490
|
-
}
|
|
491
|
-
if (Object.prototype.toString.call(object) !== '[object Object]') {
|
|
492
|
-
const tag = object[Symbol.toStringTag];
|
|
493
|
-
if (tag == null) {
|
|
494
|
-
return false;
|
|
495
|
-
}
|
|
496
|
-
const isTagReadonly = !Object.getOwnPropertyDescriptor(object, Symbol.toStringTag)?.writable;
|
|
497
|
-
if (isTagReadonly) {
|
|
498
|
-
return false;
|
|
499
|
-
}
|
|
500
|
-
return object.toString() === `[object ${tag}]`;
|
|
501
|
-
}
|
|
502
|
-
let proto = object;
|
|
503
|
-
while (Object.getPrototypeOf(proto) !== null) {
|
|
504
|
-
proto = Object.getPrototypeOf(proto);
|
|
505
|
-
}
|
|
506
|
-
return Object.getPrototypeOf(object) === proto;
|
|
507
|
-
}
|
|
508
|
-
|
|
509
|
-
function toCamelCaseKeys(obj) {
|
|
510
|
-
if (isArray(obj)) {
|
|
511
|
-
return obj.map(item => toCamelCaseKeys(item));
|
|
512
|
-
}
|
|
513
|
-
if (isPlainObject(obj)) {
|
|
514
|
-
const result = {};
|
|
515
|
-
const keys = Object.keys(obj);
|
|
516
|
-
for (let i = 0; i < keys.length; i++) {
|
|
517
|
-
const key = keys[i];
|
|
518
|
-
const camelKey = snakeCase.camelCase(key);
|
|
519
|
-
const camelCaseKeys = toCamelCaseKeys(obj[key]);
|
|
520
|
-
result[camelKey] = camelCaseKeys;
|
|
521
|
-
}
|
|
522
|
-
return result;
|
|
523
|
-
}
|
|
524
|
-
return obj;
|
|
525
|
-
}
|
|
526
|
-
|
|
527
|
-
function toMerged(target, source) {
|
|
528
|
-
return merge(cloneDeep(target), source);
|
|
529
|
-
}
|
|
530
|
-
|
|
531
|
-
function toSnakeCaseKeys(obj) {
|
|
532
|
-
if (isArray(obj)) {
|
|
533
|
-
return obj.map(item => toSnakeCaseKeys(item));
|
|
534
|
-
}
|
|
535
|
-
if (isPlainObject(obj)) {
|
|
536
|
-
const result = {};
|
|
537
|
-
const keys = Object.keys(obj);
|
|
538
|
-
for (let i = 0; i < keys.length; i++) {
|
|
539
|
-
const key = keys[i];
|
|
540
|
-
const snakeKey = snakeCase.snakeCase(key);
|
|
541
|
-
const snakeCaseKeys = toSnakeCaseKeys(obj[key]);
|
|
542
|
-
result[snakeKey] = snakeCaseKeys;
|
|
543
|
-
}
|
|
544
|
-
return result;
|
|
545
|
-
}
|
|
546
|
-
return obj;
|
|
547
|
-
}
|
|
548
|
-
|
|
549
|
-
exports.bind = bind;
|
|
550
|
-
exports.bindKey = bindKey;
|
|
551
|
-
exports.clone = clone;
|
|
552
|
-
exports.cloneDeep = cloneDeep;
|
|
553
|
-
exports.cloneDeepWith = cloneDeepWith;
|
|
554
|
-
exports.copyProperties = copyProperties;
|
|
555
|
-
exports.curry = curry;
|
|
556
|
-
exports.curryRight = curryRight;
|
|
557
|
-
exports.findKey = findKey;
|
|
558
|
-
exports.flattenObject = flattenObject;
|
|
559
|
-
exports.invert = invert;
|
|
560
|
-
exports.isArray = isArray;
|
|
561
|
-
exports.isObjectLike = isObjectLike;
|
|
562
|
-
exports.isPlainObject = isPlainObject;
|
|
563
|
-
exports.mapKeys = mapKeys;
|
|
564
|
-
exports.mapValues = mapValues;
|
|
565
|
-
exports.merge = merge;
|
|
566
|
-
exports.omitBy = omitBy;
|
|
567
|
-
exports.toCamelCaseKeys = toCamelCaseKeys;
|
|
568
|
-
exports.toMerged = toMerged;
|
|
569
|
-
exports.toSnakeCaseKeys = toSnakeCaseKeys;
|