type-guardians 1.2.3 → 1.2.5

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 CHANGED
@@ -60,3 +60,8 @@ function double(value: unknown) {
60
60
 
61
61
  - `isNumber(value: unknown): value is number`
62
62
  - `assertNumber(value: unknown, message?: string): asserts value is number`
63
+
64
+ ### Error
65
+
66
+ - `isError(value: unknown): value is Error`
67
+ - `assertError(value: unknown, message?: string): asserts value is Error`
package/defined.ts ADDED
@@ -0,0 +1,10 @@
1
+ export function isDefined<Value>(value: Value): value is NonNullable<Value> {
2
+ return value !== undefined && value !== null;
3
+ }
4
+
5
+ export function assertDefined<Value>(
6
+ value: Value,
7
+ message = "Expected a defined value, received undefined or null",
8
+ ): asserts value is NonNullable<Value> {
9
+ if (!isDefined(value)) throw new TypeError(message);
10
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "type-guardians",
3
- "version": "1.2.3",
3
+ "version": "1.2.5",
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",
@@ -13,7 +13,10 @@
13
13
  "guards",
14
14
  "validation"
15
15
  ],
16
- "repository": "https://github.com/pchalupa/type-guardians",
16
+ "repository": {
17
+ "type": "git",
18
+ "url": "git+https://github.com/pchalupa/type-guardians.git"
19
+ },
17
20
  "homepage": "https://github.com/pchalupa/type-guardians#readme",
18
21
  "bugs": {
19
22
  "url": "https://github.com/pchalupa/type-guardians/issues"
package/.autorc DELETED
@@ -1,12 +0,0 @@
1
- {
2
- "noVersionPrefix": true,
3
- "plugins": [
4
- "npm",
5
- [
6
- "conventional-commits",
7
- {
8
- "preset": "angular"
9
- }
10
- ]
11
- ]
12
- }
@@ -1,46 +0,0 @@
1
- name: Code Quality
2
- on: push
3
- jobs:
4
- code-quality:
5
- runs-on: ubuntu-latest
6
- timeout-minutes: 2
7
- steps:
8
- - uses: actions/checkout@v5
9
- - uses: pnpm/action-setup@v4
10
- - uses: biomejs/setup-biome@v2
11
- - uses: actions/setup-node@v4
12
- with:
13
- node-version: 22
14
- cache: 'pnpm'
15
- - run: pnpm install
16
- - run: biome ci .
17
- - run: pnpm ts:check
18
- - run: pnpm test
19
-
20
- publish:
21
- runs-on: ubuntu-latest
22
- timeout-minutes: 10
23
- permissions:
24
- pull-requests: write
25
- contents: read
26
- id-token: write
27
- environment:
28
- name: npm
29
- url: https://www.npmjs.com/package/type-guardians
30
- if: ${{ !contains(github.event.head_commit.message, 'skip ci') }}
31
- needs: code-quality
32
- steps:
33
- - uses: actions/checkout@v5
34
- with:
35
- fetch-depth: 0
36
- ssh-key: ${{ secrets.SSH_KEY }}
37
- - uses: pnpm/action-setup@v4
38
- - uses: actions/setup-node@v4
39
- with:
40
- node-version: 22
41
- cache: 'pnpm'
42
- - run: pnpm install
43
- - run: pnpm release
44
- env:
45
- GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
46
- NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
package/CHANGELOG.md DELETED
@@ -1,48 +0,0 @@
1
- # 1.2.1 (Wed Aug 20 2025)
2
-
3
- #### 🐛 Bug Fix
4
-
5
- - feat: add error type guard [#5](https://github.com/pchalupa/type-guardians/pull/5) ([@pchalupa](https://github.com/pchalupa))
6
- - chore: setup auto release [#4](https://github.com/pchalupa/type-guardians/pull/4) ([@pchalupa](https://github.com/pchalupa))
7
-
8
- #### ⚠️ Pushed to `main`
9
-
10
- - ci: needs ([@pchalupa](https://github.com/pchalupa))
11
- - docs: add description and keywords ([@pchalupa](https://github.com/pchalupa))
12
-
13
- #### Authors: 1
14
-
15
- - Petr Chalupa ([@pchalupa](https://github.com/pchalupa))
16
-
17
- ---
18
-
19
- # 1.2.1 (Wed Aug 20 2025)
20
-
21
- #### 🐛 Bug Fix
22
-
23
- - feat: add error type guard [#5](https://github.com/pchalupa/type-guardians/pull/5) ([@pchalupa](https://github.com/pchalupa))
24
- - chore: setup auto release [#4](https://github.com/pchalupa/type-guardians/pull/4) ([@pchalupa](https://github.com/pchalupa))
25
-
26
- #### ⚠️ Pushed to `main`
27
-
28
- - docs: add description and keywords ([@pchalupa](https://github.com/pchalupa))
29
-
30
- #### Authors: 1
31
-
32
- - Petr Chalupa ([@pchalupa](https://github.com/pchalupa))
33
-
34
- ---
35
-
36
- # 1.2.1 (Tue Aug 19 2025)
37
-
38
- #### 🐛 Bug Fix
39
-
40
- - chore: setup auto release [#4](https://github.com/pchalupa/type-guardians/pull/4) ([@pchalupa](https://github.com/pchalupa))
41
-
42
- #### ⚠️ Pushed to `main`
43
-
44
- - docs: add description and keywords ([@pchalupa](https://github.com/pchalupa))
45
-
46
- #### Authors: 1
47
-
48
- - Petr Chalupa ([@pchalupa](https://github.com/pchalupa))