resultar 3.3.0 → 3.3.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.
Files changed (2) hide show
  1. package/README.md +25 -15
  2. package/package.json +1 -1
package/README.md CHANGED
@@ -71,21 +71,6 @@ import type { StrictResult } from 'resultar'
71
71
 
72
72
  CommonJS `require('resultar')` is not exported.
73
73
 
74
- ## Mutation Testing
75
-
76
- The core runtime package has a scoped Stryker setup for mutation testing:
77
-
78
- ```sh
79
- pnpm --filter resultar test:mutation
80
- ```
81
-
82
- The setup lives in [`stryker.conf.json`](./stryker.conf.json) and is intentionally separate from
83
- `check:full`. It mutates the central runtime files under `src/`, uses the Vitest runner with
84
- per-test coverage, stores incremental state under `reports/`, and keeps baseline thresholds
85
- report-only while the mutation score is established. The dedicated
86
- [`vitest-stryker.config.ts`](./vitest-stryker.config.ts) maps `vite-plus/test` to `vitest` so
87
- Stryker can run the same tests without the `vp test` bootstrap.
88
-
89
74
  ## Why Teams Use It
90
75
 
91
76
  This signature hides an expected failure:
@@ -174,6 +159,31 @@ const getPosts = (
174
159
  )
175
160
  ```
176
161
 
162
+ The same flow can be written linearly with `safeTry` when the chain gets harder to scan:
163
+
164
+ ```ts
165
+ const getPostsLinear = (
166
+ url: string,
167
+ ): StrictResultAsync<Post[], FetchPostsError | HttpClientError | ParsePostsError> =>
168
+ safeTry(async function* () {
169
+ const response = yield* tryResultAsync(
170
+ fetch(url),
171
+ (cause) => new FetchPostsError({ cause }),
172
+ )
173
+
174
+ if (response.status >= 400) {
175
+ return HttpClientError.err({ status: response.status })
176
+ }
177
+
178
+ const posts = yield* tryResultAsync(
179
+ response.json() as Promise<Post[]>,
180
+ (cause) => new ParsePostsError({ cause }),
181
+ )
182
+
183
+ return ok(posts)
184
+ })
185
+ ```
186
+
177
187
  ## Async Control Without A Runtime
178
188
 
179
189
  The 3.1 async helpers cover common production workflows while keeping plain `Promise` and
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "resultar",
3
- "version": "3.3.0",
3
+ "version": "3.3.1",
4
4
  "description": "Result pattern for TypeScript",
5
5
  "keywords": [
6
6
  "error-handling",