es-toolkit 1.31.0-dev.997 → 1.31.0-dev.999
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/_chunk/isPlainObject-Xaozpc.js +93 -0
- package/dist/_chunk/{isWeakSet-BgjERb.js → isWeakSet-BW79-8.js} +32 -71
- package/dist/_chunk/{toMerged-NG176l.js → toMerged-BQTfB8.js} +33 -2
- package/dist/browser.global.js +1 -1
- package/dist/browser.global.js.map +1 -1
- package/dist/compat/index.js +9 -9
- package/dist/index.js +3 -3
- package/dist/object/cloneDeepWith.mjs +34 -1
- package/dist/object/index.js +1 -1
- package/dist/predicate/index.js +2 -2
- package/package.json +2 -1
- package/dist/_chunk/isPlainObject-octpoD.js +0 -32
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
function isPrimitive(value) {
|
|
4
|
+
return value == null || (typeof value !== 'object' && typeof value !== 'function');
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
function isTypedArray(x) {
|
|
8
|
+
return ArrayBuffer.isView(x) && !(x instanceof DataView);
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
function getSymbols(object) {
|
|
12
|
+
return Object.getOwnPropertySymbols(object).filter(symbol => Object.prototype.propertyIsEnumerable.call(object, symbol));
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
function getTag(value) {
|
|
16
|
+
if (value == null) {
|
|
17
|
+
return value === undefined ? '[object Undefined]' : '[object Null]';
|
|
18
|
+
}
|
|
19
|
+
return Object.prototype.toString.call(value);
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
const regexpTag = '[object RegExp]';
|
|
23
|
+
const stringTag = '[object String]';
|
|
24
|
+
const numberTag = '[object Number]';
|
|
25
|
+
const booleanTag = '[object Boolean]';
|
|
26
|
+
const argumentsTag = '[object Arguments]';
|
|
27
|
+
const symbolTag = '[object Symbol]';
|
|
28
|
+
const dateTag = '[object Date]';
|
|
29
|
+
const mapTag = '[object Map]';
|
|
30
|
+
const setTag = '[object Set]';
|
|
31
|
+
const arrayTag = '[object Array]';
|
|
32
|
+
const functionTag = '[object Function]';
|
|
33
|
+
const arrayBufferTag = '[object ArrayBuffer]';
|
|
34
|
+
const objectTag = '[object Object]';
|
|
35
|
+
const errorTag = '[object Error]';
|
|
36
|
+
const dataViewTag = '[object DataView]';
|
|
37
|
+
const uint8ArrayTag = '[object Uint8Array]';
|
|
38
|
+
const uint8ClampedArrayTag = '[object Uint8ClampedArray]';
|
|
39
|
+
const uint16ArrayTag = '[object Uint16Array]';
|
|
40
|
+
const uint32ArrayTag = '[object Uint32Array]';
|
|
41
|
+
const bigUint64ArrayTag = '[object BigUint64Array]';
|
|
42
|
+
const int8ArrayTag = '[object Int8Array]';
|
|
43
|
+
const int16ArrayTag = '[object Int16Array]';
|
|
44
|
+
const int32ArrayTag = '[object Int32Array]';
|
|
45
|
+
const bigInt64ArrayTag = '[object BigInt64Array]';
|
|
46
|
+
const float32ArrayTag = '[object Float32Array]';
|
|
47
|
+
const float64ArrayTag = '[object Float64Array]';
|
|
48
|
+
|
|
49
|
+
function isPlainObject(value) {
|
|
50
|
+
if (!value || typeof value !== 'object') {
|
|
51
|
+
return false;
|
|
52
|
+
}
|
|
53
|
+
const proto = Object.getPrototypeOf(value);
|
|
54
|
+
const hasObjectPrototype = proto === null ||
|
|
55
|
+
proto === Object.prototype ||
|
|
56
|
+
Object.getPrototypeOf(proto) === null;
|
|
57
|
+
if (!hasObjectPrototype) {
|
|
58
|
+
return false;
|
|
59
|
+
}
|
|
60
|
+
return Object.prototype.toString.call(value) === '[object Object]';
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
exports.argumentsTag = argumentsTag;
|
|
64
|
+
exports.arrayBufferTag = arrayBufferTag;
|
|
65
|
+
exports.arrayTag = arrayTag;
|
|
66
|
+
exports.bigInt64ArrayTag = bigInt64ArrayTag;
|
|
67
|
+
exports.bigUint64ArrayTag = bigUint64ArrayTag;
|
|
68
|
+
exports.booleanTag = booleanTag;
|
|
69
|
+
exports.dataViewTag = dataViewTag;
|
|
70
|
+
exports.dateTag = dateTag;
|
|
71
|
+
exports.errorTag = errorTag;
|
|
72
|
+
exports.float32ArrayTag = float32ArrayTag;
|
|
73
|
+
exports.float64ArrayTag = float64ArrayTag;
|
|
74
|
+
exports.functionTag = functionTag;
|
|
75
|
+
exports.getSymbols = getSymbols;
|
|
76
|
+
exports.getTag = getTag;
|
|
77
|
+
exports.int16ArrayTag = int16ArrayTag;
|
|
78
|
+
exports.int32ArrayTag = int32ArrayTag;
|
|
79
|
+
exports.int8ArrayTag = int8ArrayTag;
|
|
80
|
+
exports.isPlainObject = isPlainObject;
|
|
81
|
+
exports.isPrimitive = isPrimitive;
|
|
82
|
+
exports.isTypedArray = isTypedArray;
|
|
83
|
+
exports.mapTag = mapTag;
|
|
84
|
+
exports.numberTag = numberTag;
|
|
85
|
+
exports.objectTag = objectTag;
|
|
86
|
+
exports.regexpTag = regexpTag;
|
|
87
|
+
exports.setTag = setTag;
|
|
88
|
+
exports.stringTag = stringTag;
|
|
89
|
+
exports.symbolTag = symbolTag;
|
|
90
|
+
exports.uint16ArrayTag = uint16ArrayTag;
|
|
91
|
+
exports.uint32ArrayTag = uint32ArrayTag;
|
|
92
|
+
exports.uint8ArrayTag = uint8ArrayTag;
|
|
93
|
+
exports.uint8ClampedArrayTag = uint8ClampedArrayTag;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const isPlainObject = require('./isPlainObject-
|
|
3
|
+
const isPlainObject = require('./isPlainObject-Xaozpc.js');
|
|
4
4
|
const noop = require('./noop-2IwLUk.js');
|
|
5
5
|
|
|
6
6
|
function isArrayBuffer(value) {
|
|
@@ -22,40 +22,6 @@ function isDate(value) {
|
|
|
22
22
|
return value instanceof Date;
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
function getTag(value) {
|
|
26
|
-
if (value == null) {
|
|
27
|
-
return value === undefined ? '[object Undefined]' : '[object Null]';
|
|
28
|
-
}
|
|
29
|
-
return Object.prototype.toString.call(value);
|
|
30
|
-
}
|
|
31
|
-
|
|
32
|
-
const regexpTag = '[object RegExp]';
|
|
33
|
-
const stringTag = '[object String]';
|
|
34
|
-
const numberTag = '[object Number]';
|
|
35
|
-
const booleanTag = '[object Boolean]';
|
|
36
|
-
const argumentsTag = '[object Arguments]';
|
|
37
|
-
const symbolTag = '[object Symbol]';
|
|
38
|
-
const dateTag = '[object Date]';
|
|
39
|
-
const mapTag = '[object Map]';
|
|
40
|
-
const setTag = '[object Set]';
|
|
41
|
-
const arrayTag = '[object Array]';
|
|
42
|
-
const functionTag = '[object Function]';
|
|
43
|
-
const arrayBufferTag = '[object ArrayBuffer]';
|
|
44
|
-
const objectTag = '[object Object]';
|
|
45
|
-
const errorTag = '[object Error]';
|
|
46
|
-
const dataViewTag = '[object DataView]';
|
|
47
|
-
const uint8ArrayTag = '[object Uint8Array]';
|
|
48
|
-
const uint8ClampedArrayTag = '[object Uint8ClampedArray]';
|
|
49
|
-
const uint16ArrayTag = '[object Uint16Array]';
|
|
50
|
-
const uint32ArrayTag = '[object Uint32Array]';
|
|
51
|
-
const bigUint64ArrayTag = '[object BigUint64Array]';
|
|
52
|
-
const int8ArrayTag = '[object Int8Array]';
|
|
53
|
-
const int16ArrayTag = '[object Int16Array]';
|
|
54
|
-
const int32ArrayTag = '[object Int32Array]';
|
|
55
|
-
const bigInt64ArrayTag = '[object BigInt64Array]';
|
|
56
|
-
const float32ArrayTag = '[object Float32Array]';
|
|
57
|
-
const float64ArrayTag = '[object Float64Array]';
|
|
58
|
-
|
|
59
25
|
function eq(value, other) {
|
|
60
26
|
return value === other || (Number.isNaN(value) && Number.isNaN(other));
|
|
61
27
|
}
|
|
@@ -94,33 +60,33 @@ function areObjectsEqual(a, b, stack, areValuesEqual) {
|
|
|
94
60
|
if (Object.is(a, b)) {
|
|
95
61
|
return true;
|
|
96
62
|
}
|
|
97
|
-
let aTag = getTag(a);
|
|
98
|
-
let bTag = getTag(b);
|
|
99
|
-
if (aTag === argumentsTag) {
|
|
100
|
-
aTag = objectTag;
|
|
63
|
+
let aTag = isPlainObject.getTag(a);
|
|
64
|
+
let bTag = isPlainObject.getTag(b);
|
|
65
|
+
if (aTag === isPlainObject.argumentsTag) {
|
|
66
|
+
aTag = isPlainObject.objectTag;
|
|
101
67
|
}
|
|
102
|
-
if (bTag === argumentsTag) {
|
|
103
|
-
bTag = objectTag;
|
|
68
|
+
if (bTag === isPlainObject.argumentsTag) {
|
|
69
|
+
bTag = isPlainObject.objectTag;
|
|
104
70
|
}
|
|
105
71
|
if (aTag !== bTag) {
|
|
106
72
|
return false;
|
|
107
73
|
}
|
|
108
74
|
switch (aTag) {
|
|
109
|
-
case stringTag:
|
|
75
|
+
case isPlainObject.stringTag:
|
|
110
76
|
return a.toString() === b.toString();
|
|
111
|
-
case numberTag: {
|
|
77
|
+
case isPlainObject.numberTag: {
|
|
112
78
|
const x = a.valueOf();
|
|
113
79
|
const y = b.valueOf();
|
|
114
80
|
return eq(x, y);
|
|
115
81
|
}
|
|
116
|
-
case booleanTag:
|
|
117
|
-
case dateTag:
|
|
118
|
-
case symbolTag:
|
|
82
|
+
case isPlainObject.booleanTag:
|
|
83
|
+
case isPlainObject.dateTag:
|
|
84
|
+
case isPlainObject.symbolTag:
|
|
119
85
|
return Object.is(a.valueOf(), b.valueOf());
|
|
120
|
-
case regexpTag: {
|
|
86
|
+
case isPlainObject.regexpTag: {
|
|
121
87
|
return a.source === b.source && a.flags === b.flags;
|
|
122
88
|
}
|
|
123
|
-
case functionTag: {
|
|
89
|
+
case isPlainObject.functionTag: {
|
|
124
90
|
return a === b;
|
|
125
91
|
}
|
|
126
92
|
}
|
|
@@ -134,7 +100,7 @@ function areObjectsEqual(a, b, stack, areValuesEqual) {
|
|
|
134
100
|
stack.set(b, a);
|
|
135
101
|
try {
|
|
136
102
|
switch (aTag) {
|
|
137
|
-
case mapTag: {
|
|
103
|
+
case isPlainObject.mapTag: {
|
|
138
104
|
if (a.size !== b.size) {
|
|
139
105
|
return false;
|
|
140
106
|
}
|
|
@@ -145,7 +111,7 @@ function areObjectsEqual(a, b, stack, areValuesEqual) {
|
|
|
145
111
|
}
|
|
146
112
|
return true;
|
|
147
113
|
}
|
|
148
|
-
case setTag: {
|
|
114
|
+
case isPlainObject.setTag: {
|
|
149
115
|
if (a.size !== b.size) {
|
|
150
116
|
return false;
|
|
151
117
|
}
|
|
@@ -163,18 +129,18 @@ function areObjectsEqual(a, b, stack, areValuesEqual) {
|
|
|
163
129
|
}
|
|
164
130
|
return true;
|
|
165
131
|
}
|
|
166
|
-
case arrayTag:
|
|
167
|
-
case uint8ArrayTag:
|
|
168
|
-
case uint8ClampedArrayTag:
|
|
169
|
-
case uint16ArrayTag:
|
|
170
|
-
case uint32ArrayTag:
|
|
171
|
-
case bigUint64ArrayTag:
|
|
172
|
-
case int8ArrayTag:
|
|
173
|
-
case int16ArrayTag:
|
|
174
|
-
case int32ArrayTag:
|
|
175
|
-
case bigInt64ArrayTag:
|
|
176
|
-
case float32ArrayTag:
|
|
177
|
-
case float64ArrayTag: {
|
|
132
|
+
case isPlainObject.arrayTag:
|
|
133
|
+
case isPlainObject.uint8ArrayTag:
|
|
134
|
+
case isPlainObject.uint8ClampedArrayTag:
|
|
135
|
+
case isPlainObject.uint16ArrayTag:
|
|
136
|
+
case isPlainObject.uint32ArrayTag:
|
|
137
|
+
case isPlainObject.bigUint64ArrayTag:
|
|
138
|
+
case isPlainObject.int8ArrayTag:
|
|
139
|
+
case isPlainObject.int16ArrayTag:
|
|
140
|
+
case isPlainObject.int32ArrayTag:
|
|
141
|
+
case isPlainObject.bigInt64ArrayTag:
|
|
142
|
+
case isPlainObject.float32ArrayTag:
|
|
143
|
+
case isPlainObject.float64ArrayTag: {
|
|
178
144
|
if (typeof Buffer !== 'undefined' && Buffer.isBuffer(a) !== Buffer.isBuffer(b)) {
|
|
179
145
|
return false;
|
|
180
146
|
}
|
|
@@ -188,22 +154,22 @@ function areObjectsEqual(a, b, stack, areValuesEqual) {
|
|
|
188
154
|
}
|
|
189
155
|
return true;
|
|
190
156
|
}
|
|
191
|
-
case arrayBufferTag: {
|
|
157
|
+
case isPlainObject.arrayBufferTag: {
|
|
192
158
|
if (a.byteLength !== b.byteLength) {
|
|
193
159
|
return false;
|
|
194
160
|
}
|
|
195
161
|
return areObjectsEqual(new Uint8Array(a), new Uint8Array(b), stack, areValuesEqual);
|
|
196
162
|
}
|
|
197
|
-
case dataViewTag: {
|
|
163
|
+
case isPlainObject.dataViewTag: {
|
|
198
164
|
if (a.byteLength !== b.byteLength || a.byteOffset !== b.byteOffset) {
|
|
199
165
|
return false;
|
|
200
166
|
}
|
|
201
167
|
return areObjectsEqual(new Uint8Array(a), new Uint8Array(b), stack, areValuesEqual);
|
|
202
168
|
}
|
|
203
|
-
case errorTag: {
|
|
169
|
+
case isPlainObject.errorTag: {
|
|
204
170
|
return a.name === b.name && a.message === b.message;
|
|
205
171
|
}
|
|
206
|
-
case objectTag: {
|
|
172
|
+
case isPlainObject.objectTag: {
|
|
207
173
|
const areEqualInstances = areObjectsEqual(a.constructor, b.constructor, stack, areValuesEqual) ||
|
|
208
174
|
(isPlainObject.isPlainObject(a) && isPlainObject.isPlainObject(b));
|
|
209
175
|
if (!areEqualInstances) {
|
|
@@ -336,10 +302,7 @@ function isWeakSet(value) {
|
|
|
336
302
|
return value instanceof WeakSet;
|
|
337
303
|
}
|
|
338
304
|
|
|
339
|
-
exports.argumentsTag = argumentsTag;
|
|
340
|
-
exports.booleanTag = booleanTag;
|
|
341
305
|
exports.eq = eq;
|
|
342
|
-
exports.getTag = getTag;
|
|
343
306
|
exports.isArrayBuffer = isArrayBuffer;
|
|
344
307
|
exports.isBlob = isBlob;
|
|
345
308
|
exports.isBuffer = isBuffer;
|
|
@@ -362,5 +325,3 @@ exports.isSet = isSet;
|
|
|
362
325
|
exports.isUndefined = isUndefined;
|
|
363
326
|
exports.isWeakMap = isWeakMap;
|
|
364
327
|
exports.isWeakSet = isWeakSet;
|
|
365
|
-
exports.numberTag = numberTag;
|
|
366
|
-
exports.stringTag = stringTag;
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
-
const isPlainObject = require('./isPlainObject-
|
|
3
|
+
const isPlainObject = require('./isPlainObject-Xaozpc.js');
|
|
4
4
|
|
|
5
5
|
function clone(obj) {
|
|
6
6
|
if (isPlainObject.isPrimitive(obj)) {
|
|
@@ -140,7 +140,7 @@ function cloneDeepWithImpl(valueToClone, keyToClone, objectToClone, stack = new
|
|
|
140
140
|
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
|
141
141
|
return result;
|
|
142
142
|
}
|
|
143
|
-
if (typeof valueToClone === 'object' && valueToClone
|
|
143
|
+
if (typeof valueToClone === 'object' && isCloneableObject(valueToClone)) {
|
|
144
144
|
const result = Object.create(Object.getPrototypeOf(valueToClone));
|
|
145
145
|
stack.set(valueToClone, result);
|
|
146
146
|
copyProperties(result, valueToClone, objectToClone, stack, cloneValue);
|
|
@@ -158,6 +158,37 @@ function copyProperties(target, source, objectToClone = target, stack, cloneValu
|
|
|
158
158
|
}
|
|
159
159
|
}
|
|
160
160
|
}
|
|
161
|
+
function isCloneableObject(object) {
|
|
162
|
+
switch (isPlainObject.getTag(object)) {
|
|
163
|
+
case isPlainObject.argumentsTag:
|
|
164
|
+
case isPlainObject.arrayTag:
|
|
165
|
+
case isPlainObject.arrayBufferTag:
|
|
166
|
+
case isPlainObject.dataViewTag:
|
|
167
|
+
case isPlainObject.booleanTag:
|
|
168
|
+
case isPlainObject.dateTag:
|
|
169
|
+
case isPlainObject.float32ArrayTag:
|
|
170
|
+
case isPlainObject.float64ArrayTag:
|
|
171
|
+
case isPlainObject.int8ArrayTag:
|
|
172
|
+
case isPlainObject.int16ArrayTag:
|
|
173
|
+
case isPlainObject.int32ArrayTag:
|
|
174
|
+
case isPlainObject.mapTag:
|
|
175
|
+
case isPlainObject.numberTag:
|
|
176
|
+
case isPlainObject.objectTag:
|
|
177
|
+
case isPlainObject.regexpTag:
|
|
178
|
+
case isPlainObject.setTag:
|
|
179
|
+
case isPlainObject.stringTag:
|
|
180
|
+
case isPlainObject.symbolTag:
|
|
181
|
+
case isPlainObject.uint8ArrayTag:
|
|
182
|
+
case isPlainObject.uint8ClampedArrayTag:
|
|
183
|
+
case isPlainObject.uint16ArrayTag:
|
|
184
|
+
case isPlainObject.uint32ArrayTag: {
|
|
185
|
+
return true;
|
|
186
|
+
}
|
|
187
|
+
default: {
|
|
188
|
+
return false;
|
|
189
|
+
}
|
|
190
|
+
}
|
|
191
|
+
}
|
|
161
192
|
|
|
162
193
|
function cloneDeep(obj) {
|
|
163
194
|
return cloneDeepWithImpl(obj, undefined, obj, new Map(), undefined);
|