@schukai/monster 4.43.0 → 4.43.1
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/CHANGELOG.md +8 -0
- package/package.json +1 -1
- package/source/types/typeof.mjs +24 -15
package/CHANGELOG.md
CHANGED
package/package.json
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"author":"schukai GmbH","dependencies":{"@floating-ui/dom":"^1.7.4","@popperjs/core":"^2.11.8"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"type":"module","version":"4.43.
|
1
|
+
{"author":"schukai GmbH","dependencies":{"@floating-ui/dom":"^1.7.4","@popperjs/core":"^2.11.8"},"description":"Monster is a simple library for creating fast, robust and lightweight websites.","homepage":"https://monsterjs.org/","keywords":["framework","web","dom","css","sass","mobile-first","app","front-end","templates","schukai","core","shopcloud","alvine","monster","buildmap","stack","observer","observable","uuid","node","nodelist","css-in-js","logger","log","theme"],"license":"AGPL 3.0","main":"source/monster.mjs","module":"source/monster.mjs","name":"@schukai/monster","repository":{"type":"git","url":"https://gitlab.schukai.com/oss/libraries/javascript/monster.git"},"type":"module","version":"4.43.1"}
|
package/source/types/typeof.mjs
CHANGED
@@ -15,7 +15,8 @@
|
|
15
15
|
export { typeOf };
|
16
16
|
|
17
17
|
/**
|
18
|
-
* The built-in typeof method is known to have some historical weaknesses.
|
18
|
+
* The built-in typeof method is known to have some historical weaknesses.
|
19
|
+
* This function tries to provide a better and more accurate result.
|
19
20
|
*
|
20
21
|
* @param {*} value
|
21
22
|
* @return {string}
|
@@ -25,18 +26,26 @@ export { typeOf };
|
|
25
26
|
* @throws {TypeError} value is not a primitive
|
26
27
|
*/
|
27
28
|
function typeOf(value) {
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
29
|
+
if (value === null) {
|
30
|
+
return "null";
|
31
|
+
}
|
32
|
+
|
33
|
+
const baseType = typeof value;
|
34
|
+
|
35
|
+
if (baseType !== "object" && baseType !== "function") {
|
36
|
+
return baseType;
|
37
|
+
}
|
38
|
+
|
39
|
+
const internalType = {}.toString.call(value).slice(8, -1);
|
40
|
+
|
41
|
+
if (internalType !== "Object") {
|
42
|
+
return internalType.toLowerCase();
|
43
|
+
}
|
44
|
+
|
45
|
+
const constructorName = value.constructor?.name;
|
46
|
+
if (constructorName && constructorName !== "Object") {
|
47
|
+
return constructorName.toLowerCase();
|
48
|
+
}
|
49
|
+
|
50
|
+
return "object";
|
42
51
|
}
|