mirror of
https://github.com/formbricks/formbricks.git
synced 2026-01-05 13:20:03 -06:00
* add @formbricks/api (api abstraction layer) and @formbricks/errors package to monorepo * use @formbricks/api in @formbricks/js to expose an api endpoint --------- Co-authored-by: Matthias Nannt <mail@matthiasnannt.com>
11 lines
332 B
TypeScript
11 lines
332 B
TypeScript
export type Result<T, E = Error> = { ok: true; data: T } | { ok: false; error: E };
|
|
|
|
export const ok = <T, E>(data: T): Result<T, E> => ({ ok: true, data });
|
|
|
|
export const okVoid = <E>(): Result<void, E> => ({ ok: true, data: undefined });
|
|
|
|
export const err = <E = Error>(error: E): Result<never, E> => ({
|
|
ok: false,
|
|
error,
|
|
});
|