import BarcodeFormat from '../BarcodeFormat' ; import BitArray from '../common/BitArray' ; import DecodeHintType from '../DecodeHintType' ; import NotFoundException from '../NotFoundException' ; import Result from '../Result' ; import Code128Reader from './Code128Reader' ; import Code39Reader from './Code39Reader' ; import ITFReader from './ITFReader' ; import MultiFormatUPCEANReader from './MultiFormatUPCEANReader' ; import OneDReader from './OneDReader' ; import RSSExpandedReader from './rss/expanded/RSSExpandedReader' ; import RSS14Reader from './rss/RSS14Reader' ; author Daniel Switkin <dswitkin@google.com>
 *  author Sean Owen
  export default class MultiFormatOneDReader extends OneDReader { private readers : OneDReader [ ] = [ ] ; public constructor ( hints ? ) { super ( ) ; const possibleFormats = ! hints ? null : < BarcodeFormat [ ] > hints . get ( DecodeHintType . POSSIBLE_FORMATS ) ; const useCode39CheckDigit = hints && hints . get ( DecodeHintType . ASSUME_CODE_39_CHECK_DIGIT ) !== undefined ; if ( possibleFormats ) { if ( possibleFormats . includes ( BarcodeFormat . EAN_13 ) || possibleFormats . includes ( BarcodeFormat . UPC_A ) || possibleFormats . includes ( BarcodeFormat . EAN_8 ) || possibleFormats . includes ( BarcodeFormat . UPC_E ) ) { this . readers . push ( new MultiFormatUPCEANReader ( hints ) ) ; } if ( possibleFormats . includes ( BarcodeFormat . CODE_39 ) ) { this . readers . push ( new Code39Reader ( useCode39CheckDigit ) ) ; } if ( possibleFormats . includes ( BarcodeFormat . CODE_128 ) ) { this . readers . push ( new Code128Reader ( ) ) ; } if ( possibleFormats . includes ( BarcodeFormat . ITF ) ) { this . readers . push ( new ITFReader ( ) ) ; } if ( possibleFormats . includes ( BarcodeFormat . RSS_14 ) ) { this . readers . push ( new RSS14Reader ( ) ) ; } if ( possibleFormats . includes ( BarcodeFormat . RSS_EXPANDED ) ) { console . warn ( 'RSS Expanded reader IS NOT ready for production yet! use at your own risk.' ) ; this . readers . push ( new RSSExpandedReader ( ) ) ; } } if ( this . readers . length === 0 ) { this . readers . push ( new MultiFormatUPCEANReader ( hints ) ) ; this . readers . push ( new Code39Reader ( ) ) ; this . readers . push ( new MultiFormatUPCEANReader ( hints ) ) ; this . readers . push ( new Code128Reader ( ) ) ; this . readers . push ( new ITFReader ( ) ) ; this . readers . push ( new RSS14Reader ( ) ) ; } } public decodeRow ( rowNumber , row , hints ) { for ( let i = 0 ; i < this . readers . length ; i ++ ) { try { return this . readers [ i ] . decodeRow ( rowNumber , row , hints ) ; } catch ( re ) { } } throw new NotFoundException ( ) ; } public reset ( ) { this . readers . forEach ( reader => reader . reset ( ) ) ; } }