File size: 22,491 Bytes
31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 e391660 31e8457 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 | /**
* Represents observable state for asynchronous values.
*
* `AsyncResult<A, E>` records whether asynchronous work has no value yet,
* succeeded with an `A`, or failed with an `E`. Every state also carries a
* `waiting` flag, so callers can keep showing the current value while newer
* work is loading, refreshing, retrying, or recovering. This module includes
* constructors, checks, accessors, mapping and matching helpers, ways to combine
* several results, and schemas for encoding or decoding results.
*
* @since 4.0.0
*/
import * as Cause from "../../Cause.ts";
import * as Exit from "../../Exit.ts";
import type { LazyArg } from "../../Function.ts";
import * as Option from "../../Option.ts";
import { type Pipeable } from "../../Pipeable.ts";
import type { Predicate, Refinement } from "../../Predicate.ts";
import * as Schema_ from "../../Schema.ts";
import type * as Types from "../../Types.ts";
/**
* Type-level identifier used to recognize `AsyncResult` values.
*
* @category type IDs
* @since 4.0.0
*/
export type TypeId = "~effect/reactivity/AsyncResult";
/**
* Runtime identifier attached to `AsyncResult` values and used by `isAsyncResult`.
*
* @category type IDs
* @since 4.0.0
*/
export declare const TypeId: TypeId;
/**
* Represents the state of an asynchronous value as `Initial`, `Success`, or `Failure`, with a `waiting` flag for in-flight refreshes.
*
* @category models
* @since 4.0.0
*/
export type AsyncResult<A, E = never> = Initial<A, E> | Success<A, E> | Failure<A, E>;
/**
* Returns `true` when a value is an `AsyncResult`.
*
* @category guards
* @since 4.0.0
*/
export declare const isAsyncResult: (u: unknown) => u is AsyncResult<unknown, unknown>;
/**
* Namespace containing type-level helpers and the shared prototype shape for `AsyncResult` values.
*
* @since 4.0.0
*/
export declare namespace AsyncResult {
/**
* Common prototype fields implemented by every `AsyncResult` variant, including pipeability, the type marker, phantom type members, and the `waiting` flag.
*
* @category models
* @since 4.0.0
*/
interface Proto<A, E> extends Pipeable {
readonly [TypeId]: {
readonly E: (_: never) => E;
readonly A: (_: never) => A;
};
readonly waiting: boolean;
}
/**
* Extracts the success value type from an `AsyncResult`.
*
* @category utility types
* @since 4.0.0
*/
type Success<R> = R extends AsyncResult<infer A, infer _> ? A : never;
/**
* Extracts the failure error type from an `AsyncResult`.
*
* @category utility types
* @since 4.0.0
*/
type Failure<R> = R extends AsyncResult<infer _, infer E> ? E : never;
}
/**
* Rebuilds an `AsyncResult` with new success and failure types while preserving the variant of another result.
*
* @category utility types
* @since 4.0.0
*/
export type With<R extends AsyncResult<any, any>, A, E> = R extends Initial<infer _A, infer _E> ? Initial<A, E> : R extends Success<infer _A, infer _E> ? Success<A, E> : R extends Failure<infer _A, infer _E> ? Failure<A, E> : never;
/**
* Returns whether an `AsyncResult` is currently waiting for an asynchronous computation or refresh to finish.
*
* @category refinements
* @since 4.0.0
*/
export declare const isWaiting: <A, E>(result: AsyncResult<A, E>) => boolean;
/**
* Initial `AsyncResult` state before a success value or failure cause is available.
*
* @category models
* @since 4.0.0
*/
export interface Initial<A, E = never> extends AsyncResult.Proto<A, E> {
readonly _tag: "Initial";
}
/**
* Converts an `Exit` into a `Success` when it succeeds or a `Failure` carrying the exit cause when it fails.
*
* @category constructors
* @since 4.0.0
*/
export declare const fromExit: <A, E>(exit: Exit.Exit<A, E>) => Success<A, E> | Failure<A, E>;
/**
* Converts an `Exit` to a result, preserving the latest previous success when the exit is a failure.
*
* @category constructors
* @since 4.0.0
*/
export declare const fromExitWithPrevious: <A, E>(exit: Exit.Exit<A, E>, previous: Option.Option<AsyncResult<A, E>>) => Success<A, E> | Failure<A, E>;
/**
* Creates a waiting result from an optional previous result, using `Initial(true)` when no previous result exists.
*
* @category constructors
* @since 4.0.0
*/
export declare const waitingFrom: <A, E>(previous: Option.Option<AsyncResult<A, E>>) => AsyncResult<A, E>;
/**
* Returns `true` when an `AsyncResult` is in the `Initial` state.
*
* @category refinements
* @since 4.0.0
*/
export declare const isInitial: <A, E>(result: AsyncResult<A, E>) => result is Initial<A, E>;
/**
* Returns `true` when an `AsyncResult` is either `Success` or `Failure`.
*
* @category refinements
* @since 4.0.0
*/
export declare const isNotInitial: <A, E>(result: AsyncResult<A, E>) => result is Success<A, E> | Failure<A, E>;
/**
* Creates an `Initial` result, optionally marking it as waiting.
*
* @category constructors
* @since 4.0.0
*/
export declare const initial: <A = never, E = never>(waiting?: boolean) => Initial<A, E>;
/**
* Successful `AsyncResult` containing the current value, its timestamp, and the shared waiting flag.
*
* @category models
* @since 4.0.0
*/
export interface Success<A, E = never> extends AsyncResult.Proto<A, E> {
readonly _tag: "Success";
readonly value: A;
readonly timestamp: number;
}
/**
* Returns `true` when an `AsyncResult` is a `Success`.
*
* @category refinements
* @since 4.0.0
*/
export declare const isSuccess: <A, E>(result: AsyncResult<A, E>) => result is Success<A, E>;
/**
* Creates a `Success` result with a value and optional `waiting` flag or timestamp override.
*
* @category constructors
* @since 4.0.0
*/
export declare const success: <A, E = never>(value: A, options?: {
readonly waiting?: boolean | undefined;
readonly timestamp?: number | undefined;
}) => Success<A, E>;
/**
* Failed `AsyncResult` containing a failure cause and the latest previous success when one is available.
*
* @category models
* @since 4.0.0
*/
export interface Failure<A, E = never> extends AsyncResult.Proto<A, E> {
readonly _tag: "Failure";
readonly cause: Cause.Cause<E>;
readonly previousSuccess: Option.Option<Success<A, E>>;
}
/**
* Returns `true` when an `AsyncResult` is a `Failure`.
*
* @category refinements
* @since 4.0.0
*/
export declare const isFailure: <A, E>(result: AsyncResult<A, E>) => result is Failure<A, E>;
/**
* Returns `true` when an `AsyncResult` is a `Failure` whose cause contains only interruptions.
*
* @category refinements
* @since 4.0.0
*/
export declare const isInterrupted: <A, E>(result: AsyncResult<A, E>) => result is Failure<A, E>;
/**
* Creates a `Failure` result from a `Cause`, optionally preserving a previous success and marking the result as waiting.
*
* @category constructors
* @since 4.0.0
*/
export declare const failure: <A, E = never>(cause: Cause.Cause<E>, options?: {
readonly previousSuccess?: Option.Option<Success<A, E>> | undefined;
readonly waiting?: boolean | undefined;
}) => Failure<A, E>;
/**
* Creates a `Failure` result from a `Cause`, carrying forward the latest success stored in a previous result.
*
* @category constructors
* @since 4.0.0
*/
export declare const failureWithPrevious: <A, E>(cause: Cause.Cause<E>, options: {
readonly previous: Option.Option<AsyncResult<A, E>>;
readonly waiting?: boolean | undefined;
}) => Failure<A, E>;
/**
* Creates a `Failure` result from a typed error, wrapping it in `Cause.fail`.
*
* @category constructors
* @since 4.0.0
*/
export declare const fail: <E, A = never>(error: E, options?: {
readonly previousSuccess?: Option.Option<Success<A, E>> | undefined;
readonly waiting?: boolean | undefined;
}) => Failure<A, E>;
/**
* Creates a `Failure` result from a typed error while carrying forward the latest success stored in a previous result.
*
* @category constructors
* @since 4.0.0
*/
export declare const failWithPrevious: <A, E>(error: E, options: {
readonly previous: Option.Option<AsyncResult<A, E>>;
readonly waiting?: boolean | undefined;
}) => Failure<A, E>;
/**
* Marks an `AsyncResult` as waiting, optionally touching the timestamp when the result is a `Success`.
*
* @category constructors
* @since 4.0.0
*/
export declare const waiting: <R extends AsyncResult<any, any>>(self: R, options?: {
readonly touch?: boolean | undefined;
}) => R;
/**
* Refreshes the timestamp of a `Success` result while preserving its value and waiting flag; non-success results are returned unchanged.
*
* @category combinators
* @since 4.0.0
*/
export declare const touch: <A extends AsyncResult<any, any>>(result: A) => A;
/**
* Replaces a `Failure` value's stored previous success with the latest success
* found in another result.
*
* @category combinators
* @since 4.0.0
*/
export declare const replacePrevious: <R extends AsyncResult<any, any>, XE, A>(self: R, previous: Option.Option<AsyncResult<A, XE>>) => With<R, A, AsyncResult.Failure<R>>;
/**
* Returns the current success value, or the previous success value stored in a failure, as an `Option`.
*
* @category accessors
* @since 4.0.0
*/
export declare const value: <A, E>(self: AsyncResult<A, E>) => Option.Option<A>;
/**
* Returns the available value from `value`, or evaluates the fallback when no current or previous success exists.
*
* @category accessors
* @since 4.0.0
*/
export declare const getOrElse: {
/**
* Returns the available value from `value`, or evaluates the fallback when no current or previous success exists.
*
* @category accessors
* @since 4.0.0
*/
<B>(orElse: LazyArg<B>): <A, E>(self: AsyncResult<A, E>) => A | B;
/**
* Returns the available value from `value`, or evaluates the fallback when no current or previous success exists.
*
* @category accessors
* @since 4.0.0
*/
<A, E, B>(self: AsyncResult<A, E>, orElse: LazyArg<B>): A | B;
};
/**
* Returns the available value from `value`, or throws `NoSuchElementError` when no current or previous success exists.
*
* @category accessors
* @since 4.0.0
*/
export declare const getOrThrow: <A, E>(self: AsyncResult<A, E>) => A;
/**
* Returns the failure cause when the result is a `Failure`, otherwise `None`.
*
* @category accessors
* @since 4.0.0
*/
export declare const cause: <A, E>(self: AsyncResult<A, E>) => Option.Option<Cause.Cause<E>>;
/**
* Returns the first typed error from a failure cause, or `None` for successes, initial results, defects, and interrupt-only causes.
*
* @category accessors
* @since 4.0.0
*/
export declare const error: <A, E>(self: AsyncResult<A, E>) => Option.Option<E>;
/**
* Converts a result to an `Exit`, succeeding with a success value, failing with a failure cause, or failing with `NoSuchElementError` for `Initial`.
*
* @category combinators
* @since 4.0.0
*/
export declare const toExit: <A, E>(self: AsyncResult<A, E>) => Exit.Exit<A, E | Cause.NoSuchElementError>;
/**
* Maps the success value of an `AsyncResult`, also mapping any previous success stored in a failure while leaving initial results unchanged.
*
* @category combinators
* @since 4.0.0
*/
export declare const map: {
/**
* Maps the success value of an `AsyncResult`, also mapping any previous success stored in a failure while leaving initial results unchanged.
*
* @category combinators
* @since 4.0.0
*/
<A, B>(f: (a: A) => B): <E>(self: AsyncResult<A, E>) => AsyncResult<B, E>;
/**
* Maps the success value of an `AsyncResult`, also mapping any previous success stored in a failure while leaving initial results unchanged.
*
* @category combinators
* @since 4.0.0
*/
<E, A, B>(self: AsyncResult<A, E>, f: (a: A) => B): AsyncResult<B, E>;
};
/**
* Maps the success value of an `AsyncResult` and flattens the result.
*
* **When to use**
*
* Use to sequence computations that may return another `AsyncResult` while
* preserving initial and failure states.
*
* **Details**
*
* Initial results are left unchanged. Failures preserve their cause and remap
* the stored previous success when the mapping function returns a success.
*
* @category combinators
* @since 4.0.0
*/
export declare const flatMap: {
/**
* Maps the success value of an `AsyncResult` and flattens the result.
*
* **When to use**
*
* Use to sequence computations that may return another `AsyncResult` while
* preserving initial and failure states.
*
* **Details**
*
* Initial results are left unchanged. Failures preserve their cause and remap
* the stored previous success when the mapping function returns a success.
*
* @category combinators
* @since 4.0.0
*/
<A, E, B, E2>(f: (a: A, prev: Success<A, E>) => AsyncResult<A, E2>): (self: AsyncResult<A, E>) => AsyncResult<B, E | E2>;
/**
* Maps the success value of an `AsyncResult` and flattens the result.
*
* **When to use**
*
* Use to sequence computations that may return another `AsyncResult` while
* preserving initial and failure states.
*
* **Details**
*
* Initial results are left unchanged. Failures preserve their cause and remap
* the stored previous success when the mapping function returns a success.
*
* @category combinators
* @since 4.0.0
*/
<E, A, B, E2>(self: AsyncResult<A, E>, f: (a: A, prev: Success<A, E>) => AsyncResult<B, E2>): AsyncResult<B, E | E2>;
};
/**
* Pattern matches an `AsyncResult` by calling the handler for `Initial`, `Failure`, or `Success`.
*
* @category combinators
* @since 4.0.0
*/
export declare const match: {
/**
* Pattern matches an `AsyncResult` by calling the handler for `Initial`, `Failure`, or `Success`.
*
* @category combinators
* @since 4.0.0
*/
<A, E, X, Y, Z>(options: {
readonly onInitial: (_: Initial<A, E>) => X;
readonly onFailure: (_: Failure<A, E>) => Y;
readonly onSuccess: (_: Success<A, E>) => Z;
}): (self: AsyncResult<A, E>) => X | Y | Z;
/**
* Pattern matches an `AsyncResult` by calling the handler for `Initial`, `Failure`, or `Success`.
*
* @category combinators
* @since 4.0.0
*/
<A, E, X, Y, Z>(self: AsyncResult<A, E>, options: {
readonly onInitial: (_: Initial<A, E>) => X;
readonly onFailure: (_: Failure<A, E>) => Y;
readonly onSuccess: (_: Success<A, E>) => Z;
}): X | Y | Z;
};
/**
* Pattern matches a result, handling successes and initials directly while splitting failures into typed errors or squashed non-error causes passed to `onDefect`.
*
* @category combinators
* @since 4.0.0
*/
export declare const matchWithError: {
/**
* Pattern matches a result, handling successes and initials directly while splitting failures into typed errors or squashed non-error causes passed to `onDefect`.
*
* @category combinators
* @since 4.0.0
*/
<A, E, W, X, Y, Z>(options: {
readonly onInitial: (_: Initial<A, E>) => W;
readonly onError: (error: E, _: Failure<A, E>) => X;
readonly onDefect: (defect: unknown, _: Failure<A, E>) => Y;
readonly onSuccess: (_: Success<A, E>) => Z;
}): (self: AsyncResult<A, E>) => W | X | Y | Z;
/**
* Pattern matches a result, handling successes and initials directly while splitting failures into typed errors or squashed non-error causes passed to `onDefect`.
*
* @category combinators
* @since 4.0.0
*/
<A, E, W, X, Y, Z>(self: AsyncResult<A, E>, options: {
readonly onInitial: (_: Initial<A, E>) => W;
readonly onError: (error: E, _: Failure<A, E>) => X;
readonly onDefect: (defect: unknown, _: Failure<A, E>) => Y;
readonly onSuccess: (_: Success<A, E>) => Z;
}): W | X | Y | Z;
};
/**
* Pattern matches a result by calling `onWaiting` for waiting or initial states, otherwise handling successes and splitting failures into typed errors or squashed non-error causes.
*
* @category combinators
* @since 4.0.0
*/
export declare const matchWithWaiting: {
/**
* Pattern matches a result by calling `onWaiting` for waiting or initial states, otherwise handling successes and splitting failures into typed errors or squashed non-error causes.
*
* @category combinators
* @since 4.0.0
*/
<A, E, W, X, Y, Z>(options: {
readonly onWaiting: (_: AsyncResult<A, E>) => W;
readonly onError: (error: E, _: Failure<A, E>) => X;
readonly onDefect: (defect: unknown, _: Failure<A, E>) => Y;
readonly onSuccess: (_: Success<A, E>) => Z;
}): (self: AsyncResult<A, E>) => W | X | Y | Z;
/**
* Pattern matches a result by calling `onWaiting` for waiting or initial states, otherwise handling successes and splitting failures into typed errors or squashed non-error causes.
*
* @category combinators
* @since 4.0.0
*/
<A, E, W, X, Y, Z>(self: AsyncResult<A, E>, options: {
readonly onWaiting: (_: AsyncResult<A, E>) => W;
readonly onError: (error: E, _: Failure<A, E>) => X;
readonly onDefect: (defect: unknown, _: Failure<A, E>) => Y;
readonly onSuccess: (_: Success<A, E>) => Z;
}): W | X | Y | Z;
};
/**
* Combines an iterable or record of `AsyncResult` and plain values into one `AsyncResult`, returning the first non-success result or a success of the collected values marked waiting when any input success is waiting.
*
* @category combinators
* @since 4.0.0
*/
export declare const all: <const Arg extends Iterable<any> | Record<string, any>>(results: Arg) => AsyncResult<[Arg] extends [ReadonlyArray<any>] ? { -readonly [K in keyof Arg]: [Arg[K]] extends [AsyncResult<infer _A, infer _E>] ? _A : Arg[K]; } : [Arg] extends [Iterable<infer _A>] ? _A extends AsyncResult<infer _AA, infer _E_1> ? _AA : _A : [Arg] extends [Record<string, any>] ? { -readonly [K in keyof Arg]: [Arg[K]] extends [AsyncResult<infer _A, infer _E_2>] ? _A : Arg[K]; } : never, [Arg] extends [ReadonlyArray<any>] ? AsyncResult.Failure<Arg[number]> : [Arg] extends [Iterable<infer _A>] ? AsyncResult.Failure<_A> : [Arg] extends [Record<string, any>] ? AsyncResult.Failure<Arg[keyof Arg]> : never>;
/**
* Creates a typed builder for rendering an `AsyncResult` by handling waiting, initial, success, error, defect, interrupt, and failure cases.
*
* @category constructors
* @since 4.0.0
*/
export declare const builder: <A extends AsyncResult<any, any>>(self: A) => Builder<never, A extends Success<infer _A, infer _E> ? _A : never, A extends Failure<infer _A, infer _E_1> ? _E_1 : never, A extends Initial<infer _A, infer _E_2> ? true : never, A extends Failure<infer _A, infer _E_3> ? Defect | Interrupt : never>;
/**
* Type marker used by `Builder` to track whether defect failures still need to be handled.
*
* @category models
* @since 4.0.0
*/
export interface Defect {
readonly _: unique symbol;
}
/**
* Type marker used by `Builder` to track whether interrupt failures still need to be handled.
*
* @category models
* @since 4.0.0
*/
export interface Interrupt {
readonly _: unique symbol;
}
/**
* Fluent renderer for `AsyncResult` values that tracks unhandled cases at the type level and exposes `exhaustive` only after all possible cases are handled.
*
* @category models
* @since 4.0.0
*/
export type Builder<Out, A, E, I, F> = Pipeable & {
onWaiting<B>(f: (result: AsyncResult<A, E>) => B): Builder<Out | B, A, E, I, F>;
orElse<B>(orElse: LazyArg<B>): Out | B;
orNull(): Out | null;
render(): [A | I] extends [never] ? Out : Out | null;
} & ([A | E | I | F] extends [never] ? {
exhaustive(): Out;
} : unknown) & ([I] extends [never] ? unknown : {
onInitial<B>(f: (result: Initial<A, E>) => B): Builder<Out | B, A, E, never, F>;
onInitialOrWaiting<B>(f: (result: AsyncResult<A, E>) => B): Builder<Out | B, A, E, never, F>;
}) & ([A] extends [never] ? unknown : {
onSuccess<B>(f: (value: A, result: Success<A, E>) => B): Builder<Out | B, never, E, I, F>;
}) & ([E] extends [never] ? unknown : {
onError<B>(f: (error: E, result: Failure<A, E>) => B): Builder<Out | B, A, never, I, F>;
onErrorIf<B extends E, C>(refinement: Refinement<E, B>, f: (error: B, result: Failure<A, E>) => C): Builder<Out | C, A, Types.EqualsWith<E, B, E, Exclude<E, B>>, I, F>;
onErrorIf<C>(predicate: Predicate<E>, f: (error: E, result: Failure<A, E>) => C): Builder<Out | C, A, E, I, F>;
onErrorTag<const Tags extends ReadonlyArray<Types.Tags<E>>, B>(tags: Tags, f: (error: Types.ExtractTag<E, Tags[number]>, result: Failure<A, E>) => B): Builder<Out | B, A, Types.ExcludeTag<E, Tags[number]>, I, F>;
onErrorTag<const Tag extends Types.Tags<E>, B>(tag: Tag, f: (error: Types.ExtractTag<E, Tag>, result: Failure<A, E>) => B): Builder<Out | B, A, Types.ExcludeTag<E, Tag>, I, F>;
}) & ([E | F] extends [never] ? unknown : {
onFailure<B>(f: (cause: Cause.Cause<E>, result: Failure<A, E>) => B): Builder<Out | B, A, never, I, never>;
}) & (Interrupt extends F ? {
onInterrupt<B>(f: (interruptors: ReadonlySet<number>, result: Failure<A, E>) => B): Builder<Out | B, A, E, I, Exclude<F, Interrupt>>;
} : unknown) & (Defect extends F ? {
onDefect<B>(f: (defect: unknown, result: Failure<A, E>) => B): Builder<Out | B, A, E, I, Exclude<F, Defect>>;
} : unknown);
/**
* Schema interface for `AsyncResult` values, retaining the schemas used for success values and failure errors.
*
* @category schemas
* @since 4.0.0
*/
export interface Schema<Success extends Schema_.Top, Error extends Schema_.Top> extends Schema_.declareConstructor<AsyncResult<Success["Type"], Error["Type"]>, AsyncResult<Success["Encoded"], Error["Encoded"]>, readonly [Success, Schema_.Cause<Error, Schema_.Defect>]> {
readonly success: Success;
readonly error: Error;
}
/**
* Creates a schema for `AsyncResult` values using optional schemas for success values and failure errors.
*
* @category schemas
* @since 4.0.0
*/
export declare const Schema: <A extends Schema_.Top = Schema_.Never, E extends Schema_.Top = Schema_.Never>(options: {
readonly success?: A | undefined;
readonly error?: E | undefined;
}) => Schema<A, E>;
//# sourceMappingURL=AsyncResult.d.ts.map |