@domql/utils 2.5.73 → 2.5.80
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/cjs/object.js +13 -12
- package/dist/cjs/string.js +6 -5
- package/object.js +16 -15
- package/package.json +2 -2
- package/string.js +6 -5
package/dist/cjs/object.js
CHANGED
|
@@ -20,7 +20,6 @@ var object_exports = {};
|
|
|
20
20
|
__export(object_exports, {
|
|
21
21
|
clone: () => clone,
|
|
22
22
|
deepClone: () => deepClone,
|
|
23
|
-
deepCloneEntrance: () => deepCloneEntrance,
|
|
24
23
|
deepCloneExclude: () => deepCloneExclude,
|
|
25
24
|
deepCloneWithExtend: () => deepCloneWithExtend,
|
|
26
25
|
deepContains: () => deepContains,
|
|
@@ -136,6 +135,12 @@ const mergeArrayExclude = (arr, excl = []) => {
|
|
|
136
135
|
const deepClone = (obj, excludeFrom = [], cleanUndefined = false) => {
|
|
137
136
|
const o = (0, import_types.isArray)(obj) ? [] : {};
|
|
138
137
|
for (const prop in obj) {
|
|
138
|
+
if (!Object.prototype.hasOwnProperty.call(obj, prop))
|
|
139
|
+
continue;
|
|
140
|
+
if (prop === "node" || prop === "parent" || prop === "root" || prop === "__element") {
|
|
141
|
+
console.warn("recursive clonning is called", obj);
|
|
142
|
+
continue;
|
|
143
|
+
}
|
|
139
144
|
if (prop === "__proto__")
|
|
140
145
|
continue;
|
|
141
146
|
if (excludeFrom.includes(prop) || prop.startsWith("__"))
|
|
@@ -153,21 +158,17 @@ const deepClone = (obj, excludeFrom = [], cleanUndefined = false) => {
|
|
|
153
158
|
}
|
|
154
159
|
return o;
|
|
155
160
|
};
|
|
156
|
-
const deepCloneEntrance = (...params) => {
|
|
157
|
-
let extended;
|
|
158
|
-
try {
|
|
159
|
-
extended = deepCloneWithExtend(...params);
|
|
160
|
-
} catch {
|
|
161
|
-
console.log("HERE", extended);
|
|
162
|
-
}
|
|
163
|
-
return extended;
|
|
164
|
-
};
|
|
165
161
|
const deepCloneWithExtend = (obj, excludeFrom = ["node"], options = {}) => {
|
|
166
162
|
const o = (0, import_types.isArray)(obj) ? [] : {};
|
|
167
163
|
for (const prop in obj) {
|
|
168
|
-
|
|
164
|
+
if (!Object.prototype.hasOwnProperty.call(obj, prop))
|
|
165
|
+
continue;
|
|
166
|
+
if (prop === "node" || prop === "parent" || prop === "root" || prop === "__element") {
|
|
167
|
+
console.warn("recursive clonning is called", obj);
|
|
168
|
+
continue;
|
|
169
|
+
}
|
|
169
170
|
const objProp = obj[prop];
|
|
170
|
-
if (
|
|
171
|
+
if (excludeFrom.includes(prop) || prop.startsWith("__") || options.cleanUndefined && (0, import_types.isUndefined)(objProp) || options.cleanNull && (0, import_types.isNull)(objProp))
|
|
171
172
|
continue;
|
|
172
173
|
if ((0, import_types.isObjectLike)(objProp)) {
|
|
173
174
|
o[prop] = deepCloneWithExtend(objProp, excludeFrom, options);
|
package/dist/cjs/string.js
CHANGED
|
@@ -38,14 +38,15 @@ const trimStringFromSymbols = (str, characters) => {
|
|
|
38
38
|
};
|
|
39
39
|
const brackRegex = {
|
|
40
40
|
2: /\{\{\s*((?:\.\.\/)+)?([^}\s]+)\s*\}\}/g,
|
|
41
|
-
3: /\{\{\s*((
|
|
41
|
+
3: /\{\{\{\s*((?:\.\.\/)+)?([^}\s]+)\s*\}\}\}/g
|
|
42
42
|
};
|
|
43
|
-
const replaceLiteralsWithObjectFields = (str, state,
|
|
44
|
-
if (!str.includes(
|
|
43
|
+
const replaceLiteralsWithObjectFields = (str, state, options = {}) => {
|
|
44
|
+
if (!str.includes(options.bracketsLength === 3 ? "{{{" : "{{"))
|
|
45
45
|
return str;
|
|
46
|
-
|
|
46
|
+
const reg = brackRegex[options.bracketsLength || 2];
|
|
47
|
+
return str.replace(reg, (_, parentPath, variable) => {
|
|
47
48
|
if (parentPath) {
|
|
48
|
-
const parentLevels = parentPath.match(
|
|
49
|
+
const parentLevels = parentPath.match(options.bracketsLength === 3 ? /\.\.\.\//g : /\.\.\//g).length;
|
|
49
50
|
let parentState = state;
|
|
50
51
|
for (let i = 0; i < parentLevels; i++) {
|
|
51
52
|
parentState = parentState.parent;
|
package/object.js
CHANGED
|
@@ -98,6 +98,11 @@ export const mergeArrayExclude = (arr, excl = []) => {
|
|
|
98
98
|
export const deepClone = (obj, excludeFrom = [], cleanUndefined = false) => {
|
|
99
99
|
const o = isArray(obj) ? [] : {}
|
|
100
100
|
for (const prop in obj) {
|
|
101
|
+
if (!Object.prototype.hasOwnProperty.call(obj, prop)) continue
|
|
102
|
+
if (prop === 'node' || prop === 'parent' || prop === 'root' || prop === '__element') {
|
|
103
|
+
console.warn('recursive clonning is called', obj)
|
|
104
|
+
continue
|
|
105
|
+
}
|
|
101
106
|
if (prop === '__proto__') continue
|
|
102
107
|
if (excludeFrom.includes(prop) || prop.startsWith('__')) continue
|
|
103
108
|
let objProp = obj[prop]
|
|
@@ -106,39 +111,35 @@ export const deepClone = (obj, excludeFrom = [], cleanUndefined = false) => {
|
|
|
106
111
|
objProp = mergeArray(objProp)
|
|
107
112
|
}
|
|
108
113
|
if (isObjectLike(objProp)) {
|
|
114
|
+
// queueMicrotask(() => {
|
|
109
115
|
o[prop] = deepClone(objProp, excludeFrom, cleanUndefined)
|
|
116
|
+
// })
|
|
110
117
|
} else o[prop] = objProp
|
|
111
118
|
}
|
|
112
119
|
return o
|
|
113
120
|
}
|
|
121
|
+
|
|
114
122
|
/**
|
|
115
123
|
* Deep cloning of object
|
|
116
124
|
*/
|
|
117
|
-
export const deepCloneEntrance = (...params) => {
|
|
118
|
-
// console.groupCollapsed('deepCloneEntrance')
|
|
119
|
-
// console.warn(params)
|
|
120
|
-
let extended
|
|
121
|
-
try {
|
|
122
|
-
extended = deepCloneWithExtend(...params)
|
|
123
|
-
} catch {
|
|
124
|
-
console.log('HERE', extended)
|
|
125
|
-
}
|
|
126
|
-
// console.groupEnd('deepCloneEntrance')
|
|
127
|
-
return extended
|
|
128
|
-
}
|
|
129
|
-
|
|
130
125
|
export const deepCloneWithExtend = (obj, excludeFrom = ['node'], options = {}) => {
|
|
131
126
|
const o = isArray(obj) ? [] : {}
|
|
132
127
|
for (const prop in obj) {
|
|
133
|
-
|
|
128
|
+
if (!Object.prototype.hasOwnProperty.call(obj, prop)) continue
|
|
129
|
+
if (prop === 'node' || prop === 'parent' || prop === 'root' || prop === '__element') {
|
|
130
|
+
console.warn('recursive clonning is called', obj)
|
|
131
|
+
continue
|
|
132
|
+
}
|
|
134
133
|
const objProp = obj[prop]
|
|
135
134
|
if (
|
|
136
|
-
|
|
135
|
+
excludeFrom.includes(prop) || prop.startsWith('__') ||
|
|
137
136
|
(options.cleanUndefined && isUndefined(objProp)) ||
|
|
138
137
|
(options.cleanNull && isNull(objProp))
|
|
139
138
|
) continue
|
|
140
139
|
if (isObjectLike(objProp)) {
|
|
140
|
+
// queueMicrotask(() => {
|
|
141
141
|
o[prop] = deepCloneWithExtend(objProp, excludeFrom, options)
|
|
142
|
+
// })
|
|
142
143
|
} else o[prop] = objProp
|
|
143
144
|
}
|
|
144
145
|
return o
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/utils",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.80",
|
|
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": "48b6b1ab378914613e11e696ae931cece3f784bb",
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@babel/core": "^7.12.0"
|
|
29
29
|
}
|
package/string.js
CHANGED
|
@@ -26,14 +26,15 @@ export const trimStringFromSymbols = (str, characters) => {
|
|
|
26
26
|
*/
|
|
27
27
|
const brackRegex = {
|
|
28
28
|
2: /\{\{\s*((?:\.\.\/)+)?([^}\s]+)\s*\}\}/g,
|
|
29
|
-
3: /\{\{\s*((
|
|
29
|
+
3: /\{\{\{\s*((?:\.\.\/)+)?([^}\s]+)\s*\}\}\}/g
|
|
30
30
|
}
|
|
31
31
|
|
|
32
|
-
export const replaceLiteralsWithObjectFields = (str, state,
|
|
33
|
-
if (!str.includes(
|
|
34
|
-
|
|
32
|
+
export const replaceLiteralsWithObjectFields = (str, state, options = {}) => {
|
|
33
|
+
if (!str.includes(options.bracketsLength === 3 ? '{{{' : '{{')) return str
|
|
34
|
+
const reg = brackRegex[options.bracketsLength || 2]
|
|
35
|
+
return str.replace(reg, (_, parentPath, variable) => {
|
|
35
36
|
if (parentPath) {
|
|
36
|
-
const parentLevels = parentPath.match(
|
|
37
|
+
const parentLevels = parentPath.match(options.bracketsLength === 3 ? /\.\.\.\//g : /\.\.\//g).length
|
|
37
38
|
let parentState = state
|
|
38
39
|
for (let i = 0; i < parentLevels; i++) {
|
|
39
40
|
parentState = parentState.parent
|