1
0
mirror of https://github.com/MisskeyIO/misskey synced 2025-01-07 10:23:43 +09:00
MisskeyIO/src/prelude/maybe.ts
2019-02-07 21:02:33 +09:00

21 lines
291 B
TypeScript

export interface Maybe<T> {
isJust(): this is Just<T>;
}
export type Just<T> = Maybe<T> & {
get(): T
};
export function just<T>(value: T): Just<T> {
return {
isJust: () => true,
get: () => value
};
}
export function nothing<T>(): Maybe<T> {
return {
isJust: () => false,
};
}