import { Consumer } from '@jamashita/anden-type'; import { DeadConstructor } from '@jamashita/genitore-schrodinger'; import { Chrono } from '../Chrono'; export class MockChrono implements Chrono { private readonly map: Consumer>; private readonly recover: Consumer; private readonly destroy: Consumer; private readonly errors: Set>; public constructor(map: Consumer>, recover: Consumer, destroy: Consumer, errors: Set>) { this.map = map; this.recover = recover; this.destroy = destroy; this.errors = errors; } public accept(value: Exclude): unknown { return this.map(value); } public catch(errors: Iterable>): void { [...errors].forEach((error: DeadConstructor) => { this.errors.add(error); }); } public decline(value: R): unknown { return this.recover(value); } public getErrors(): Set> { return this.errors; } public throw(cause: unknown): unknown { return this.destroy(cause); } }