import BarcodeFormat from '../BarcodeFormat' ; import BinaryBitmap from '../BinaryBitmap' ; import BitArray from '../common/BitArray' ; import DecodeHintType from '../DecodeHintType' ; import Reader from '../Reader' ; import Result from '../Result' ; import ResultMetadataType from '../ResultMetadataType' ; import ResultPoint from '../ResultPoint' ; import NotFoundException from '../NotFoundException' ; import EAN13Reader from './EAN13Reader' ; import UPCEANReader from './UPCEANReader' ; import { int } from 'src/customTypings' ; author dswitkin google author Sean Owen
 *  author sam2332 (Sam Rudloff)
 *
 *  source experimental export default class UPCAReader extends UPCEANReader { private readonly ean13Reader = new EAN13Reader ( ) ; public getBarcodeFormat ( ) { return BarcodeFormat . UPC_A ; } public decode ( image , hints ? ) { return this . maybeReturnResult ( this . ean13Reader . decode ( image ) ) ; } public decodeRow ( rowNumber , row , hints ? ) { return this . maybeReturnResult ( this . ean13Reader . decodeRow ( rowNumber , row , hints ) ) ; } public decodeMiddle ( row , startRange , resultString ) { return this . ean13Reader . decodeMiddle ( row , startRange , resultString ) ; } public maybeReturnResult ( result ) { let text = result . getText ( ) ; if ( text . charAt ( 0 ) === '0' ) { let upcaResult = new Result ( text . substring ( 1 ) , null , null , result . getResultPoints ( ) , BarcodeFormat . UPC_A ) ; if ( result . getResultMetadata ( ) != null ) { upcaResult . putAllMetadata ( result . getResultMetadata ( ) ) ; } return upcaResult ; } else { throw new NotFoundException ( ) ; } } public reset ( ) { this . ean13Reader . reset ( ) ; } }