UNPKG

@tjieco/library

Version:

TypeScript port of ZXing multi-format 1D/2D barcode image processing library, with Code128 and ITF support.

103 lines 4.59 kB
"use strict"; /* * Copyright 2008 ZXing authors * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ var __extends = (this && this.__extends) || (function () { var extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); var OneDReader_1 = require("./OneDReader"); var Code128Reader_1 = require("./Code128Reader"); var Exception_1 = require("../Exception"); var ITFReader_1 = require("./ITFReader"); /** * @author dswitkin@google.com (Daniel Switkin) * @author Sean Owen */ var MultiFormatOneDReader = /** @class */ (function (_super) { __extends(MultiFormatOneDReader, _super); function MultiFormatOneDReader(hints) { var _this = _super.call(this) || this; _this.readers = []; var possibleFormats = !hints ? null : hints.get(2 /* POSSIBLE_FORMATS */); var useCode39CheckDigit = hints && hints.get(6 /* ASSUME_CODE_39_CHECK_DIGIT */) !== undefined; if (possibleFormats) { // if (possibleFormats.get(BarcodeFormat.EAN_13) || // possibleFormats.get(BarcodeFormat.UPC_A) || // possibleFormats.get(BarcodeFormat.EAN_8) || // possibleFormats.get(BarcodeFormat.UPC_E)) { // readers.push(new MultiFormatUPCEANReader(hints)); // } // if (possibleFormats.get(BarcodeFormat.CODE_39)) { // this.readers.push(new Code39Reader(useCode39CheckDigit)); // } // if (possibleFormats.get(BarcodeFormat.CODE_93)) { // this.readers.push(new Code93Reader()); // } if (possibleFormats.get(4 /* CODE_128 */)) { _this.readers.push(new Code128Reader_1.default()); } if (possibleFormats.get(8 /* ITF */)) { _this.readers.push(new ITFReader_1.default()); } // if (possibleFormats.get(BarcodeFormat.CODABAR)) { // this.readers.push(new CodaBarReader()); // } // if (possibleFormats.get(BarcodeFormat.RSS_14)) { // this.readers.push(new RSS14Reader()); // } // if (possibleFormats.get(BarcodeFormat.RSS_EXPANDED)) { // 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 CodaBarReader()); // this.readers.push(new Code93Reader()); _this.readers.push(new Code128Reader_1.default()); _this.readers.push(new ITFReader_1.default()); // this.readers.push(new RSS14Reader()); // this.readers.push(new RSSExpandedReader()); } return _this; } // @Override MultiFormatOneDReader.prototype.decodeRow = function (rowNumber, row, hints) { for (var i = 0; i < this.readers.length; i++) { try { return this.readers[i].decodeRow(rowNumber, row, hints); } catch (re) { // continue } } throw new Exception_1.default(Exception_1.default.NotFoundException); }; // @Override MultiFormatOneDReader.prototype.reset = function () { this.readers.forEach(function (reader) { return reader.reset(); }); }; return MultiFormatOneDReader; }(OneDReader_1.default)); exports.default = MultiFormatOneDReader; //# sourceMappingURL=MultiFormatOneDReader.js.map