@putkoff/abstract-utilities 0.1.193 → 0.1.194
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/index.js +15 -15
- package/dist/cjs/index.js.map +1 -1
- package/dist/esm/index.js +15 -15
- package/dist/esm/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -17,6 +17,21 @@ function getDocumentProp(...keys) {
|
|
|
17
17
|
return obj;
|
|
18
18
|
}
|
|
19
19
|
|
|
20
|
+
/**
|
|
21
|
+
* Safely walk `globalThis` (or window/document) by a chain of property names.
|
|
22
|
+
* Returns `undefined` if any step is missing.
|
|
23
|
+
*/
|
|
24
|
+
function safeGlobalProp(...path) {
|
|
25
|
+
let obj = globalThis;
|
|
26
|
+
for (const key of path) {
|
|
27
|
+
if (obj == null || typeof obj !== "object" || !(key in obj)) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
obj = obj[key];
|
|
31
|
+
}
|
|
32
|
+
return obj;
|
|
33
|
+
}
|
|
34
|
+
|
|
20
35
|
/**
|
|
21
36
|
* Returns `window` if running in a browser, otherwise `undefined`.
|
|
22
37
|
*/
|
|
@@ -69,21 +84,6 @@ function safeStorage(storageName, method, ...args) {
|
|
|
69
84
|
}
|
|
70
85
|
}
|
|
71
86
|
|
|
72
|
-
/**
|
|
73
|
-
* Safely walk `globalThis` (or window/document) by a chain of property names.
|
|
74
|
-
* Returns `undefined` if any step is missing.
|
|
75
|
-
*/
|
|
76
|
-
function safeGlobalProp(...path) {
|
|
77
|
-
let obj = globalThis;
|
|
78
|
-
for (const key of path) {
|
|
79
|
-
if (obj == null || typeof obj !== "object" || !(key in obj)) {
|
|
80
|
-
return undefined;
|
|
81
|
-
}
|
|
82
|
-
obj = obj[key];
|
|
83
|
-
}
|
|
84
|
-
return obj;
|
|
85
|
-
}
|
|
86
|
-
|
|
87
87
|
/**
|
|
88
88
|
* Returns the global window object if it exists, otherwise undefined.
|
|
89
89
|
*/
|