tryError Documentation
Function: tryAny()
Function
```ts function tryAny<T>(attempts): TryResult<T, TryError<string>>; ``` Defined in: [sync.ts:385](https://github.com/oconnorjohnson/try-error/blob/e3ae0308069a4fba073f4543d527ad76373db795/src/sync.ts#L385) Try multiple operations, returning the first successful result
tryError API Documentation v0.0.1-alpha.1
tryError API Documentation / tryAny
Function: tryAny()
function tryAny<T>(attempts): TryResult<T, TryError<string>>;
Defined in: sync.ts:385
Try multiple operations, returning the first successful result
Type Parameters
T
T
Parameters
attempts
() => TryResult
<T
, TryError
<string
>>[]
Array of functions to try
Returns
TryResult
<T
, TryError
<string
>>
First successful result or last error if all fail
Example
const result = tryAny([
() => trySync(() => JSON.parse(primaryJson)),
() => trySync(() => JSON.parse(fallbackJson)),
() => ({ fallback: true }),
]);