Namespace flow-control
Package: @litert/utils-flow-control
Flow-control utility functions for JavaScript/TypeScript. Provides an expression-style try-catch-finally helper and a conditional value selector, both supporting synchronous and asynchronous functions.
Install
Use this package only:
bash
npm i @litert/utils-flow-controlOr install the full bundle:
bash
npm i @litert/utilsAnd then import from it.
ts
import * as LibUtils from '@litert/utils';
LibUtils.tryCatch(...);
// or
import { tryCatch } from '@litert/utils';
tryCatch(...);Functions
| Function | Description |
|---|---|
tryCatch | Expression-style try-catch[-finally] that supports both sync and async code. |
useValueOr | Returns a value if it passes a check, or falls back to a default value. |
Typings
See Typings.md for all exported interfaces and type aliases.
| Type | Description |
|---|---|
ITryCatchOptions | Options object for tryCatch. |
ITryCatchResult | Computed return type of tryCatch based on its options. |