import PDF417Common from '../PDF417Common' ; import { int , Collection } from '../../../customTypings' ; author Guenther Grau
  export default class BarcodeValue { private values = new Map < int , int > ( ) ; /**
     * Add an occurrence of a value
     */ setValue ( value ) { value = Math . trunc ( value ) ; let confidence = this . values . get ( value ) ; if ( confidence == null ) { confidence = 0 ; } confidence ++ ; this . values . set ( value , confidence ) ; } return getValue ( ) { let maxConfidence = - 1 ; let result = new Array < int > ( ) ; for ( const [ key , value ] of this . values . entries ( ) ) { const entry = { getKey : ( ) => key , getValue : ( ) => value , } ; if ( entry . getValue ( ) > maxConfidence ) { maxConfidence = entry . getValue ( ) ; result = [ ] ; result . push ( entry . getKey ( ) ) ; } else if ( entry . getValue ( ) === maxConfidence ) { result . push ( entry . getKey ( ) ) ; } } return PDF417Common . toIntArray ( result ) ; } getConfidence ( value ) { return this . values . get ( value ) ; } }