typof 1.0.18 → 1.1.0
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/README.md +1 -1
- package/dist/main.cjs +3 -3
- package/dist/main.mjs +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -126,7 +126,7 @@ Infer types.
|
|
|
126
126
|
> typof(true); // ['boolean']
|
|
127
127
|
>
|
|
128
128
|
> typof('2025-01-01'); // ['string', 'date']
|
|
129
|
-
> typof(new Date('2025-01-01')); // ['
|
|
129
|
+
> typof(new Date('2025-01-01')); // ['date', 'object']
|
|
130
130
|
>
|
|
131
131
|
> typof('{"key":"value"}'); // ['string', 'object']
|
|
132
132
|
> typof({ key: 'value' }); // ['object']
|
package/dist/main.cjs
CHANGED
|
@@ -44,8 +44,8 @@ const typof = (value) => {
|
|
|
44
44
|
else types.push("float");
|
|
45
45
|
} else if (typeof value === "boolean") types.push("boolean");
|
|
46
46
|
else if (is_object(value) && !Array.isArray(value)) {
|
|
47
|
-
types.push("object");
|
|
48
47
|
if (value instanceof Date) types.push("date");
|
|
48
|
+
types.push("object");
|
|
49
49
|
} else if (is_object(value) && Array.isArray(value)) types.push("array");
|
|
50
50
|
else if (value === null) types.push("null");
|
|
51
51
|
else if (value === void 0) types.push("undefined");
|
|
@@ -63,8 +63,8 @@ const integer = (value) => {
|
|
|
63
63
|
};
|
|
64
64
|
const boolean = (value) => {
|
|
65
65
|
const types = typof(value);
|
|
66
|
-
if (types.includes("boolean") && types.includes("string")) if (value === "true") return true;
|
|
67
|
-
else if (value === "false") return false;
|
|
66
|
+
if (types.includes("boolean") && types.includes("string")) if (value.trim() === "true") return true;
|
|
67
|
+
else if (value.trim() === "false") return false;
|
|
68
68
|
else return value;
|
|
69
69
|
else return value;
|
|
70
70
|
};
|
package/dist/main.mjs
CHANGED
|
@@ -43,8 +43,8 @@ const typof = (value) => {
|
|
|
43
43
|
else types.push("float");
|
|
44
44
|
} else if (typeof value === "boolean") types.push("boolean");
|
|
45
45
|
else if (is_object(value) && !Array.isArray(value)) {
|
|
46
|
-
types.push("object");
|
|
47
46
|
if (value instanceof Date) types.push("date");
|
|
47
|
+
types.push("object");
|
|
48
48
|
} else if (is_object(value) && Array.isArray(value)) types.push("array");
|
|
49
49
|
else if (value === null) types.push("null");
|
|
50
50
|
else if (value === void 0) types.push("undefined");
|
|
@@ -62,8 +62,8 @@ const integer = (value) => {
|
|
|
62
62
|
};
|
|
63
63
|
const boolean = (value) => {
|
|
64
64
|
const types = typof(value);
|
|
65
|
-
if (types.includes("boolean") && types.includes("string")) if (value === "true") return true;
|
|
66
|
-
else if (value === "false") return false;
|
|
65
|
+
if (types.includes("boolean") && types.includes("string")) if (value.trim() === "true") return true;
|
|
66
|
+
else if (value.trim() === "false") return false;
|
|
67
67
|
else return value;
|
|
68
68
|
else return value;
|
|
69
69
|
};
|