@domql/utils 2.5.107 → 2.5.112
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/array.js +3 -3
- package/dist/cjs/array.js +2 -2
- package/dist/cjs/object.js +2 -2
- package/object.js +4 -2
- package/package.json +2 -2
package/array.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
'use strict'
|
|
2
2
|
|
|
3
|
-
import {
|
|
3
|
+
import { deepCloneWithExtend, deepMerge } from './object'
|
|
4
4
|
import { isArray, isNumber, isString } from './types'
|
|
5
5
|
|
|
6
6
|
export const arrayContainsOtherArray = (arr1, arr2) => {
|
|
@@ -40,14 +40,14 @@ export const joinArrays = (...arrays) => {
|
|
|
40
40
|
* Merges array extendtypes
|
|
41
41
|
*/
|
|
42
42
|
export const mergeArray = (arr, excludeFrom = []) => {
|
|
43
|
-
return arr.reduce((a, c) => deepMerge(a,
|
|
43
|
+
return arr.reduce((a, c) => deepMerge(a, deepCloneWithExtend(c, excludeFrom), excludeFrom), {})
|
|
44
44
|
}
|
|
45
45
|
|
|
46
46
|
/**
|
|
47
47
|
* Merges array extends
|
|
48
48
|
*/
|
|
49
49
|
export const mergeAndCloneIfArray = obj => {
|
|
50
|
-
return isArray(obj) ? mergeArray(obj) :
|
|
50
|
+
return isArray(obj) ? mergeArray(obj) : deepCloneWithExtend(obj)
|
|
51
51
|
}
|
|
52
52
|
|
|
53
53
|
export const cutArrayBeforeValue = (arr, value) => {
|
package/dist/cjs/array.js
CHANGED
|
@@ -67,10 +67,10 @@ const joinArrays = (...arrays) => {
|
|
|
67
67
|
return [].concat(...arrays);
|
|
68
68
|
};
|
|
69
69
|
const mergeArray = (arr, excludeFrom = []) => {
|
|
70
|
-
return arr.reduce((a, c) => (0, import_object.deepMerge)(a, (0, import_object.
|
|
70
|
+
return arr.reduce((a, c) => (0, import_object.deepMerge)(a, (0, import_object.deepCloneWithExtend)(c, excludeFrom), excludeFrom), {});
|
|
71
71
|
};
|
|
72
72
|
const mergeAndCloneIfArray = (obj) => {
|
|
73
|
-
return (0, import_types.isArray)(obj) ? mergeArray(obj) : (0, import_object.
|
|
73
|
+
return (0, import_types.isArray)(obj) ? mergeArray(obj) : (0, import_object.deepCloneWithExtend)(obj);
|
|
74
74
|
};
|
|
75
75
|
const cutArrayBeforeValue = (arr, value) => {
|
|
76
76
|
const index = arr.indexOf(value);
|
package/dist/cjs/object.js
CHANGED
|
@@ -159,7 +159,7 @@ const deepClone = (obj, excludeFrom = [], cleanUndefined = false) => {
|
|
|
159
159
|
return o;
|
|
160
160
|
};
|
|
161
161
|
const deepCloneWithExtend = (obj, excludeFrom = ["node"], options = {}) => {
|
|
162
|
-
const o = (0, import_types.isArray)(obj) ? [] : {};
|
|
162
|
+
const o = options.window ? (0, import_types.isArray)(obj) ? new options.window.Array([]) : new options.window.Object({}) : (0, import_types.isArray)(obj) ? [] : {};
|
|
163
163
|
for (const prop in obj) {
|
|
164
164
|
if (!Object.prototype.hasOwnProperty.call(obj, prop))
|
|
165
165
|
continue;
|
|
@@ -413,7 +413,7 @@ const overwriteShallow = (obj, params, excludeFrom = []) => {
|
|
|
413
413
|
};
|
|
414
414
|
const overwriteDeep = (obj, params, excludeFrom = []) => {
|
|
415
415
|
for (const e in params) {
|
|
416
|
-
if (e === "
|
|
416
|
+
if (e === "__ref")
|
|
417
417
|
continue;
|
|
418
418
|
if (excludeFrom.includes(e) || e.startsWith("__"))
|
|
419
419
|
continue;
|
package/object.js
CHANGED
|
@@ -123,7 +123,9 @@ export const deepClone = (obj, excludeFrom = [], cleanUndefined = false) => {
|
|
|
123
123
|
* Deep cloning of object
|
|
124
124
|
*/
|
|
125
125
|
export const deepCloneWithExtend = (obj, excludeFrom = ['node'], options = {}) => {
|
|
126
|
-
const o =
|
|
126
|
+
const o = options.window
|
|
127
|
+
? isArray(obj) ? new options.window.Array([]) : new options.window.Object({})
|
|
128
|
+
: isArray(obj) ? [] : {}
|
|
127
129
|
for (const prop in obj) {
|
|
128
130
|
if (!Object.prototype.hasOwnProperty.call(obj, prop)) continue
|
|
129
131
|
// if (prop === 'node' || prop === 'parent' || prop === 'root' || prop === '__element') {
|
|
@@ -426,7 +428,7 @@ export const overwriteShallow = (obj, params, excludeFrom = []) => {
|
|
|
426
428
|
*/
|
|
427
429
|
export const overwriteDeep = (obj, params, excludeFrom = []) => {
|
|
428
430
|
for (const e in params) {
|
|
429
|
-
if (e === '
|
|
431
|
+
if (e === '__ref') continue
|
|
430
432
|
if (excludeFrom.includes(e) || e.startsWith('__')) continue
|
|
431
433
|
const objProp = obj[e]
|
|
432
434
|
const paramsProp = params[e]
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/utils",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.112",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "index.js",
|
|
@@ -23,7 +23,7 @@
|
|
|
23
23
|
"build": "yarn build:cjs",
|
|
24
24
|
"prepublish": "rimraf -I dist && yarn build && yarn copy:package:cjs"
|
|
25
25
|
},
|
|
26
|
-
"gitHead": "
|
|
26
|
+
"gitHead": "8a59640e77bcd22114bdf64dfa4945604b5bfd1f",
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@babel/core": "^7.12.0"
|
|
29
29
|
}
|