import { Decider , Decision , ImplicationProofItem } from '../../types' ; export class CannotDecideError extends Error { constructor ( message ? ) { super ( message ) ; Object . setPrototypeOf ( this , new . target . prototype ) ; } } export const handleCannotDecideError = ( e ) : undefined => { if ( ! ( e instanceof CannotDecideError ) ) { throw e ; } return undefined ; } ; const getJustification = ( decider , input , witness ) : ImplicationProofItem [ ] => { return [ { implication : { decider , input , } , implicationWitness : witness , } , ] ; } ; export class TrueDecider implements Decider { public async decide ( input ) { return { outcome : true , justification : getJustification ( this , input , true ) , } ; } } export class FalseDecider implements Decider { public async decide ( input ) { return { outcome : false , justification : getJustification ( this , input , true ) , } ; } } export class CannotDecideDecider implements Decider { public async decide ( input ) { throw new CannotDecideError ( 'Cannot decide!' ) ; } }