import { areEqual } from '@pigi/core-utils' ; import { Decider , Decision , ImplicationProofItem } from '../../types' ; export interface EqualityDeciderInput { itemsToCompare : any [ ] ; } /**
 * Decider that decides true if all of the provided values are equal.
 */ export class EqualityDecider implements Decider { private static _instance : EqualityDecider ; public static instance ( ) { if ( ! EqualityDecider . _instance ) { EqualityDecider . _instance = new EqualityDecider ( ) ; } return EqualityDecider . _instance ; } public async decide ( input , noCache ? ) { if ( input . itemsToCompare && input . itemsToCompare . length ) { const compareTo = input . itemsToCompare [ 0 ] ; for ( const item of input . itemsToCompare ) { if ( ! areEqual ( compareTo , item ) ) { return this . getDecision ( input , [ compareTo , item ] ) ; } } } return this . getDecision ( input ) ; } param input param mismatchedItems returns private getDecision ( input , mismatchedItems ? ) { const justification = [ { implication : { decider : this , input , } , implicationWitness : mismatchedItems , } , ] ; return { outcome : ! mismatchedItems , justification , } ; } }