MCPcopy
hub / github.com/facebook/react / Result

Interface Result

compiler/packages/babel-plugin-react-compiler/src/Utils/Result.ts:9–86  ·  compiler/packages/babel-plugin-react-compiler/src/Utils/Result.ts::Result

Source from the content-addressed store, hash-verified

7
8class="cm">// Direct translation of Rust's Result type, although some ownership related methods are omitted.
9export interface Result<T, E> {
10 /*
11 * Maps a `Result<T, E>` to `Result<U, E>` by applying a function to a contained `Ok` value,
12 * leaving an `Err` value untouched.
13 *
14 * This function can be used to compose the results of two functions.
15 */
16 map<U>(fn: (val: T) => U): Result<U, E>;
17 /*
18 * Maps a `Result<T, E>` to `Result<T, F>` by applying a function to a contained `Err` value,
19 * leaving an `Ok` value untouched.
20 *
21 * This function can be used to pass through a successful result while handling an error.
22 */
23 mapErr<F>(fn: (val: E) => F): Result<T, F>;
24 /*
25 * Returns the provided default (if `Err`), or applies a function to the contained value
26 * (if `Ok`).
27 *
28 * Arguments passed to {@link mapOr} are eagerly evaluated; if you are passing the result of a
29 * function call, it is recommended to use {@link mapOrElse}, which is lazily evaluated.
30 */
31 mapOr<U>(fallback: U, fn: (val: T) => U): U;
32 /*
33 * Maps a `Result<T, E>` to `U` by applying fallback function default to a contained `Err` value,
34 * or function `fn` to a contained `Ok` value.
35 *
36 * This function can be used to unpack a successful result while handling an error.
37 */
38 mapOrElse<U>(fallback: () => U, fn: (val: T) => U): U;
39 /*
40 * Calls `fn` if the result is `Ok`, otherwise returns the `Err` value of self.
41 *
42 * This function can be used for control flow based on Result values.
43 */
44 andThen<U>(fn: (val: T) => Result<U, E>): Result<U, E>;
45 /*
46 * Returns res if the result is `Ok`, otherwise returns the `Err` value of self.
47 *
48 * Arguments passed to {@link and} are eagerly evaluated; if you are passing the result of a
49 * function call, it is recommended to use {@link andThen}, which is lazily evaluated.
50 */
51 and<U>(res: Result<U, E>): Result<U, E>;
52 /*
53 * Returns `res` if the result is `Err`, otherwise returns the `Ok` value of self.
54 *
55 * Arguments passed to {@link or} are eagerly evaluated; if you are passing the result of a
56 * function call, it is recommended to use {@link orElse}, which is lazily evaluated.
57 */
58 or(res: Result<T, E>): Result<T, E>;
59 /*
60 * Calls `fn` if the result is `Err`, otherwise returns the `Ok` value of self.
61 *
62 * This function can be used for control flow based on result values.
63 */
64 orElse<F>(fn: (val: E) => Result<T, F>): Result<T, F>;
65 class="cm">// Returns `true` if the result is `Ok`.
66 isOk(): this is OkImpl<T>;

Callers 51

ComponentFunction · 0.65
applyMethod · 0.65
resolveAllClientFilesMethod · 0.65
processDebugValuesFunction · 0.65
FooFunction · 0.65
Result-test.tsFile · 0.65
Result-test.tsFile · 0.65
Result-test.tsFile · 0.65
Result-test.tsFile · 0.65

Implementers 2

OkImplcompiler/packages/babel-plugin-react-c
ErrImplcompiler/packages/babel-plugin-react-c

Calls

no outgoing calls

Tested by

no test coverage detected