@jsopen/objects 1.3.0 → 1.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/CHANGELOG.md +2 -2
- package/cjs/merge.js +10 -5
- package/esm/merge.js +10 -5
- package/package.json +1 -1
- package/types/merge.d.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
# v1.
|
|
1
|
+
# v1.4.0
|
|
2
2
|
[2024-11-22]
|
|
3
3
|
|
|
4
4
|
### Changes
|
|
5
5
|
|
|
6
|
-
* feat: Added
|
|
6
|
+
* feat: Added "full" option to "deep" config ([`3d2a51a`](https://github.com/panates/jsopen-objects/commit/3d2a51adff14d2ac67f3ec0c8760ae167febc4d7))
|
package/cjs/merge.js
CHANGED
|
@@ -32,9 +32,11 @@ function getMergeFunction(options) {
|
|
|
32
32
|
? 'n'
|
|
33
33
|
: typeof option === 'function'
|
|
34
34
|
? 'f'
|
|
35
|
-
: option
|
|
36
|
-
?
|
|
37
|
-
:
|
|
35
|
+
: typeof option === 'string'
|
|
36
|
+
? option
|
|
37
|
+
: option
|
|
38
|
+
? '1'
|
|
39
|
+
: '0')
|
|
38
40
|
.join();
|
|
39
41
|
let fn = functionCache.get(cacheKey);
|
|
40
42
|
if (!fn) {
|
|
@@ -153,14 +155,17 @@ if (
|
|
|
153
155
|
const deepArray = !options?.moveArrays || typeof options?.moveArrays === 'function';
|
|
154
156
|
/** ************* deep *****************/
|
|
155
157
|
if (options?.deep) {
|
|
158
|
+
const deepCondition = options.deep === 'full'
|
|
159
|
+
? `typeof srcVal === 'object' && !isBuiltIn(srcVal)`
|
|
160
|
+
: `isPlainObject(srcVal)`;
|
|
156
161
|
if (deepArray) {
|
|
157
162
|
scriptL1For.push(`
|
|
158
163
|
_isArray = Array.isArray(srcVal);
|
|
159
|
-
if (
|
|
164
|
+
if (typeof key !== 'symbol' && (_isArray || (${deepCondition}))) {`);
|
|
160
165
|
}
|
|
161
166
|
else {
|
|
162
167
|
scriptL1For.push(`
|
|
163
|
-
if (typeof
|
|
168
|
+
if (typeof key !== 'symbol' && ${deepCondition}) {
|
|
164
169
|
subPath = curPath + (curPath ? '.' : '') + key;`);
|
|
165
170
|
}
|
|
166
171
|
scriptL1For.push(`subPath = curPath + (curPath ? '.' : '') + key;`);
|
package/esm/merge.js
CHANGED
|
@@ -28,9 +28,11 @@ export function getMergeFunction(options) {
|
|
|
28
28
|
? 'n'
|
|
29
29
|
: typeof option === 'function'
|
|
30
30
|
? 'f'
|
|
31
|
-
: option
|
|
32
|
-
?
|
|
33
|
-
:
|
|
31
|
+
: typeof option === 'string'
|
|
32
|
+
? option
|
|
33
|
+
: option
|
|
34
|
+
? '1'
|
|
35
|
+
: '0')
|
|
34
36
|
.join();
|
|
35
37
|
let fn = functionCache.get(cacheKey);
|
|
36
38
|
if (!fn) {
|
|
@@ -149,14 +151,17 @@ if (
|
|
|
149
151
|
const deepArray = !options?.moveArrays || typeof options?.moveArrays === 'function';
|
|
150
152
|
/** ************* deep *****************/
|
|
151
153
|
if (options?.deep) {
|
|
154
|
+
const deepCondition = options.deep === 'full'
|
|
155
|
+
? `typeof srcVal === 'object' && !isBuiltIn(srcVal)`
|
|
156
|
+
: `isPlainObject(srcVal)`;
|
|
152
157
|
if (deepArray) {
|
|
153
158
|
scriptL1For.push(`
|
|
154
159
|
_isArray = Array.isArray(srcVal);
|
|
155
|
-
if (
|
|
160
|
+
if (typeof key !== 'symbol' && (_isArray || (${deepCondition}))) {`);
|
|
156
161
|
}
|
|
157
162
|
else {
|
|
158
163
|
scriptL1For.push(`
|
|
159
|
-
if (typeof
|
|
164
|
+
if (typeof key !== 'symbol' && ${deepCondition}) {
|
|
160
165
|
subPath = curPath + (curPath ? '.' : '') + key;`);
|
|
161
166
|
}
|
|
162
167
|
scriptL1For.push(`subPath = curPath + (curPath ? '.' : '') + key;`);
|
package/package.json
CHANGED
package/types/merge.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
export declare namespace merge {
|
|
2
2
|
type NodeCallback = (key: string | symbol, source: any, target: any, path: string) => boolean;
|
|
3
3
|
interface Options {
|
|
4
|
-
deep?: boolean | NodeCallback;
|
|
4
|
+
deep?: boolean | 'full' | NodeCallback;
|
|
5
5
|
/**
|
|
6
6
|
*/
|
|
7
7
|
moveArrays?: boolean | NodeCallback;
|