import { nail } from './string' // allows implementing partial functions & leaving a message for another developer export function todo(value?: V, message = 'TODO'): V { if (value === undefined) throw impl(message) return value } export function stub(message = 'Implement stub'): V { throw impl(message) } export const hole = stub /** * Used for marking incomplete data (which must be expanded instead of replaced, so can't be marked with todo()) */ export const incomplete = (value: V) => value // eslint-disable-next-line @typescript-eslint/ban-types export const impl = (message = '') => new ImplementationError(nail(message).trim()) export const Impl = () => { throw impl() } // eslint-disable-next-line @typescript-eslint/no-explicit-any export const manual = (map: Record, key: Key, message?: string): Value => { const value = map[key] if (!value) throw impl(message) return value } export class ImplementationError extends Error { } export type Todo = unknown export interface Stub {} export type Likely = T export const manually = impl