mirror of
https://github.com/eigent-ai/eigent.git
synced 2026-04-30 20:50:02 +00:00
Initial commit of eigent-main
This commit is contained in:
commit
723df5a03e
1144 changed files with 103478 additions and 0 deletions
78
package/@stackframe/stack-shared/dist/utils/results.d.mts
vendored
Normal file
78
package/@stackframe/stack-shared/dist/utils/results.d.mts
vendored
Normal file
|
|
@ -0,0 +1,78 @@
|
|||
type Result<T, E = unknown> = {
|
||||
status: "ok";
|
||||
data: T;
|
||||
} | {
|
||||
status: "error";
|
||||
error: E;
|
||||
};
|
||||
declare const Result: {
|
||||
fromThrowing: typeof fromThrowing;
|
||||
fromThrowingAsync: typeof fromThrowingAsync;
|
||||
fromPromise: typeof promiseToResult;
|
||||
ok<T>(data: T): {
|
||||
status: "ok";
|
||||
data: T;
|
||||
} & {
|
||||
status: "ok";
|
||||
};
|
||||
error<E>(error: E): {
|
||||
status: "error";
|
||||
error: E;
|
||||
} & {
|
||||
status: "error";
|
||||
};
|
||||
map: typeof mapResult;
|
||||
or: <T_1, E_1, U>(result: Result<T_1, E_1>, fallback: U) => T_1 | U;
|
||||
orThrow: <T_2, E_2>(result: Result<T_2, E_2>) => T_2;
|
||||
orThrowAsync: <T_3, E_3>(result: Promise<Result<T_3, E_3>>) => Promise<T_3>;
|
||||
retry: typeof retry;
|
||||
};
|
||||
type AsyncResult<T, E = unknown, P = void> = Result<T, E> | ({
|
||||
status: "pending";
|
||||
} & {
|
||||
progress: P;
|
||||
});
|
||||
declare const AsyncResult: {
|
||||
fromThrowing: typeof fromThrowing;
|
||||
fromPromise: typeof promiseToResult;
|
||||
ok: <T>(data: T) => {
|
||||
status: "ok";
|
||||
data: T;
|
||||
} & {
|
||||
status: "ok";
|
||||
};
|
||||
error: <E>(error: E) => {
|
||||
status: "error";
|
||||
error: E;
|
||||
} & {
|
||||
status: "error";
|
||||
};
|
||||
pending: typeof pending;
|
||||
map: typeof mapResult;
|
||||
or: <T_1, E_1, P, U>(result: AsyncResult<T_1, E_1, P>, fallback: U) => T_1 | U;
|
||||
orThrow: <T_2, E_2, P_1>(result: AsyncResult<T_2, E_2, P_1>) => T_2;
|
||||
retry: typeof retry;
|
||||
};
|
||||
declare function pending(): AsyncResult<never, never, void> & {
|
||||
status: "pending";
|
||||
};
|
||||
declare function pending<P>(progress: P): AsyncResult<never, never, P> & {
|
||||
status: "pending";
|
||||
};
|
||||
declare function promiseToResult<T>(promise: Promise<T>): Promise<Result<T>>;
|
||||
declare function fromThrowing<T>(fn: () => T): Result<T, unknown>;
|
||||
declare function fromThrowingAsync<T>(fn: () => Promise<T>): Promise<Result<T, unknown>>;
|
||||
declare function mapResult<T, U, E = unknown, P = unknown>(result: Result<T, E>, fn: (data: T) => U): Result<U, E>;
|
||||
declare function mapResult<T, U, E = unknown, P = unknown>(result: AsyncResult<T, E, P>, fn: (data: T) => U): AsyncResult<U, E, P>;
|
||||
declare class RetryError extends AggregateError {
|
||||
readonly errors: unknown[];
|
||||
constructor(errors: unknown[]);
|
||||
get attempts(): number;
|
||||
}
|
||||
declare function retry<T>(fn: (attemptIndex: number) => Result<T> | Promise<Result<T>>, totalAttempts: number, { exponentialDelayBase }?: {
|
||||
exponentialDelayBase?: number | undefined;
|
||||
}): Promise<Result<T, RetryError> & {
|
||||
attempts: number;
|
||||
}>;
|
||||
|
||||
export { AsyncResult, Result };
|
||||
Loading…
Add table
Add a link
Reference in a new issue