@domql/utils 2.5.130 → 2.5.134
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/cookie.js +5 -0
- package/dist/cjs/cookie.js +6 -0
- package/dist/cjs/object.js +39 -0
- package/object.js +41 -0
- package/package.json +2 -2
package/cookie.js
CHANGED
package/dist/cjs/cookie.js
CHANGED
|
@@ -20,6 +20,7 @@ var cookie_exports = {};
|
|
|
20
20
|
__export(cookie_exports, {
|
|
21
21
|
getCookie: () => getCookie,
|
|
22
22
|
isMobile: () => isMobile,
|
|
23
|
+
removeCookie: () => removeCookie,
|
|
23
24
|
setCookie: () => setCookie
|
|
24
25
|
});
|
|
25
26
|
module.exports = __toCommonJS(cookie_exports);
|
|
@@ -49,3 +50,8 @@ const getCookie = (cname) => {
|
|
|
49
50
|
}
|
|
50
51
|
return "";
|
|
51
52
|
};
|
|
53
|
+
const removeCookie = (cname) => {
|
|
54
|
+
if ((0, import_types.isUndefined)(import_utils.document) || (0, import_types.isUndefined)(import_utils.document.cookie))
|
|
55
|
+
return;
|
|
56
|
+
import_utils.document.cookie = cname + "=; expires=Thu, 01 Jan 1970 00:00:00 UTC; path=/;";
|
|
57
|
+
};
|
package/dist/cjs/object.js
CHANGED
|
@@ -29,6 +29,7 @@ __export(object_exports, {
|
|
|
29
29
|
deepDiff: () => deepDiff,
|
|
30
30
|
deepMerge: () => deepMerge,
|
|
31
31
|
deepStringify: () => deepStringify,
|
|
32
|
+
deepStringifyWithMaxDepth: () => deepStringifyWithMaxDepth,
|
|
32
33
|
detachFunctionsFromObject: () => detachFunctionsFromObject,
|
|
33
34
|
detectInfiniteLoop: () => detectInfiniteLoop,
|
|
34
35
|
diff: () => diff,
|
|
@@ -179,6 +180,11 @@ const deepCloneWithExtend = (obj, excludeFrom = ["node"], options = {}) => {
|
|
|
179
180
|
return o;
|
|
180
181
|
};
|
|
181
182
|
const deepStringify = (obj, stringified = {}) => {
|
|
183
|
+
var _a;
|
|
184
|
+
if (obj.node || obj.__ref || obj.parent || obj.__element || obj.parse) {
|
|
185
|
+
console.warn("Trying to clone element or state at", obj);
|
|
186
|
+
obj = (_a = obj.parse) == null ? void 0 : _a.call(obj);
|
|
187
|
+
}
|
|
182
188
|
for (const prop in obj) {
|
|
183
189
|
const objProp = obj[prop];
|
|
184
190
|
if ((0, import_types.isFunction)(objProp)) {
|
|
@@ -204,6 +210,39 @@ const deepStringify = (obj, stringified = {}) => {
|
|
|
204
210
|
}
|
|
205
211
|
return stringified;
|
|
206
212
|
};
|
|
213
|
+
const MAX_DEPTH = 100;
|
|
214
|
+
const deepStringifyWithMaxDepth = (obj, stringified = {}, depth = 0, path = "") => {
|
|
215
|
+
if (depth > MAX_DEPTH) {
|
|
216
|
+
console.warn(`Maximum depth exceeded at path: ${path}. Possible circular reference.`);
|
|
217
|
+
return "[MAX_DEPTH_EXCEEDED]";
|
|
218
|
+
}
|
|
219
|
+
for (const prop in obj) {
|
|
220
|
+
const currentPath = path ? `${path}.${prop}` : prop;
|
|
221
|
+
const objProp = obj[prop];
|
|
222
|
+
if ((0, import_types.isFunction)(objProp)) {
|
|
223
|
+
stringified[prop] = objProp.toString();
|
|
224
|
+
} else if ((0, import_types.isObject)(objProp)) {
|
|
225
|
+
stringified[prop] = {};
|
|
226
|
+
deepStringifyWithMaxDepth(objProp, stringified[prop], depth + 1, currentPath);
|
|
227
|
+
} else if ((0, import_types.isArray)(objProp)) {
|
|
228
|
+
stringified[prop] = [];
|
|
229
|
+
objProp.forEach((v, i) => {
|
|
230
|
+
const itemPath = `${currentPath}[${i}]`;
|
|
231
|
+
if ((0, import_types.isObject)(v)) {
|
|
232
|
+
stringified[prop][i] = {};
|
|
233
|
+
deepStringifyWithMaxDepth(v, stringified[prop][i], depth + 1, itemPath);
|
|
234
|
+
} else if ((0, import_types.isFunction)(v)) {
|
|
235
|
+
stringified[prop][i] = v.toString();
|
|
236
|
+
} else {
|
|
237
|
+
stringified[prop][i] = v;
|
|
238
|
+
}
|
|
239
|
+
});
|
|
240
|
+
} else {
|
|
241
|
+
stringified[prop] = objProp;
|
|
242
|
+
}
|
|
243
|
+
}
|
|
244
|
+
return stringified;
|
|
245
|
+
};
|
|
207
246
|
const objectToString = (obj = {}, indent = 0) => {
|
|
208
247
|
const spaces = " ".repeat(indent);
|
|
209
248
|
let str = "{\n";
|
package/object.js
CHANGED
|
@@ -199,6 +199,11 @@ export const deepCloneWithExtend = (obj, excludeFrom = ['node'], options = {}) =
|
|
|
199
199
|
* Stringify object
|
|
200
200
|
*/
|
|
201
201
|
export const deepStringify = (obj, stringified = {}) => {
|
|
202
|
+
if (obj.node || obj.__ref || obj.parent || obj.__element || obj.parse) {
|
|
203
|
+
console.warn('Trying to clone element or state at', obj)
|
|
204
|
+
obj = obj.parse?.()
|
|
205
|
+
}
|
|
206
|
+
|
|
202
207
|
for (const prop in obj) {
|
|
203
208
|
const objProp = obj[prop]
|
|
204
209
|
if (isFunction(objProp)) {
|
|
@@ -225,6 +230,42 @@ export const deepStringify = (obj, stringified = {}) => {
|
|
|
225
230
|
return stringified
|
|
226
231
|
}
|
|
227
232
|
|
|
233
|
+
const MAX_DEPTH = 100 // Adjust this value as needed
|
|
234
|
+
export const deepStringifyWithMaxDepth = (obj, stringified = {}, depth = 0, path = '') => {
|
|
235
|
+
if (depth > MAX_DEPTH) {
|
|
236
|
+
console.warn(`Maximum depth exceeded at path: ${path}. Possible circular reference.`)
|
|
237
|
+
return '[MAX_DEPTH_EXCEEDED]'
|
|
238
|
+
}
|
|
239
|
+
|
|
240
|
+
for (const prop in obj) {
|
|
241
|
+
const currentPath = path ? `${path}.${prop}` : prop
|
|
242
|
+
const objProp = obj[prop]
|
|
243
|
+
|
|
244
|
+
if (isFunction(objProp)) {
|
|
245
|
+
stringified[prop] = objProp.toString()
|
|
246
|
+
} else if (isObject(objProp)) {
|
|
247
|
+
stringified[prop] = {}
|
|
248
|
+
deepStringifyWithMaxDepth(objProp, stringified[prop], depth + 1, currentPath)
|
|
249
|
+
} else if (isArray(objProp)) {
|
|
250
|
+
stringified[prop] = []
|
|
251
|
+
objProp.forEach((v, i) => {
|
|
252
|
+
const itemPath = `${currentPath}[${i}]`
|
|
253
|
+
if (isObject(v)) {
|
|
254
|
+
stringified[prop][i] = {}
|
|
255
|
+
deepStringifyWithMaxDepth(v, stringified[prop][i], depth + 1, itemPath)
|
|
256
|
+
} else if (isFunction(v)) {
|
|
257
|
+
stringified[prop][i] = v.toString()
|
|
258
|
+
} else {
|
|
259
|
+
stringified[prop][i] = v
|
|
260
|
+
}
|
|
261
|
+
})
|
|
262
|
+
} else {
|
|
263
|
+
stringified[prop] = objProp
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
return stringified
|
|
267
|
+
}
|
|
268
|
+
|
|
228
269
|
export const objectToString = (obj = {}, indent = 0) => {
|
|
229
270
|
const spaces = ' '.repeat(indent)
|
|
230
271
|
let str = '{\n'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/utils",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.134",
|
|
4
4
|
"license": "MIT",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "index.js",
|
|
@@ -25,7 +25,7 @@
|
|
|
25
25
|
"build": "yarn build:cjs",
|
|
26
26
|
"prepublish": "rimraf -I dist && yarn build && yarn copy:package:cjs"
|
|
27
27
|
},
|
|
28
|
-
"gitHead": "
|
|
28
|
+
"gitHead": "20e65426dc742448bd6dc85211dea3a48ed74ae0",
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@babel/core": "^7.12.0"
|
|
31
31
|
}
|