metis-desk/packages/rdx-utils/src/index.ts
David e3f92fa534 feat: initialize pnpm workspace and add configuration files
- Added pnpm-workspace.yaml to define package structure.
- Created prepare-local-env.py script for local environment setup.
- Introduced tsconfig.json for TypeScript configuration.
- Added turbo.json for task management with Turbo.
2026-10-03 12:36:03 +02:00

26 lines
672 B
TypeScript

export type Result<T, E extends Error = Error> =
| Readonly<{ isSuccess: true; data: T }>
| Readonly<{ isSuccess: false; error: E }>;
export const Result = {
ok<T>(data: T): Result<T, never> {
return Object.freeze({ isSuccess: true, data });
},
fail<E extends Error>(error: E): Result<never, E> {
return Object.freeze({ isSuccess: false, error });
},
};
export class Maybe<T> {
private constructor(private readonly value: T | undefined) {}
static some<T>(value: T): Maybe<T> {
return new Maybe(value);
}
static none<T>(): Maybe<T> {
return new Maybe<T>(undefined);
}
getOrUndefined(): T | undefined {
return this.value;
}
}