UNPKG

1.01 kBTypeScriptView Raw
1/**
2 * Result of running an action, optionally on a target.
3 * Instances may add further information beyond boolean success or failure.
4 * Useful when promise chaining, to allow results to be included along with the target.
5 */
6export interface ActionResult<T = undefined> {
7 /**
8 * Target on which we ran the action, if there is one.
9 */
10 readonly target: T;
11 /**
12 * Whether or not the action succeeded.
13 */
14 readonly success: boolean;
15 readonly error?: Error;
16 readonly errorStep?: string;
17}
18export declare function isActionResult(a: any): a is ActionResult;
19/**
20 * Convenient implementation of ActionResult
21 */
22export declare class SimpleActionResult<T> implements ActionResult<T> {
23 readonly target: T;
24 readonly success: boolean;
25 constructor(target: T, success: boolean);
26}
27export declare function successOn<T>(t: T): ActionResult<T>;
28export declare function failureOn<T>(t: T, err: Error, f?: any): ActionResult<T>;
29//# sourceMappingURL=ActionResult.d.ts.map
\No newline at end of file