@domql/utils 2.5.93 → 2.5.95
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 +1 -0
- package/dist/cjs/cookie.js +5 -4
- package/dist/cjs/object.js +13 -0
- package/globals.js +1 -1
- package/object.js +16 -0
- package/package.json +2 -2
package/cookie.js
CHANGED
package/dist/cjs/cookie.js
CHANGED
|
@@ -24,20 +24,21 @@ __export(cookie_exports, {
|
|
|
24
24
|
});
|
|
25
25
|
module.exports = __toCommonJS(cookie_exports);
|
|
26
26
|
var import_types = require("./types");
|
|
27
|
+
var import_utils = require("@domql/utils");
|
|
27
28
|
const isMobile = (() => typeof navigator === "undefined" ? false : /Mobi/.test(navigator.userAgent))();
|
|
28
29
|
const setCookie = (cname, cvalue, exdays = 365) => {
|
|
29
|
-
if ((0, import_types.isUndefined)(document) || (0, import_types.isUndefined)(document.cookie))
|
|
30
|
+
if ((0, import_types.isUndefined)(import_utils.document) || (0, import_types.isUndefined)(import_utils.document.cookie))
|
|
30
31
|
return;
|
|
31
32
|
const d = /* @__PURE__ */ new Date();
|
|
32
33
|
d.setTime(d.getTime() + exdays * 24 * 60 * 60 * 1e3);
|
|
33
34
|
const expires = `expires=${d.toUTCString()}`;
|
|
34
|
-
document.cookie = `${cname}=${cvalue};${expires};path=/`;
|
|
35
|
+
import_utils.document.cookie = `${cname}=${cvalue};${expires};path=/`;
|
|
35
36
|
};
|
|
36
37
|
const getCookie = (cname) => {
|
|
37
|
-
if ((0, import_types.isUndefined)(document) || (0, import_types.isUndefined)(document.cookie))
|
|
38
|
+
if ((0, import_types.isUndefined)(import_utils.document) || (0, import_types.isUndefined)(import_utils.document.cookie))
|
|
38
39
|
return;
|
|
39
40
|
const name = `${cname}=`;
|
|
40
|
-
const decodedCookie = decodeURIComponent(document.cookie);
|
|
41
|
+
const decodedCookie = decodeURIComponent(import_utils.document.cookie);
|
|
41
42
|
const ca = decodedCookie.split(";");
|
|
42
43
|
for (let i = 0; i < ca.length; i++) {
|
|
43
44
|
let c = ca[i];
|
package/dist/cjs/object.js
CHANGED
|
@@ -19,6 +19,7 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
19
19
|
var object_exports = {};
|
|
20
20
|
__export(object_exports, {
|
|
21
21
|
clone: () => clone,
|
|
22
|
+
createObjectWithoutPrototype: () => createObjectWithoutPrototype,
|
|
22
23
|
deepClone: () => deepClone,
|
|
23
24
|
deepCloneExclude: () => deepCloneExclude,
|
|
24
25
|
deepCloneWithExtend: () => deepCloneWithExtend,
|
|
@@ -502,3 +503,15 @@ const removeFromObject = (obj, props) => {
|
|
|
502
503
|
}
|
|
503
504
|
return obj;
|
|
504
505
|
};
|
|
506
|
+
const createObjectWithoutPrototype = (obj) => {
|
|
507
|
+
if (obj === null || typeof obj !== "object") {
|
|
508
|
+
return obj;
|
|
509
|
+
}
|
|
510
|
+
const newObj = /* @__PURE__ */ Object.create(null);
|
|
511
|
+
for (const key in obj) {
|
|
512
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
513
|
+
newObj[key] = createObjectWithoutPrototype(obj[key]);
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
return newObj;
|
|
517
|
+
};
|
package/globals.js
CHANGED
package/object.js
CHANGED
|
@@ -577,3 +577,19 @@ export const removeFromObject = (obj, props) => {
|
|
|
577
577
|
}
|
|
578
578
|
return obj
|
|
579
579
|
}
|
|
580
|
+
|
|
581
|
+
export const createObjectWithoutPrototype = (obj) => {
|
|
582
|
+
if (obj === null || typeof obj !== 'object') {
|
|
583
|
+
return obj // Return the value if obj is not an object
|
|
584
|
+
}
|
|
585
|
+
|
|
586
|
+
const newObj = Object.create(null) // Create an object without prototype
|
|
587
|
+
|
|
588
|
+
for (const key in obj) {
|
|
589
|
+
if (Object.prototype.hasOwnProperty.call(obj, key)) {
|
|
590
|
+
newObj[key] = createObjectWithoutPrototype(obj[key]) // Recursively copy each property
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
|
|
594
|
+
return newObj
|
|
595
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@domql/utils",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.95",
|
|
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": "8ac5f539ad4739c7baa30dd68cb7d6f94e70aa3c",
|
|
27
27
|
"devDependencies": {
|
|
28
28
|
"@babel/core": "^7.12.0"
|
|
29
29
|
}
|