mirror of
https://github.com/n8n-io/n8n.git
synced 2024-12-31 23:47:28 -08:00
14 lines
359 B
TypeScript
14 lines
359 B
TypeScript
|
export type ResultOk<T> = { ok: true; result: T };
|
||
|
export type ResultError<E> = { ok: false; error: E };
|
||
|
export type Result<T, E> = ResultOk<T> | ResultError<E>;
|
||
|
|
||
|
export const createResultOk = <T>(data: T): ResultOk<T> => ({
|
||
|
ok: true,
|
||
|
result: data,
|
||
|
});
|
||
|
|
||
|
export const createResultError = <E = unknown>(error: E): ResultError<E> => ({
|
||
|
ok: false,
|
||
|
error,
|
||
|
});
|