type-guardians 1.2.1 → 1.2.2--canary.5.181a8ea.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/error.ts +10 -0
- package/number.ts +1 -1
- package/package.json +3 -2
- package/string.ts +1 -1
package/error.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
export function isError(value: unknown): value is Error {
|
|
2
|
+
return value instanceof Error;
|
|
3
|
+
}
|
|
4
|
+
|
|
5
|
+
export function assertError(
|
|
6
|
+
value: unknown,
|
|
7
|
+
message = `Expected an error, received ${typeof value}`,
|
|
8
|
+
): asserts value is string {
|
|
9
|
+
if (!isError(value)) throw new TypeError(message);
|
|
10
|
+
}
|
package/number.ts
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "type-guardians",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.2--canary.5.181a8ea.0",
|
|
4
4
|
"description": "A lightweight, zero-dependency TypeScript library providing type guards and assertions for safer and more readable code",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"typescript",
|
|
@@ -23,7 +23,8 @@
|
|
|
23
23
|
"type": "module",
|
|
24
24
|
"exports": {
|
|
25
25
|
"./string": "./string.ts",
|
|
26
|
-
"./number": "./number.ts"
|
|
26
|
+
"./number": "./number.ts",
|
|
27
|
+
"./error": "./error.ts"
|
|
27
28
|
},
|
|
28
29
|
"scripts": {
|
|
29
30
|
"lint": "biome lint .",
|
package/string.ts
CHANGED