@typed/async-data 1.0.0-beta.6 → 1.0.0-beta.8

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2023-present The Contributors
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/dist/index.d.ts CHANGED
@@ -20,7 +20,7 @@ import type { Unify } from "effect/Unify";
20
20
  * const progress: Progress = { loaded: 4, total: 10 }
21
21
  * ```
22
22
  *
23
- * @category Models
23
+ * @category State models
24
24
  * @since 1.0.0
25
25
  */
26
26
  export interface Progress {
@@ -31,7 +31,7 @@ export interface Progress {
31
31
  * A required counter lets consumers render useful progress even when the total is unknown.
32
32
  * ## Ownership and lifetime
33
33
  * Inherits the resource-free lifetime of its enclosing `Progress` value.
34
- * @category Models
34
+ * @category State models
35
35
  * @since 1.0.0
36
36
  */
37
37
  readonly loaded: number;
@@ -42,7 +42,7 @@ export interface Progress {
42
42
  * Optionality distinguishes indeterminate work from a known total without inventing a sentinel value.
43
43
  * ## Ownership and lifetime
44
44
  * Inherits the resource-free lifetime of its enclosing `Progress` value.
45
- * @category Models
45
+ * @category State models
46
46
  * @since 1.0.0
47
47
  */
48
48
  readonly total?: number | undefined;
@@ -59,7 +59,7 @@ export interface Progress {
59
59
  * import { NoData } from "@typed/async-data"
60
60
  * const initial = NoData
61
61
  * ```
62
- * @category Models
62
+ * @category State models
63
63
  * @since 1.0.0
64
64
  */
65
65
  export interface NoData {
@@ -70,7 +70,7 @@ export interface NoData {
70
70
  * A literal tag enables exhaustive matching without runtime class identity.
71
71
  * ## Ownership and lifetime
72
72
  * Inherits the resource-free lifetime of its enclosing state.
73
- * @category Models
73
+ * @category State models
74
74
  * @since 1.0.0
75
75
  */
76
76
  readonly _tag: "NoData";
@@ -87,7 +87,7 @@ export interface NoData {
87
87
  * import { loading } from "@typed/async-data"
88
88
  * const state = loading({ loaded: 0 })
89
89
  * ```
90
- * @category Models
90
+ * @category State models
91
91
  * @since 1.0.0
92
92
  */
93
93
  export interface Loading {
@@ -98,7 +98,7 @@ export interface Loading {
98
98
  * The literal tag makes loading branches explicit and exhaustively checkable.
99
99
  * ## Ownership and lifetime
100
100
  * Inherits the resource-free lifetime of its enclosing state.
101
- * @category Models
101
+ * @category State models
102
102
  * @since 1.0.0
103
103
  */
104
104
  readonly _tag: "Loading";
@@ -109,7 +109,7 @@ export interface Loading {
109
109
  * Keeping progress optional supports both determinate and uninstrumented operations.
110
110
  * ## Ownership and lifetime
111
111
  * Inherits the resource-free lifetime of its enclosing state.
112
- * @category Models
112
+ * @category State models
113
113
  * @since 1.0.0
114
114
  */
115
115
  readonly progress?: Progress | undefined;
@@ -126,7 +126,7 @@ export interface Loading {
126
126
  * import { success } from "@typed/async-data"
127
127
  * const state = success({ id: 1 })
128
128
  * ```
129
- * @category Models
129
+ * @category State models
130
130
  * @since 1.0.0
131
131
  */
132
132
  export interface Success<A> {
@@ -137,7 +137,7 @@ export interface Success<A> {
137
137
  * The literal tag enables exhaustive success handling without inspecting the payload.
138
138
  * ## Ownership and lifetime
139
139
  * Inherits the resource-free lifetime of its enclosing state.
140
- * @category Models
140
+ * @category State models
141
141
  * @since 1.0.0
142
142
  */
143
143
  readonly _tag: "Success";
@@ -148,7 +148,7 @@ export interface Success<A> {
148
148
  * The payload remains directly accessible even when `progress` marks a refresh.
149
149
  * ## Ownership and lifetime
150
150
  * Inherits the enclosing state's lifetime; the caller retains ownership of the referenced value.
151
- * @category Models
151
+ * @category State models
152
152
  * @since 1.0.0
153
153
  */
154
154
  readonly value: A;
@@ -159,7 +159,7 @@ export interface Success<A> {
159
159
  * Its presence distinguishes refreshing success from a settled success.
160
160
  * ## Ownership and lifetime
161
161
  * Inherits the resource-free lifetime of its enclosing state.
162
- * @category Models
162
+ * @category State models
163
163
  * @since 1.0.0
164
164
  */
165
165
  readonly progress?: Progress | undefined;
@@ -177,8 +177,8 @@ export interface Success<A> {
177
177
  * import { Cause } from "effect"
178
178
  * const state = failure(Cause.fail("offline"))
179
179
  * ```
180
- * See [Effect Cause](https://effect.website/docs/error-management/cause/).
181
- * @category Models
180
+ * See [Effect Cause](https://effect.website/docs/data-types/cause/).
181
+ * @category State models
182
182
  * @since 1.0.0
183
183
  */
184
184
  export interface Failure<E> {
@@ -189,7 +189,7 @@ export interface Failure<E> {
189
189
  * The literal tag separates failure from absence and loading.
190
190
  * ## Ownership and lifetime
191
191
  * Inherits the resource-free lifetime of its enclosing state.
192
- * @category Models
192
+ * @category State models
193
193
  * @since 1.0.0
194
194
  */
195
195
  readonly _tag: "Failure";
@@ -200,7 +200,7 @@ export interface Failure<E> {
200
200
  * Cause preservation keeps defects and interruption observable alongside typed failures.
201
201
  * ## Ownership and lifetime
202
202
  * Inherits the enclosing state's lifetime; Effect Cause is persistent.
203
- * @category Models
203
+ * @category State models
204
204
  * @since 1.0.0
205
205
  */
206
206
  readonly cause: Cause.Cause<E>;
@@ -211,7 +211,7 @@ export interface Failure<E> {
211
211
  * Its presence distinguishes a refreshing failure from a settled failure.
212
212
  * ## Ownership and lifetime
213
213
  * Inherits the resource-free lifetime of its enclosing state.
214
- * @category Models
214
+ * @category State models
215
215
  * @since 1.0.0
216
216
  */
217
217
  readonly progress?: Progress | undefined;
@@ -228,7 +228,7 @@ export interface Failure<E> {
228
228
  * import { optimistic, success } from "@typed/async-data"
229
229
  * const state = optimistic(success(1), 2)
230
230
  * ```
231
- * @category Models
231
+ * @category State models
232
232
  * @since 1.0.0
233
233
  */
234
234
  export interface Optimistic<A, E> {
@@ -239,7 +239,7 @@ export interface Optimistic<A, E> {
239
239
  * The literal tag enables explicit optimistic handling and cycle-safe traversal.
240
240
  * ## Ownership and lifetime
241
241
  * Inherits the resource-free lifetime of its enclosing state.
242
- * @category Models
242
+ * @category State models
243
243
  * @since 1.0.0
244
244
  */
245
245
  readonly _tag: "Optimistic";
@@ -250,7 +250,7 @@ export interface Optimistic<A, E> {
250
250
  * Separating the provisional value from history makes pending intent directly observable.
251
251
  * ## Ownership and lifetime
252
252
  * Inherits the enclosing state's lifetime; the caller retains ownership of the referenced value.
253
- * @category Models
253
+ * @category State models
254
254
  * @since 1.0.0
255
255
  */
256
256
  readonly value: A;
@@ -261,7 +261,7 @@ export interface Optimistic<A, E> {
261
261
  * Explicit history supports deterministic rollback and transformation of nested optimistic states.
262
262
  * ## Ownership and lifetime
263
263
  * Inherits the enclosing optimistic wrapper's resource-free lifetime.
264
- * @category Models
264
+ * @category State models
265
265
  * @since 1.0.0
266
266
  */
267
267
  readonly previous: AsyncData<A, E>;
@@ -279,7 +279,7 @@ export interface Optimistic<A, E> {
279
279
  * import { success } from "@typed/async-data"
280
280
  * const state: AsyncData<number, string> = success(1)
281
281
  * ```
282
- * @category Models
282
+ * @category State models
283
283
  * @since 1.0.0
284
284
  */
285
285
  export type AsyncData<A, E> = NoData | Loading | Success<A> | Failure<E> | Optimistic<A, E>;
@@ -295,7 +295,7 @@ export type AsyncData<A, E> = NoData | Loading | Success<A> | Failure<E> | Optim
295
295
  * import type { Refreshing } from "@typed/async-data"
296
296
  * const state: Refreshing<number, never> = { _tag: "Success", value: 1, progress: { loaded: 0 } }
297
297
  * ```
298
- * @category Models
298
+ * @category State models
299
299
  * @since 1.0.0
300
300
  */
301
301
  export type Refreshing<A, E> = (Success<A> | Failure<E>) & {
@@ -327,7 +327,7 @@ type EncodedAsyncData<A, E> = NoData | Loading | Success<A> | EncodedFailure | E
327
327
  * const codec = AsyncData(Schema.String, Schema.String)
328
328
  * ```
329
329
  * See [Effect Schema](https://effect.website/docs/schema/introduction/).
330
- * @category Schemas
330
+ * @category Serialization
331
331
  * @since 1.0.0
332
332
  */
333
333
  export declare const AsyncData: <const A extends Schema.Top, E extends Schema.Top>(A: A, E: E) => Schema.Codec<AsyncData<A["Type"], E["Type"]>, EncodedAsyncData<A["Encoded"], E["Encoded"]>, A["DecodingServices"] | E["DecodingServices"], A["EncodingServices"] | E["EncodingServices"]>;
@@ -343,7 +343,7 @@ export declare const AsyncData: <const A extends Schema.Top, E extends Schema.To
343
343
  * import { isNoData, NoData } from "@typed/async-data"
344
344
  * isNoData(NoData)
345
345
  * ```
346
- * @category Refinements
346
+ * @category State inspection
347
347
  * @since 1.0.0
348
348
  */
349
349
  export declare const isNoData: <A, E>(asyncData: AsyncData<A, E>) => asyncData is NoData;
@@ -359,7 +359,7 @@ export declare const isNoData: <A, E>(asyncData: AsyncData<A, E>) => asyncData i
359
359
  * import { isLoading, loading } from "@typed/async-data"
360
360
  * isLoading(loading())
361
361
  * ```
362
- * @category Refinements
362
+ * @category State inspection
363
363
  * @since 1.0.0
364
364
  */
365
365
  export declare const isLoading: <A, E>(asyncData: AsyncData<A, E>) => asyncData is Loading;
@@ -375,7 +375,7 @@ export declare const isLoading: <A, E>(asyncData: AsyncData<A, E>) => asyncData
375
375
  * import { isSuccess, success } from "@typed/async-data"
376
376
  * isSuccess(success(1))
377
377
  * ```
378
- * @category Refinements
378
+ * @category State inspection
379
379
  * @since 1.0.0
380
380
  */
381
381
  export declare const isSuccess: <A, E>(asyncData: AsyncData<A, E>) => asyncData is Success<A>;
@@ -392,7 +392,7 @@ export declare const isSuccess: <A, E>(asyncData: AsyncData<A, E>) => asyncData
392
392
  * import { Cause } from "effect"
393
393
  * isFailure(failure(Cause.fail("offline")))
394
394
  * ```
395
- * @category Refinements
395
+ * @category State inspection
396
396
  * @since 1.0.0
397
397
  */
398
398
  export declare const isFailure: <A, E>(asyncData: AsyncData<A, E>) => asyncData is Failure<E>;
@@ -408,7 +408,7 @@ export declare const isFailure: <A, E>(asyncData: AsyncData<A, E>) => asyncData
408
408
  * import { isOptimistic, optimistic, success } from "@typed/async-data"
409
409
  * isOptimistic(optimistic(success(1), 2))
410
410
  * ```
411
- * @category Refinements
411
+ * @category State inspection
412
412
  * @since 1.0.0
413
413
  */
414
414
  export declare const isOptimistic: <A, E>(asyncData: AsyncData<A, E>) => asyncData is Optimistic<A, E>;
@@ -424,7 +424,7 @@ export declare const isOptimistic: <A, E>(asyncData: AsyncData<A, E>) => asyncDa
424
424
  * import { isAsyncData } from "@typed/async-data"
425
425
  * isAsyncData({ _tag: "Loading", progress: { loaded: 1 } })
426
426
  * ```
427
- * @category Refinements
427
+ * @category Runtime validation
428
428
  * @since 1.0.0
429
429
  */
430
430
  export declare const isAsyncData: <A, E>(u: unknown) => u is AsyncData<A, E>;
@@ -440,7 +440,7 @@ export declare const isAsyncData: <A, E>(u: unknown) => u is AsyncData<A, E>;
440
440
  * import { isRefreshing, success } from "@typed/async-data"
441
441
  * isRefreshing(success("cached", { loaded: 0 }))
442
442
  * ```
443
- * @category Refinements
443
+ * @category State inspection
444
444
  * @since 1.0.0
445
445
  */
446
446
  export declare const isRefreshing: <A, E>(asyncData: AsyncData<A, E>) => asyncData is Refreshing<A, E>;
@@ -458,7 +458,7 @@ export declare const isRefreshing: <A, E>(asyncData: AsyncData<A, E>) => asyncDa
458
458
  * import { isPending, loading, optimistic } from "@typed/async-data"
459
459
  * isPending(optimistic(loading(), "draft"))
460
460
  * ```
461
- * @category Refinements
461
+ * @category State inspection
462
462
  * @since 1.0.0
463
463
  */
464
464
  export declare const isPending: <A, E>(asyncData: AsyncData<A, E>) => asyncData is Loading | Refreshing<A, E>;
@@ -474,7 +474,7 @@ export declare const isPending: <A, E>(asyncData: AsyncData<A, E>) => asyncData
474
474
  * import { NoData } from "@typed/async-data"
475
475
  * const initial = NoData
476
476
  * ```
477
- * @category Constructors
477
+ * @category State construction
478
478
  * @since 1.0.0
479
479
  */
480
480
  export declare const NoData: NoData;
@@ -490,7 +490,7 @@ export declare const NoData: NoData;
490
490
  * import { loading } from "@typed/async-data"
491
491
  * const state = loading({ loaded: 2, total: 5 })
492
492
  * ```
493
- * @category Constructors
493
+ * @category State construction
494
494
  * @since 1.0.0
495
495
  */
496
496
  export declare const loading: (progress?: Progress) => Loading;
@@ -506,7 +506,7 @@ export declare const loading: (progress?: Progress) => Loading;
506
506
  * import { success } from "@typed/async-data"
507
507
  * const state = success("ready")
508
508
  * ```
509
- * @category Constructors
509
+ * @category State construction
510
510
  * @since 1.0.0
511
511
  */
512
512
  export declare const success: <A>(value: A, progress?: Progress) => Success<A>;
@@ -523,7 +523,7 @@ export declare const success: <A>(value: A, progress?: Progress) => Success<A>;
523
523
  * import { Cause } from "effect"
524
524
  * const state = failure(Cause.fail("offline"))
525
525
  * ```
526
- * @category Constructors
526
+ * @category State construction
527
527
  * @since 1.0.0
528
528
  */
529
529
  export declare const failure: <E>(cause: Cause.Cause<E>, progress?: Progress) => Failure<E>;
@@ -539,7 +539,7 @@ export declare const failure: <E>(cause: Cause.Cause<E>, progress?: Progress) =>
539
539
  * import { optimistic, success } from "@typed/async-data"
540
540
  * const state = optimistic(success("saved"), "saving")
541
541
  * ```
542
- * @category Constructors
542
+ * @category Optimistic transitions
543
543
  * @since 1.0.0
544
544
  */
545
545
  export declare const optimistic: <A, E>(previous: AsyncData<A, E>, value: A) => Optimistic<A, E>;
@@ -555,7 +555,7 @@ export declare const optimistic: <A, E>(previous: AsyncData<A, E>, value: A) =>
555
555
  * import { startLoading, success } from "@typed/async-data"
556
556
  * const refreshing = startLoading(success("cached"))
557
557
  * ```
558
- * @category Transformations
558
+ * @category Refresh transitions
559
559
  * @since 1.0.0
560
560
  */
561
561
  export declare const startLoading: <A, E>(data: AsyncData<A, E>, progress?: Progress) => AsyncData<A, E>;
@@ -571,7 +571,7 @@ export declare const startLoading: <A, E>(data: AsyncData<A, E>, progress?: Prog
571
571
  * import { startLoading, stopLoading, success } from "@typed/async-data"
572
572
  * const settled = stopLoading(startLoading(success("cached")))
573
573
  * ```
574
- * @category Transformations
574
+ * @category Refresh transitions
575
575
  * @since 1.0.0
576
576
  */
577
577
  export declare const stopLoading: <A, E>(data: AsyncData<A, E>) => AsyncData<A, E>;
@@ -587,7 +587,7 @@ export declare const stopLoading: <A, E>(data: AsyncData<A, E>) => AsyncData<A,
587
587
  * import { match } from "@typed/async-data"
588
588
  * const label = match({ NoData: () => "empty", Loading: () => "loading", Failure: () => "failed", Success: String, Optimistic: String })
589
589
  * ```
590
- * @category Folding
590
+ * @category Pattern matching
591
591
  * @since 1.0.0
592
592
  */
593
593
  export declare const match: {
@@ -619,7 +619,7 @@ export declare const match: {
619
619
  * const value = getSuccess(success(1))
620
620
  * ```
621
621
  * See [Effect Option](https://effect.website/docs/data-types/option/).
622
- * @category Accessors
622
+ * @category State extraction
623
623
  * @since 1.0.0
624
624
  */
625
625
  export declare function getSuccess<A, E>(data: AsyncData<A, E>): Option.Option<A>;
@@ -636,7 +636,7 @@ export declare function getSuccess<A, E>(data: AsyncData<A, E>): Option.Option<A
636
636
  * import { Cause } from "effect"
637
637
  * const cause = getCause(failure(Cause.fail("offline")))
638
638
  * ```
639
- * @category Accessors
639
+ * @category State extraction
640
640
  * @since 1.0.0
641
641
  */
642
642
  export declare function getCause<A, E>(data: AsyncData<A, E>): Option.Option<Cause.Cause<E>>;
@@ -653,7 +653,7 @@ export declare function getCause<A, E>(data: AsyncData<A, E>): Option.Option<Cau
653
653
  * import { Cause } from "effect"
654
654
  * const error = getError(failure(Cause.fail("offline")))
655
655
  * ```
656
- * @category Accessors
656
+ * @category State extraction
657
657
  * @since 1.0.0
658
658
  */
659
659
  export declare function getError<A, E>(data: AsyncData<A, E>): Option.Option<E>;
@@ -669,7 +669,7 @@ export declare function getError<A, E>(data: AsyncData<A, E>): Option.Option<E>;
669
669
  * import { map, success } from "@typed/async-data"
670
670
  * const state = map(success(2), (n) => n * 2)
671
671
  * ```
672
- * @category Transformations
672
+ * @category Value transformations
673
673
  * @since 1.0.0
674
674
  */
675
675
  export declare const map: {
@@ -688,7 +688,7 @@ export declare const map: {
688
688
  * import { flatMap, success } from "@typed/async-data"
689
689
  * const parsed = flatMap(success("2"), (text) => success(Number(text)))
690
690
  * ```
691
- * @category Transformations
691
+ * @category Value transformations
692
692
  * @since 1.0.0
693
693
  */
694
694
  export declare const flatMap: {
@@ -708,7 +708,7 @@ export declare const flatMap: {
708
708
  * import { Cause } from "effect"
709
709
  * const state = mapError(failure(Cause.fail(404)), String)
710
710
  * ```
711
- * @category Transformations
711
+ * @category Failure transformations
712
712
  * @since 1.0.0
713
713
  */
714
714
  export declare const mapError: {
@@ -728,7 +728,7 @@ export declare const mapError: {
728
728
  * import { Exit } from "effect"
729
729
  * const state = fromExit(Exit.succeed(1))
730
730
  * ```
731
- * @category Conversions
731
+ * @category Effect outcome conversion
732
732
  * @since 1.0.0
733
733
  */
734
734
  export declare const fromExit: <A, E>(exit: Exit.Exit<A, E>) => AsyncData<A, E>;
@@ -745,7 +745,7 @@ export declare const fromExit: <A, E>(exit: Exit.Exit<A, E>) => AsyncData<A, E>;
745
745
  * import { Result } from "effect"
746
746
  * const state = fromResult(Result.succeed(1))
747
747
  * ```
748
- * @category Conversions
748
+ * @category Effect outcome conversion
749
749
  * @since 1.0.0
750
750
  */
751
751
  export declare const fromResult: <A, E>(result: Result.Result<A, E>) => AsyncData<A, E>;
package/dist/index.js CHANGED
@@ -19,7 +19,7 @@ import * as Schema from "effect/Schema";
19
19
  * const codec = AsyncData(Schema.String, Schema.String)
20
20
  * ```
21
21
  * See [Effect Schema](https://effect.website/docs/schema/introduction/).
22
- * @category Schemas
22
+ * @category Serialization
23
23
  * @since 1.0.0
24
24
  */
25
25
  export const AsyncData = (A, E) => {
@@ -66,7 +66,7 @@ export const AsyncData = (A, E) => {
66
66
  * import { isNoData, NoData } from "@typed/async-data"
67
67
  * isNoData(NoData)
68
68
  * ```
69
- * @category Refinements
69
+ * @category State inspection
70
70
  * @since 1.0.0
71
71
  */
72
72
  export const isNoData = (asyncData) => asyncData._tag === "NoData";
@@ -82,7 +82,7 @@ export const isNoData = (asyncData) => asyncData._tag === "NoData";
82
82
  * import { isLoading, loading } from "@typed/async-data"
83
83
  * isLoading(loading())
84
84
  * ```
85
- * @category Refinements
85
+ * @category State inspection
86
86
  * @since 1.0.0
87
87
  */
88
88
  export const isLoading = (asyncData) => asyncData._tag === "Loading";
@@ -98,7 +98,7 @@ export const isLoading = (asyncData) => asyncData._tag === "Loading";
98
98
  * import { isSuccess, success } from "@typed/async-data"
99
99
  * isSuccess(success(1))
100
100
  * ```
101
- * @category Refinements
101
+ * @category State inspection
102
102
  * @since 1.0.0
103
103
  */
104
104
  export const isSuccess = (asyncData) => asyncData._tag === "Success";
@@ -115,7 +115,7 @@ export const isSuccess = (asyncData) => asyncData._tag === "Success";
115
115
  * import { Cause } from "effect"
116
116
  * isFailure(failure(Cause.fail("offline")))
117
117
  * ```
118
- * @category Refinements
118
+ * @category State inspection
119
119
  * @since 1.0.0
120
120
  */
121
121
  export const isFailure = (asyncData) => asyncData._tag === "Failure";
@@ -131,7 +131,7 @@ export const isFailure = (asyncData) => asyncData._tag === "Failure";
131
131
  * import { isOptimistic, optimistic, success } from "@typed/async-data"
132
132
  * isOptimistic(optimistic(success(1), 2))
133
133
  * ```
134
- * @category Refinements
134
+ * @category State inspection
135
135
  * @since 1.0.0
136
136
  */
137
137
  export const isOptimistic = (asyncData) => asyncData._tag === "Optimistic";
@@ -160,7 +160,7 @@ const hasValidProgress = (u) => {
160
160
  * import { isAsyncData } from "@typed/async-data"
161
161
  * isAsyncData({ _tag: "Loading", progress: { loaded: 1 } })
162
162
  * ```
163
- * @category Refinements
163
+ * @category Runtime validation
164
164
  * @since 1.0.0
165
165
  */
166
166
  export const isAsyncData = (u) => {
@@ -203,7 +203,7 @@ export const isAsyncData = (u) => {
203
203
  * import { isRefreshing, success } from "@typed/async-data"
204
204
  * isRefreshing(success("cached", { loaded: 0 }))
205
205
  * ```
206
- * @category Refinements
206
+ * @category State inspection
207
207
  * @since 1.0.0
208
208
  */
209
209
  export const isRefreshing = (asyncData) => (asyncData._tag === "Success" || asyncData._tag === "Failure") &&
@@ -222,7 +222,7 @@ export const isRefreshing = (asyncData) => (asyncData._tag === "Success" || asyn
222
222
  * import { isPending, loading, optimistic } from "@typed/async-data"
223
223
  * isPending(optimistic(loading(), "draft"))
224
224
  * ```
225
- * @category Refinements
225
+ * @category State inspection
226
226
  * @since 1.0.0
227
227
  */
228
228
  export const isPending = (asyncData) => {
@@ -249,7 +249,7 @@ export const isPending = (asyncData) => {
249
249
  * import { NoData } from "@typed/async-data"
250
250
  * const initial = NoData
251
251
  * ```
252
- * @category Constructors
252
+ * @category State construction
253
253
  * @since 1.0.0
254
254
  */
255
255
  export const NoData = { _tag: "NoData" };
@@ -265,7 +265,7 @@ export const NoData = { _tag: "NoData" };
265
265
  * import { loading } from "@typed/async-data"
266
266
  * const state = loading({ loaded: 2, total: 5 })
267
267
  * ```
268
- * @category Constructors
268
+ * @category State construction
269
269
  * @since 1.0.0
270
270
  */
271
271
  export const loading = (progress) => ({ _tag: "Loading", progress });
@@ -281,7 +281,7 @@ export const loading = (progress) => ({ _tag: "Loading", progress });
281
281
  * import { success } from "@typed/async-data"
282
282
  * const state = success("ready")
283
283
  * ```
284
- * @category Constructors
284
+ * @category State construction
285
285
  * @since 1.0.0
286
286
  */
287
287
  export const success = (value, progress) => ({
@@ -302,7 +302,7 @@ export const success = (value, progress) => ({
302
302
  * import { Cause } from "effect"
303
303
  * const state = failure(Cause.fail("offline"))
304
304
  * ```
305
- * @category Constructors
305
+ * @category State construction
306
306
  * @since 1.0.0
307
307
  */
308
308
  export const failure = (cause, progress) => ({
@@ -322,7 +322,7 @@ export const failure = (cause, progress) => ({
322
322
  * import { optimistic, success } from "@typed/async-data"
323
323
  * const state = optimistic(success("saved"), "saving")
324
324
  * ```
325
- * @category Constructors
325
+ * @category Optimistic transitions
326
326
  * @since 1.0.0
327
327
  */
328
328
  export const optimistic = (previous, value) => ({
@@ -364,7 +364,7 @@ const refreshingProgress = (progress, existing) => progress ?? existing ?? { loa
364
364
  * import { startLoading, success } from "@typed/async-data"
365
365
  * const refreshing = startLoading(success("cached"))
366
366
  * ```
367
- * @category Transformations
367
+ * @category Refresh transitions
368
368
  * @since 1.0.0
369
369
  */
370
370
  export const startLoading = (data, progress) => {
@@ -396,7 +396,7 @@ export const startLoading = (data, progress) => {
396
396
  * import { startLoading, stopLoading, success } from "@typed/async-data"
397
397
  * const settled = stopLoading(startLoading(success("cached")))
398
398
  * ```
399
- * @category Transformations
399
+ * @category Refresh transitions
400
400
  * @since 1.0.0
401
401
  */
402
402
  export const stopLoading = (data) => {
@@ -425,7 +425,7 @@ export const stopLoading = (data) => {
425
425
  * import { match } from "@typed/async-data"
426
426
  * const label = match({ NoData: () => "empty", Loading: () => "loading", Failure: () => "failed", Success: String, Optimistic: String })
427
427
  * ```
428
- * @category Folding
428
+ * @category Pattern matching
429
429
  * @since 1.0.0
430
430
  */
431
431
  export const match = dual(2, (data, matchers) => {
@@ -458,7 +458,7 @@ export const match = dual(2, (data, matchers) => {
458
458
  * const value = getSuccess(success(1))
459
459
  * ```
460
460
  * See [Effect Option](https://effect.website/docs/data-types/option/).
461
- * @category Accessors
461
+ * @category State extraction
462
462
  * @since 1.0.0
463
463
  */
464
464
  export function getSuccess(data) {
@@ -483,7 +483,7 @@ export function getSuccess(data) {
483
483
  * import { Cause } from "effect"
484
484
  * const cause = getCause(failure(Cause.fail("offline")))
485
485
  * ```
486
- * @category Accessors
486
+ * @category State extraction
487
487
  * @since 1.0.0
488
488
  */
489
489
  export function getCause(data) {
@@ -508,7 +508,7 @@ export function getCause(data) {
508
508
  * import { Cause } from "effect"
509
509
  * const error = getError(failure(Cause.fail("offline")))
510
510
  * ```
511
- * @category Accessors
511
+ * @category State extraction
512
512
  * @since 1.0.0
513
513
  */
514
514
  export function getError(data) {
@@ -532,7 +532,7 @@ export function getError(data) {
532
532
  * import { map, success } from "@typed/async-data"
533
533
  * const state = map(success(2), (n) => n * 2)
534
534
  * ```
535
- * @category Transformations
535
+ * @category Value transformations
536
536
  * @since 1.0.0
537
537
  */
538
538
  export const map = dual(2, function map(data, f) {
@@ -561,7 +561,7 @@ export const map = dual(2, function map(data, f) {
561
561
  * import { flatMap, success } from "@typed/async-data"
562
562
  * const parsed = flatMap(success("2"), (text) => success(Number(text)))
563
563
  * ```
564
- * @category Transformations
564
+ * @category Value transformations
565
565
  * @since 1.0.0
566
566
  */
567
567
  export const flatMap = dual(2, function (data, f) {
@@ -585,7 +585,7 @@ export const flatMap = dual(2, function (data, f) {
585
585
  * import { Cause } from "effect"
586
586
  * const state = mapError(failure(Cause.fail(404)), String)
587
587
  * ```
588
- * @category Transformations
588
+ * @category Failure transformations
589
589
  * @since 1.0.0
590
590
  */
591
591
  export const mapError = dual(2, function mapError(data, f) {
@@ -612,7 +612,7 @@ export const mapError = dual(2, function mapError(data, f) {
612
612
  * import { Exit } from "effect"
613
613
  * const state = fromExit(Exit.succeed(1))
614
614
  * ```
615
- * @category Conversions
615
+ * @category Effect outcome conversion
616
616
  * @since 1.0.0
617
617
  */
618
618
  export const fromExit = (exit) => Exit.isSuccess(exit) ? success(exit.value) : failure(exit.cause);
@@ -629,7 +629,7 @@ export const fromExit = (exit) => Exit.isSuccess(exit) ? success(exit.value) : f
629
629
  * import { Result } from "effect"
630
630
  * const state = fromResult(Result.succeed(1))
631
631
  * ```
632
- * @category Conversions
632
+ * @category Effect outcome conversion
633
633
  * @since 1.0.0
634
634
  */
635
635
  export const fromResult = (result) => Result.isSuccess(result) ? success(result.success) : failure(Cause.fail(result.failure));
package/package.json CHANGED
@@ -1,13 +1,13 @@
1
1
  {
2
2
  "name": "@typed/async-data",
3
- "version": "1.0.0-beta.6",
3
+ "version": "1.0.0-beta.8",
4
4
  "description": "Async data states for Typed applications.",
5
5
  "license": "MIT",
6
- "homepage": "https://github.com/TylorS/typed-smol/tree/main/packages/async-data#readme",
7
- "bugs": "https://github.com/TylorS/typed-smol/issues",
6
+ "homepage": "https://github.com/TylorS/typed/tree/development/packages/async-data#readme",
7
+ "bugs": "https://github.com/TylorS/typed/issues",
8
8
  "repository": {
9
9
  "type": "git",
10
- "url": "git+https://github.com/TylorS/typed-smol.git",
10
+ "url": "git+https://github.com/TylorS/typed.git",
11
11
  "directory": "packages/async-data"
12
12
  },
13
13
  "files": [
@@ -17,6 +17,7 @@
17
17
  "!src/**/*.test.*"
18
18
  ],
19
19
  "type": "module",
20
+ "sideEffects": false,
20
21
  "exports": {
21
22
  ".": {
22
23
  "types": "./dist/index.d.ts",
@@ -26,16 +27,16 @@
26
27
  "publishConfig": {
27
28
  "access": "public"
28
29
  },
30
+ "dependencies": {
31
+ "effect": "4.0.0-rc.112"
32
+ },
33
+ "devDependencies": {
34
+ "typescript": "7.0.2",
35
+ "vitest": "5.0.0"
36
+ },
29
37
  "scripts": {
30
38
  "build": "node -e \"const fs=require('node:fs'); fs.rmSync('dist',{recursive:true,force:true}); fs.rmSync('tsconfig.tsbuildinfo',{force:true})\" && tsc",
31
39
  "test": "vitest run --config vitest.config.ts",
32
40
  "test:types": "pnpm run build && tsc -p tsconfig.type-tests.json && tsc -p tsconfig.tests.json"
33
- },
34
- "dependencies": {
35
- "effect": "catalog:"
36
- },
37
- "devDependencies": {
38
- "typescript": "catalog:",
39
- "vitest": "catalog:"
40
41
  }
41
- }
42
+ }
package/src/index.ts CHANGED
@@ -23,7 +23,7 @@ import type { Unify } from "effect/Unify";
23
23
  * const progress: Progress = { loaded: 4, total: 10 }
24
24
  * ```
25
25
  *
26
- * @category Models
26
+ * @category State models
27
27
  * @since 1.0.0
28
28
  */
29
29
  export interface Progress {
@@ -34,7 +34,7 @@ export interface Progress {
34
34
  * A required counter lets consumers render useful progress even when the total is unknown.
35
35
  * ## Ownership and lifetime
36
36
  * Inherits the resource-free lifetime of its enclosing `Progress` value.
37
- * @category Models
37
+ * @category State models
38
38
  * @since 1.0.0
39
39
  */
40
40
  readonly loaded: number;
@@ -45,7 +45,7 @@ export interface Progress {
45
45
  * Optionality distinguishes indeterminate work from a known total without inventing a sentinel value.
46
46
  * ## Ownership and lifetime
47
47
  * Inherits the resource-free lifetime of its enclosing `Progress` value.
48
- * @category Models
48
+ * @category State models
49
49
  * @since 1.0.0
50
50
  */
51
51
  readonly total?: number | undefined;
@@ -63,7 +63,7 @@ export interface Progress {
63
63
  * import { NoData } from "@typed/async-data"
64
64
  * const initial = NoData
65
65
  * ```
66
- * @category Models
66
+ * @category State models
67
67
  * @since 1.0.0
68
68
  */
69
69
  export interface NoData {
@@ -74,7 +74,7 @@ export interface NoData {
74
74
  * A literal tag enables exhaustive matching without runtime class identity.
75
75
  * ## Ownership and lifetime
76
76
  * Inherits the resource-free lifetime of its enclosing state.
77
- * @category Models
77
+ * @category State models
78
78
  * @since 1.0.0
79
79
  */
80
80
  readonly _tag: "NoData";
@@ -92,7 +92,7 @@ export interface NoData {
92
92
  * import { loading } from "@typed/async-data"
93
93
  * const state = loading({ loaded: 0 })
94
94
  * ```
95
- * @category Models
95
+ * @category State models
96
96
  * @since 1.0.0
97
97
  */
98
98
  export interface Loading {
@@ -103,7 +103,7 @@ export interface Loading {
103
103
  * The literal tag makes loading branches explicit and exhaustively checkable.
104
104
  * ## Ownership and lifetime
105
105
  * Inherits the resource-free lifetime of its enclosing state.
106
- * @category Models
106
+ * @category State models
107
107
  * @since 1.0.0
108
108
  */
109
109
  readonly _tag: "Loading";
@@ -114,7 +114,7 @@ export interface Loading {
114
114
  * Keeping progress optional supports both determinate and uninstrumented operations.
115
115
  * ## Ownership and lifetime
116
116
  * Inherits the resource-free lifetime of its enclosing state.
117
- * @category Models
117
+ * @category State models
118
118
  * @since 1.0.0
119
119
  */
120
120
  readonly progress?: Progress | undefined;
@@ -132,7 +132,7 @@ export interface Loading {
132
132
  * import { success } from "@typed/async-data"
133
133
  * const state = success({ id: 1 })
134
134
  * ```
135
- * @category Models
135
+ * @category State models
136
136
  * @since 1.0.0
137
137
  */
138
138
  export interface Success<A> {
@@ -143,7 +143,7 @@ export interface Success<A> {
143
143
  * The literal tag enables exhaustive success handling without inspecting the payload.
144
144
  * ## Ownership and lifetime
145
145
  * Inherits the resource-free lifetime of its enclosing state.
146
- * @category Models
146
+ * @category State models
147
147
  * @since 1.0.0
148
148
  */
149
149
  readonly _tag: "Success";
@@ -154,7 +154,7 @@ export interface Success<A> {
154
154
  * The payload remains directly accessible even when `progress` marks a refresh.
155
155
  * ## Ownership and lifetime
156
156
  * Inherits the enclosing state's lifetime; the caller retains ownership of the referenced value.
157
- * @category Models
157
+ * @category State models
158
158
  * @since 1.0.0
159
159
  */
160
160
  readonly value: A;
@@ -165,7 +165,7 @@ export interface Success<A> {
165
165
  * Its presence distinguishes refreshing success from a settled success.
166
166
  * ## Ownership and lifetime
167
167
  * Inherits the resource-free lifetime of its enclosing state.
168
- * @category Models
168
+ * @category State models
169
169
  * @since 1.0.0
170
170
  */
171
171
  readonly progress?: Progress | undefined;
@@ -184,8 +184,8 @@ export interface Success<A> {
184
184
  * import { Cause } from "effect"
185
185
  * const state = failure(Cause.fail("offline"))
186
186
  * ```
187
- * See [Effect Cause](https://effect.website/docs/error-management/cause/).
188
- * @category Models
187
+ * See [Effect Cause](https://effect.website/docs/data-types/cause/).
188
+ * @category State models
189
189
  * @since 1.0.0
190
190
  */
191
191
  export interface Failure<E> {
@@ -196,7 +196,7 @@ export interface Failure<E> {
196
196
  * The literal tag separates failure from absence and loading.
197
197
  * ## Ownership and lifetime
198
198
  * Inherits the resource-free lifetime of its enclosing state.
199
- * @category Models
199
+ * @category State models
200
200
  * @since 1.0.0
201
201
  */
202
202
  readonly _tag: "Failure";
@@ -207,7 +207,7 @@ export interface Failure<E> {
207
207
  * Cause preservation keeps defects and interruption observable alongside typed failures.
208
208
  * ## Ownership and lifetime
209
209
  * Inherits the enclosing state's lifetime; Effect Cause is persistent.
210
- * @category Models
210
+ * @category State models
211
211
  * @since 1.0.0
212
212
  */
213
213
  readonly cause: Cause.Cause<E>;
@@ -218,7 +218,7 @@ export interface Failure<E> {
218
218
  * Its presence distinguishes a refreshing failure from a settled failure.
219
219
  * ## Ownership and lifetime
220
220
  * Inherits the resource-free lifetime of its enclosing state.
221
- * @category Models
221
+ * @category State models
222
222
  * @since 1.0.0
223
223
  */
224
224
  readonly progress?: Progress | undefined;
@@ -236,7 +236,7 @@ export interface Failure<E> {
236
236
  * import { optimistic, success } from "@typed/async-data"
237
237
  * const state = optimistic(success(1), 2)
238
238
  * ```
239
- * @category Models
239
+ * @category State models
240
240
  * @since 1.0.0
241
241
  */
242
242
  export interface Optimistic<A, E> {
@@ -247,7 +247,7 @@ export interface Optimistic<A, E> {
247
247
  * The literal tag enables explicit optimistic handling and cycle-safe traversal.
248
248
  * ## Ownership and lifetime
249
249
  * Inherits the resource-free lifetime of its enclosing state.
250
- * @category Models
250
+ * @category State models
251
251
  * @since 1.0.0
252
252
  */
253
253
  readonly _tag: "Optimistic";
@@ -258,7 +258,7 @@ export interface Optimistic<A, E> {
258
258
  * Separating the provisional value from history makes pending intent directly observable.
259
259
  * ## Ownership and lifetime
260
260
  * Inherits the enclosing state's lifetime; the caller retains ownership of the referenced value.
261
- * @category Models
261
+ * @category State models
262
262
  * @since 1.0.0
263
263
  */
264
264
  readonly value: A;
@@ -269,7 +269,7 @@ export interface Optimistic<A, E> {
269
269
  * Explicit history supports deterministic rollback and transformation of nested optimistic states.
270
270
  * ## Ownership and lifetime
271
271
  * Inherits the enclosing optimistic wrapper's resource-free lifetime.
272
- * @category Models
272
+ * @category State models
273
273
  * @since 1.0.0
274
274
  */
275
275
  readonly previous: AsyncData<A, E>;
@@ -288,7 +288,7 @@ export interface Optimistic<A, E> {
288
288
  * import { success } from "@typed/async-data"
289
289
  * const state: AsyncData<number, string> = success(1)
290
290
  * ```
291
- * @category Models
291
+ * @category State models
292
292
  * @since 1.0.0
293
293
  */
294
294
  export type AsyncData<A, E> = NoData | Loading | Success<A> | Failure<E> | Optimistic<A, E>;
@@ -305,7 +305,7 @@ export type AsyncData<A, E> = NoData | Loading | Success<A> | Failure<E> | Optim
305
305
  * import type { Refreshing } from "@typed/async-data"
306
306
  * const state: Refreshing<number, never> = { _tag: "Success", value: 1, progress: { loaded: 0 } }
307
307
  * ```
308
- * @category Models
308
+ * @category State models
309
309
  * @since 1.0.0
310
310
  */
311
311
  export type Refreshing<A, E> = (Success<A> | Failure<E>) & {
@@ -346,7 +346,7 @@ type EncodedAsyncData<A, E> =
346
346
  * const codec = AsyncData(Schema.String, Schema.String)
347
347
  * ```
348
348
  * See [Effect Schema](https://effect.website/docs/schema/introduction/).
349
- * @category Schemas
349
+ * @category Serialization
350
350
  * @since 1.0.0
351
351
  */
352
352
  export const AsyncData = <const A extends Schema.Top, E extends Schema.Top>(
@@ -407,7 +407,7 @@ export const AsyncData = <const A extends Schema.Top, E extends Schema.Top>(
407
407
  * import { isNoData, NoData } from "@typed/async-data"
408
408
  * isNoData(NoData)
409
409
  * ```
410
- * @category Refinements
410
+ * @category State inspection
411
411
  * @since 1.0.0
412
412
  */
413
413
  export const isNoData = <A, E>(asyncData: AsyncData<A, E>): asyncData is NoData =>
@@ -424,7 +424,7 @@ export const isNoData = <A, E>(asyncData: AsyncData<A, E>): asyncData is NoData
424
424
  * import { isLoading, loading } from "@typed/async-data"
425
425
  * isLoading(loading())
426
426
  * ```
427
- * @category Refinements
427
+ * @category State inspection
428
428
  * @since 1.0.0
429
429
  */
430
430
  export const isLoading = <A, E>(asyncData: AsyncData<A, E>): asyncData is Loading =>
@@ -441,7 +441,7 @@ export const isLoading = <A, E>(asyncData: AsyncData<A, E>): asyncData is Loadin
441
441
  * import { isSuccess, success } from "@typed/async-data"
442
442
  * isSuccess(success(1))
443
443
  * ```
444
- * @category Refinements
444
+ * @category State inspection
445
445
  * @since 1.0.0
446
446
  */
447
447
  export const isSuccess = <A, E>(asyncData: AsyncData<A, E>): asyncData is Success<A> =>
@@ -459,7 +459,7 @@ export const isSuccess = <A, E>(asyncData: AsyncData<A, E>): asyncData is Succes
459
459
  * import { Cause } from "effect"
460
460
  * isFailure(failure(Cause.fail("offline")))
461
461
  * ```
462
- * @category Refinements
462
+ * @category State inspection
463
463
  * @since 1.0.0
464
464
  */
465
465
  export const isFailure = <A, E>(asyncData: AsyncData<A, E>): asyncData is Failure<E> =>
@@ -476,7 +476,7 @@ export const isFailure = <A, E>(asyncData: AsyncData<A, E>): asyncData is Failur
476
476
  * import { isOptimistic, optimistic, success } from "@typed/async-data"
477
477
  * isOptimistic(optimistic(success(1), 2))
478
478
  * ```
479
- * @category Refinements
479
+ * @category State inspection
480
480
  * @since 1.0.0
481
481
  */
482
482
  export const isOptimistic = <A, E>(asyncData: AsyncData<A, E>): asyncData is Optimistic<A, E> =>
@@ -510,7 +510,7 @@ const hasValidProgress = (u: object): boolean => {
510
510
  * import { isAsyncData } from "@typed/async-data"
511
511
  * isAsyncData({ _tag: "Loading", progress: { loaded: 1 } })
512
512
  * ```
513
- * @category Refinements
513
+ * @category Runtime validation
514
514
  * @since 1.0.0
515
515
  */
516
516
  export const isAsyncData = <A, E>(u: unknown): u is AsyncData<A, E> => {
@@ -558,7 +558,7 @@ export const isAsyncData = <A, E>(u: unknown): u is AsyncData<A, E> => {
558
558
  * import { isRefreshing, success } from "@typed/async-data"
559
559
  * isRefreshing(success("cached", { loaded: 0 }))
560
560
  * ```
561
- * @category Refinements
561
+ * @category State inspection
562
562
  * @since 1.0.0
563
563
  */
564
564
  export const isRefreshing = <A, E>(asyncData: AsyncData<A, E>): asyncData is Refreshing<A, E> =>
@@ -579,7 +579,7 @@ export const isRefreshing = <A, E>(asyncData: AsyncData<A, E>): asyncData is Ref
579
579
  * import { isPending, loading, optimistic } from "@typed/async-data"
580
580
  * isPending(optimistic(loading(), "draft"))
581
581
  * ```
582
- * @category Refinements
582
+ * @category State inspection
583
583
  * @since 1.0.0
584
584
  */
585
585
  export const isPending = <A, E>(
@@ -609,7 +609,7 @@ export const isPending = <A, E>(
609
609
  * import { NoData } from "@typed/async-data"
610
610
  * const initial = NoData
611
611
  * ```
612
- * @category Constructors
612
+ * @category State construction
613
613
  * @since 1.0.0
614
614
  */
615
615
  export const NoData: NoData = { _tag: "NoData" };
@@ -626,7 +626,7 @@ export const NoData: NoData = { _tag: "NoData" };
626
626
  * import { loading } from "@typed/async-data"
627
627
  * const state = loading({ loaded: 2, total: 5 })
628
628
  * ```
629
- * @category Constructors
629
+ * @category State construction
630
630
  * @since 1.0.0
631
631
  */
632
632
  export const loading = (progress?: Progress): Loading => ({ _tag: "Loading", progress });
@@ -643,7 +643,7 @@ export const loading = (progress?: Progress): Loading => ({ _tag: "Loading", pro
643
643
  * import { success } from "@typed/async-data"
644
644
  * const state = success("ready")
645
645
  * ```
646
- * @category Constructors
646
+ * @category State construction
647
647
  * @since 1.0.0
648
648
  */
649
649
  export const success = <A>(value: A, progress?: Progress): Success<A> => ({
@@ -665,7 +665,7 @@ export const success = <A>(value: A, progress?: Progress): Success<A> => ({
665
665
  * import { Cause } from "effect"
666
666
  * const state = failure(Cause.fail("offline"))
667
667
  * ```
668
- * @category Constructors
668
+ * @category State construction
669
669
  * @since 1.0.0
670
670
  */
671
671
  export const failure = <E>(cause: Cause.Cause<E>, progress?: Progress): Failure<E> => ({
@@ -686,7 +686,7 @@ export const failure = <E>(cause: Cause.Cause<E>, progress?: Progress): Failure<
686
686
  * import { optimistic, success } from "@typed/async-data"
687
687
  * const state = optimistic(success("saved"), "saving")
688
688
  * ```
689
- * @category Constructors
689
+ * @category Optimistic transitions
690
690
  * @since 1.0.0
691
691
  */
692
692
  export const optimistic = <A, E>(previous: AsyncData<A, E>, value: A): Optimistic<A, E> => ({
@@ -733,7 +733,7 @@ const refreshingProgress = (progress?: Progress, existing?: Progress): Progress
733
733
  * import { startLoading, success } from "@typed/async-data"
734
734
  * const refreshing = startLoading(success("cached"))
735
735
  * ```
736
- * @category Transformations
736
+ * @category Refresh transitions
737
737
  * @since 1.0.0
738
738
  */
739
739
  export const startLoading = <A, E>(data: AsyncData<A, E>, progress?: Progress): AsyncData<A, E> => {
@@ -763,7 +763,7 @@ export const startLoading = <A, E>(data: AsyncData<A, E>, progress?: Progress):
763
763
  * import { startLoading, stopLoading, success } from "@typed/async-data"
764
764
  * const settled = stopLoading(startLoading(success("cached")))
765
765
  * ```
766
- * @category Transformations
766
+ * @category Refresh transitions
767
767
  * @since 1.0.0
768
768
  */
769
769
  export const stopLoading = <A, E>(data: AsyncData<A, E>): AsyncData<A, E> => {
@@ -791,7 +791,7 @@ export const stopLoading = <A, E>(data: AsyncData<A, E>): AsyncData<A, E> => {
791
791
  * import { match } from "@typed/async-data"
792
792
  * const label = match({ NoData: () => "empty", Loading: () => "loading", Failure: () => "failed", Success: String, Optimistic: String })
793
793
  * ```
794
- * @category Folding
794
+ * @category Pattern matching
795
795
  * @since 1.0.0
796
796
  */
797
797
  export const match: {
@@ -852,7 +852,7 @@ export const match: {
852
852
  * const value = getSuccess(success(1))
853
853
  * ```
854
854
  * See [Effect Option](https://effect.website/docs/data-types/option/).
855
- * @category Accessors
855
+ * @category State extraction
856
856
  * @since 1.0.0
857
857
  */
858
858
  export function getSuccess<A, E>(data: AsyncData<A, E>): Option.Option<A> {
@@ -878,7 +878,7 @@ export function getSuccess<A, E>(data: AsyncData<A, E>): Option.Option<A> {
878
878
  * import { Cause } from "effect"
879
879
  * const cause = getCause(failure(Cause.fail("offline")))
880
880
  * ```
881
- * @category Accessors
881
+ * @category State extraction
882
882
  * @since 1.0.0
883
883
  */
884
884
  export function getCause<A, E>(data: AsyncData<A, E>): Option.Option<Cause.Cause<E>> {
@@ -904,7 +904,7 @@ export function getCause<A, E>(data: AsyncData<A, E>): Option.Option<Cause.Cause
904
904
  * import { Cause } from "effect"
905
905
  * const error = getError(failure(Cause.fail("offline")))
906
906
  * ```
907
- * @category Accessors
907
+ * @category State extraction
908
908
  * @since 1.0.0
909
909
  */
910
910
  export function getError<A, E>(data: AsyncData<A, E>): Option.Option<E> {
@@ -929,7 +929,7 @@ export function getError<A, E>(data: AsyncData<A, E>): Option.Option<E> {
929
929
  * import { map, success } from "@typed/async-data"
930
930
  * const state = map(success(2), (n) => n * 2)
931
931
  * ```
932
- * @category Transformations
932
+ * @category Value transformations
933
933
  * @since 1.0.0
934
934
  */
935
935
  export const map: {
@@ -961,7 +961,7 @@ export const map: {
961
961
  * import { flatMap, success } from "@typed/async-data"
962
962
  * const parsed = flatMap(success("2"), (text) => success(Number(text)))
963
963
  * ```
964
- * @category Transformations
964
+ * @category Value transformations
965
965
  * @since 1.0.0
966
966
  */
967
967
  export const flatMap: {
@@ -1001,7 +1001,7 @@ export const flatMap: {
1001
1001
  * import { Cause } from "effect"
1002
1002
  * const state = mapError(failure(Cause.fail(404)), String)
1003
1003
  * ```
1004
- * @category Transformations
1004
+ * @category Failure transformations
1005
1005
  * @since 1.0.0
1006
1006
  */
1007
1007
  export const mapError: {
@@ -1031,7 +1031,7 @@ export const mapError: {
1031
1031
  * import { Exit } from "effect"
1032
1032
  * const state = fromExit(Exit.succeed(1))
1033
1033
  * ```
1034
- * @category Conversions
1034
+ * @category Effect outcome conversion
1035
1035
  * @since 1.0.0
1036
1036
  */
1037
1037
  export const fromExit = <A, E>(exit: Exit.Exit<A, E>): AsyncData<A, E> =>
@@ -1050,7 +1050,7 @@ export const fromExit = <A, E>(exit: Exit.Exit<A, E>): AsyncData<A, E> =>
1050
1050
  * import { Result } from "effect"
1051
1051
  * const state = fromResult(Result.succeed(1))
1052
1052
  * ```
1053
- * @category Conversions
1053
+ * @category Effect outcome conversion
1054
1054
  * @since 1.0.0
1055
1055
  */
1056
1056
  export const fromResult = <A, E>(result: Result.Result<A, E>): AsyncData<A, E> =>