hardhat
Version:
Hardhat is an extensible developer tool that helps smart contract developers increase productivity by reliably bringing together the tools they want.
33 lines • 1.31 kB
TypeScript
import type { Result } from "../types/utils.js";
/**
* Creates a successful Result with the given value.
*
* @param value The value to include in the result.
* @returns A Result with success: true and the given value.
*/
export declare function successfulResult<ValueT = undefined>(...args: ValueT extends undefined | void ? [] : [value: ValueT]): {
success: true;
value: ValueT;
};
/**
* Creates a failed Result with the given error.
*
* @param error The error to include in the result.
* @returns A Result with success: false and the given error.
*/
export declare function errorResult<ErrorT = undefined>(...args: ErrorT extends undefined | void ? [] : [error: ErrorT]): {
success: false;
error: ErrorT;
};
/**
* A type guard that checks if a value is a Result.
*
* Optionally validates the value and error fields using type guard functions.
*
* @param value The value to check.
* @param isValue Optional type guard for the value field.
* @param isError Optional type guard for the error field.
* @returns true if the value is a Result.
*/
export declare function isResult<ValueT = unknown, ErrorT = unknown>(value: unknown, isValue?: (v: unknown) => v is ValueT, isError?: (e: unknown) => e is ErrorT): value is Result<ValueT, ErrorT>;
//# sourceMappingURL=result.d.ts.map