barcode-parser
Advanced tools
Comparing version 1.1.1 to 1.2.0
@@ -0,1 +1,22 @@ | ||
# [1.2.0](https://github.com/stonelasley/barcode-parsing/compare/v1.1.1...v1.2.0) (2019-02-07) | ||
### Features | ||
* **ean:** switch gtin to ean aim codes ([a09d303](https://github.com/stonelasley/barcode-parsing/commit/a09d303)) | ||
* **EAN:** Add EAN8 - EAN13 support ([a7a2231](https://github.com/stonelasley/barcode-parsing/commit/a7a2231)) | ||
* **EAN:** EAN 8/13 support ([73adacc](https://github.com/stonelasley/barcode-parsing/commit/73adacc)) | ||
# [1.1.0](https://github.com/stonelasley/barcode-parsing/compare/v1.0.0...v1.1.0) (2019-01-19) | ||
### Bug Fixes | ||
* **code-128:** export code 128 reader ([21ee2b6](https://github.com/stonelasley/barcode-parsing/commit/21ee2b6)) | ||
### Features | ||
* **code-128:** parse code 128 ([ae2175b](https://github.com/stonelasley/barcode-parsing/commit/ae2175b)) | ||
# 1.0.0 (2018-06-29) | ||
@@ -2,0 +23,0 @@ |
{ | ||
"name": "barcode-parser", | ||
"version": "1.1.1", | ||
"version": "1.2.0", | ||
"description": "This project started out as a straight port of the Quagga project - https://serratus.github.io/quaggaJS. - to typescript however it has significantly diverged.", | ||
@@ -11,5 +11,6 @@ "repository": "git@github.com:stonelasley/barcode-parsing.git", | ||
"prepublish": "npm run build", | ||
"pretest": "npm run build", | ||
"test": "nyc --reporter=html --reporter=text mocha ./lib/test --recursive", | ||
"coverage": "nyc report --reporter=text-lcov | coveralls", | ||
"test": "jest", | ||
"test:watch": "jest --watch", | ||
"coverage": "jest --coverage", | ||
"prettier": "prettier --config .prettierrc --write \"{src,__{tests,mocks}__}/**/*.ts\"", | ||
"lint": "tslint -c tslint.json 'src/**/*.ts'", | ||
@@ -24,12 +25,11 @@ "release": "semantic-release" | ||
"@semantic-release/github": "^4.2.18", | ||
"@types/chai": "^3.4.34", | ||
"@types/mocha": "^2.2.39", | ||
"chai": "^3.5.0", | ||
"@types/jest": "^23.3.12", | ||
"coveralls": "^3.0.1", | ||
"cz-conventional-changelog": "^2.1.0", | ||
"mocha": "^3.0.2", | ||
"nyc": "^12.0.2", | ||
"jest": "^23.6.0", | ||
"prettier": "1.15.3", | ||
"semantic-release": "^15.6.0", | ||
"ts-jest": "^23.10.5", | ||
"tslint": "^5.10.0", | ||
"typescript": "^2.9.2" | ||
"typescript": "^3.2.4" | ||
}, | ||
@@ -36,0 +36,0 @@ "config": { |
@@ -0,0 +0,0 @@ [![Coverage Status](https://coveralls.io/repos/github/stonelasley/barcode-parsing/badge.svg?branch=master)](https://coveralls.io/github/stonelasley/barcode-parsing?branch=master) |
import { READER_TYPES } from './readers'; | ||
import { IBarcodeValue, BarcodeValue } from './models'; | ||
import { IParserConfiguration } from './models/parser.configuration'; | ||
import { IReaderConfiguration } from './models/reader.configuration'; | ||
import { IBarcodeValue, BarcodeValue, IParserConfiguration, IReaderConfiguration } from './models'; | ||
export class BarcodeParser { | ||
private _readers: any; | ||
public get readers(): any { | ||
return this._readers; | ||
} | ||
private _readers: any; | ||
public get readers(): any { | ||
return this._readers; | ||
} | ||
public set readers(value: any) { | ||
this._readers = value; | ||
} | ||
public set readers(value: any) { | ||
this._readers = value; | ||
} | ||
constructor(config: IParserConfiguration) { | ||
this.initReaders(config.readers, config.readerConfigurations); | ||
} | ||
constructor(config: IParserConfiguration) { | ||
this.initReaders(config.readers, config.readerConfigurations); | ||
} | ||
public parse(barcodeVal: any): IBarcodeValue { | ||
let result: IBarcodeValue = null; | ||
public parse(barcodeVal: any): IBarcodeValue { | ||
let result: IBarcodeValue = null; | ||
this._readers.forEach(reader => { | ||
if (reader.validate(barcodeVal)) { | ||
result = reader.decode(barcodeVal); | ||
} | ||
}); | ||
this._readers.forEach((reader) => { | ||
if (reader.validate(barcodeVal)) { | ||
result = reader.decode(barcodeVal); | ||
} | ||
}); | ||
if (!result) { | ||
result = new BarcodeValue(null, barcodeVal); | ||
result.errorMessage = 'No Reader Found'; | ||
result.success = false; | ||
} | ||
return result; | ||
} | ||
if (!result) { | ||
result = new BarcodeValue(null, barcodeVal); | ||
result.errorMessage = 'No Reader Found'; | ||
result.success = false; | ||
} | ||
return result; | ||
} | ||
protected initReaders( | ||
readerTypes: string[], | ||
configurations: IReaderConfiguration[] | ||
) { | ||
this.readers = readerTypes.map(r => { | ||
let readerConfig: IReaderConfiguration; | ||
if (configurations.length > 0) { | ||
const configs = configurations.filter( | ||
c => c !== undefined && r === c.symbology | ||
); | ||
readerConfig = configs.pop(); | ||
} | ||
if (READER_TYPES[r]) { | ||
return new READER_TYPES[r](readerConfig); | ||
} | ||
}); | ||
protected initReaders(readerTypes: string[], configurations: IReaderConfiguration[]) { | ||
this.readers = readerTypes.map(r => { | ||
let readerConfig: IReaderConfiguration; | ||
if (configurations.length > 0) { | ||
const configs = configurations.filter(c => c !== undefined && r === c.symbology); | ||
readerConfig = configs.pop(); | ||
} | ||
if (READER_TYPES[r]) { | ||
return new READER_TYPES[r](readerConfig); | ||
} | ||
}); | ||
/* tslint:disable */ | ||
this._readers.forEach(reader => console.log('Reader Initialized: ', reader)); | ||
/* tslint:enable */ | ||
} | ||
/* tslint:disable */ | ||
this._readers.forEach(reader => | ||
console.log('Reader Initialized: ', reader) | ||
); | ||
/* tslint:enable */ | ||
} | ||
} |
@@ -1,22 +0,9 @@ | ||
export class AIMCODES { | ||
public static get GS1(): string { | ||
return ']C1'; | ||
} | ||
public static get GTIN(): string { | ||
return ']E'; | ||
} | ||
public static get ITF(): string { | ||
return ']I0'; | ||
} | ||
public static get CODE39(): string { | ||
return ']A0'; | ||
} | ||
public static get CODE128(): string { | ||
return ']C0'; | ||
} | ||
export enum AimCodes { | ||
GS1 = ']C1', | ||
GTIN = ']E0', | ||
ITF = ']I0', | ||
CODE39 = ']A0', | ||
CODE128 = ']C0', | ||
EAN13 = ']E3', | ||
EAN8 = ']E4', | ||
} |
export class Symbologies { | ||
public static get All(): string[] { | ||
return [ | ||
this.Code39, | ||
this.Code128, | ||
this.GS1128, | ||
...this.GTINX, | ||
...this.ITFX, | ||
]; | ||
} | ||
public static get All(): string[] { | ||
return [ | ||
this.Code39, | ||
this.Code128, | ||
this.GS1128, | ||
...this.GTINX, | ||
...this.ITFX, | ||
]; | ||
} | ||
public static get GTINX(): string[] { | ||
return [this.GTIN8, this.GTIN12, this.GTIN13, this.GTIN14]; | ||
} | ||
public static get GTINX(): string[] { | ||
return [ | ||
this.GTIN8, | ||
this.GTIN12, | ||
this.GTIN13, | ||
this.GTIN14, | ||
]; | ||
} | ||
public static get ITFX(): string[] { | ||
return [this.ITF8, this.ITF12, this.ITF13, this.ITF14]; | ||
} | ||
public static get ITFX(): string[] { | ||
return [ | ||
this.ITF8, | ||
this.ITF12, | ||
this.ITF13, | ||
this.ITF14, | ||
]; | ||
} | ||
public static get Code39(): string { | ||
return 'code_39'; | ||
} | ||
public static get Code39(): string { | ||
return 'code_39'; | ||
} | ||
public static get GTIN8(): string { | ||
return 'gtin_8'; | ||
} | ||
public static get GTIN8(): string { | ||
return 'gtin_8'; | ||
} | ||
public static get GTIN12(): string { | ||
return 'gtin_12'; | ||
} | ||
public static get GTIN12(): string { | ||
return 'gtin_12'; | ||
} | ||
public static get GTIN13(): string { | ||
return 'gtin_13'; | ||
} | ||
public static get GTIN13(): string { | ||
return 'gtin_13'; | ||
} | ||
public static get GTIN14(): string { | ||
return 'gtin_14'; | ||
} | ||
public static get GTIN14(): string { | ||
return 'gtin_14'; | ||
} | ||
public static get ITF8(): string { | ||
return 'itf_8'; | ||
} | ||
public static get ITF8(): string { | ||
return 'itf_8'; | ||
} | ||
public static get ITF12(): string { | ||
return 'itf_12'; | ||
} | ||
public static get ITF12(): string { | ||
return 'itf_12'; | ||
} | ||
public static get ITF13(): string { | ||
return 'itf_13'; | ||
} | ||
public static get ITF13(): string { | ||
return 'itf_13'; | ||
} | ||
public static get ITF14(): string { | ||
return 'itf_14'; | ||
} | ||
public static get ITF14(): string { | ||
return 'itf_14'; | ||
} | ||
public static get GS1128(): string { | ||
return 'gs1_128'; | ||
} | ||
public static get GS1128(): string { | ||
return 'gs1_128'; | ||
} | ||
public static get Code128(): string { | ||
return 'code_128'; | ||
} | ||
public static get Code128(): string { | ||
return 'code_128'; | ||
} | ||
} |
@@ -1,10 +0,5 @@ | ||
import {BarcodeParser} from './barcode-parser'; | ||
import {IBarcodeValue, IParserConfiguration} from './models/'; | ||
import {Symbologies} from './config/symbologies'; | ||
import { BarcodeParser } from './barcode-parser'; | ||
import { IBarcodeValue, IParserConfiguration } from './models/'; | ||
import { Symbologies } from './config/symbologies'; | ||
export { | ||
BarcodeParser, | ||
IBarcodeValue, | ||
IParserConfiguration, | ||
Symbologies, | ||
}; | ||
export { BarcodeParser, IBarcodeValue, IParserConfiguration, Symbologies }; |
export class ApplicationIdentifier { | ||
public get code(): string { | ||
return this._code; | ||
} | ||
public get code(): string { | ||
return this._code; | ||
} | ||
public get length(): number { | ||
return this._length; | ||
} | ||
public get length(): number { | ||
return this._length; | ||
} | ||
public get variableLength(): boolean { | ||
return this._variableLength; | ||
} | ||
public get variableLength(): boolean { | ||
return this._variableLength; | ||
} | ||
public get description(): string { | ||
return this._description; | ||
} | ||
public get description(): string { | ||
return this._description; | ||
} | ||
public get totalLength(): number { | ||
return ( | ||
this._code.length + | ||
this._length + | ||
(this.fractional === true ? 1 : 0) | ||
); | ||
} | ||
public get totalLength(): number { | ||
return this._code.length + this._length + (this.fractional === true ? 1 : 0); | ||
} | ||
public get fractional(): boolean { | ||
return this.frac; | ||
} | ||
private frac = false; | ||
public get fractional(): boolean { | ||
return this.frac; | ||
} | ||
constructor( | ||
private _code: string, | ||
private _description: string, | ||
private _length: number, | ||
private _variableLength: boolean, | ||
fractional?: boolean) { | ||
this.frac = fractional || false; | ||
} | ||
constructor( | ||
private _code: string, | ||
private _description: string, | ||
private _length: number, | ||
private _variableLength: boolean, | ||
private frac: boolean = false | ||
) {} | ||
} |
import { ApplicationIdentifier } from './application-identifier'; | ||
export const APPLICATION_IDENTIFIERS: ApplicationIdentifier[] = [ | ||
new ApplicationIdentifier('00', 'Serial Shipping Container Code', 18, false), | ||
new ApplicationIdentifier('01', 'Global Trade Item Number', 14, false), | ||
new ApplicationIdentifier('02', 'GTIN of Contained Trade Items', 14, false), | ||
new ApplicationIdentifier('10', 'Batch/Lot Number', 20, true), | ||
new ApplicationIdentifier('11', 'Production Date', 6, false), | ||
new ApplicationIdentifier('12', 'DueDate', 6, false), | ||
new ApplicationIdentifier('13', 'Packaging Date', 6, false), | ||
new ApplicationIdentifier('15', 'Best Befor eDate YYMMDD', 6, false), | ||
new ApplicationIdentifier('17', 'Expiration Date', 6, false), | ||
new ApplicationIdentifier('20', 'Product Variant', 2, false), | ||
new ApplicationIdentifier('21', 'Serial Number', 20, true), | ||
new ApplicationIdentifier('22', 'Secondary Data Fields', 29, true), | ||
new ApplicationIdentifier('23n', 'Lot number[n]', 19, true), | ||
new ApplicationIdentifier('240', 'Additional Product Identification', 30, true), | ||
new ApplicationIdentifier('241', 'Customer Part Number', 30, true), | ||
new ApplicationIdentifier('242', 'Made-to-Order Variation Number', 6, true), | ||
new ApplicationIdentifier('250', 'Secondary Serial Number', 30, true), | ||
new ApplicationIdentifier('251', 'Reference to SourceEntity', 30, true), | ||
new ApplicationIdentifier('253', 'Global Document Type Identifier', 17, true), | ||
new ApplicationIdentifier('254', 'GLN Extension Component', 20, true), | ||
new ApplicationIdentifier('255', 'Global Coupon Number GCN', 25, true), | ||
new ApplicationIdentifier('30', 'Count of items', 8, true), | ||
new ApplicationIdentifier('310', 'Product Net Weight in kg', 6, false, true), | ||
new ApplicationIdentifier('311', 'Product Length/1st Dimension,in meters', 6, false, true), | ||
new ApplicationIdentifier('312', 'Product Width/Diameter/2nd Dimension,in meters', 6, false, true), | ||
new ApplicationIdentifier('313', 'Product Depth/Thickness/Height/3rd Dimension,in meters', 6, false, true), | ||
new ApplicationIdentifier('314', 'Product Area,in square meters', 6, false, true), | ||
new ApplicationIdentifier('315', 'Product Net Volume,in liters', 6, false, true), | ||
new ApplicationIdentifier('316', 'Product Net Volume,in cubic meters', 6, false, true), | ||
new ApplicationIdentifier('320', 'Product Net Weight,in pounds', 6, false, true), | ||
new ApplicationIdentifier('321', 'Product Length/1st Dimension,in inches', 6, false, true), | ||
new ApplicationIdentifier('322', 'Product Length/1st Dimension,in feet', 6, false, true), | ||
new ApplicationIdentifier('323', 'Product Length/1st Dimension,in yards', 6, false, true), | ||
new ApplicationIdentifier('324', 'Product Width/Diameter/2nd Dimension,in inches', 6, false, true), | ||
new ApplicationIdentifier('325', 'Product Width/Diameter/2nd Dimension,in feet', 6, false, true), | ||
new ApplicationIdentifier('326', 'Product Width/Diameter/2nd Dimension,in yards', 6, false, true), | ||
new ApplicationIdentifier('327', 'Product Depth/Thickness/Height/3rd Dimension,in inches', 6, false, true), | ||
new ApplicationIdentifier('328', 'Product Depth/Thickness/Height/3rd Dimension,in feet', 6, false, true), | ||
new ApplicationIdentifier('329', 'Product Depth/Thickness/3rd Dimension,in yards', 6, false, true), | ||
new ApplicationIdentifier('330', 'Container Gross Weight kg', 6, false, true), | ||
new ApplicationIdentifier('331', 'Container Length/1st Dimension Meters', 6, false, true), | ||
new ApplicationIdentifier('332', 'Container Width/Diameter/2nd Dimension Meters', 6, false, true), | ||
new ApplicationIdentifier('333', 'Container Depth/Thickness/3rdDimension Meters', 6, false, true), | ||
new ApplicationIdentifier('334', 'Container Area Square Meters', 6, false, true), | ||
new ApplicationIdentifier('335', 'Container Gross Volume Liters', 6, false, true), | ||
new ApplicationIdentifier('336', 'Container Gross Volume(CubicMeters', 6, false, true), | ||
new ApplicationIdentifier('340', 'Container Gross Weight(Pounds', 6, false, true), | ||
new ApplicationIdentifier('341', 'Container Length/1stDimension,ininches', 6, false, true), | ||
new ApplicationIdentifier('342', 'Container Length/1stDimension,infeet', 6, false, true), | ||
new ApplicationIdentifier('343', 'Container Length/1stDimensionin,inyards', 6, false, true), | ||
new ApplicationIdentifier('344', 'Container Width/Diameter/2nd Dimension,in inches', 6, false, true), | ||
new ApplicationIdentifier('345', 'Container Width/Diameter/2nd Dimension,in feet', 6, false, true), | ||
new ApplicationIdentifier('346', 'Container Width/Diameter/2nd Dimension,in yards', 6, false, true), | ||
new ApplicationIdentifier('347', 'Container Depth/Thickness/Height/3rd Dimension,in inches', 6, false, true), | ||
new ApplicationIdentifier('348', 'Container Depth/Thickness/Height/3rd Dimension,in feet', 6, false, true), | ||
new ApplicationIdentifier('349', 'Container Depth/Thickness/Height/3rd Dimension,in yards', 6, false, true), | ||
new ApplicationIdentifier('350', 'Product Area(SquareInches', 6, false, true), | ||
new ApplicationIdentifier('351', 'Product Area(SquareFeet', 6, false, true), | ||
new ApplicationIdentifier('352', 'Product Area(SquareYards', 6, false, true), | ||
new ApplicationIdentifier('353', 'Container Area(SquareInches', 6, false, true), | ||
new ApplicationIdentifier('354', 'Container Area(SquareFeet', 6, false, true), | ||
new ApplicationIdentifier('355', 'Container Area(SquareYards', 6, false, true), | ||
new ApplicationIdentifier('356', 'Net Weight(TroyOunces', 6, false, true), | ||
new ApplicationIdentifier('357', 'Net Weight/Volume(Ounces', 6, false, true), | ||
new ApplicationIdentifier('360', 'Product Volume(Quarts', 6, false, true), | ||
new ApplicationIdentifier('361', 'Product Volume(Gallons', 6, false, true), | ||
new ApplicationIdentifier('362', 'Container Gross Volume(Quarts', 6, false, true), | ||
new ApplicationIdentifier('363', 'ContainerGrossVolume(U.S.Gallons', 6, false, true), | ||
new ApplicationIdentifier('364', 'ProductVolume(CubicInches', 6, false, true), | ||
new ApplicationIdentifier('365', 'ProductVolume(CubicFeet', 6, false, true), | ||
new ApplicationIdentifier('366', 'ProductVolume(CubicYards', 6, false, true), | ||
new ApplicationIdentifier('367', 'ContainerGrossVolume(CubicInches', 6, false, true), | ||
new ApplicationIdentifier('368', 'ContainerGrossVolume(CubicFeet', 6, false, true), | ||
new ApplicationIdentifier('369', 'ContainerGrossVolume(CubicYards', 6, false, true), | ||
new ApplicationIdentifier('37', 'NumberofUnitsContained', 8, true), | ||
new ApplicationIdentifier('390', 'Amount payable local currency)', 15, true, true), | ||
new ApplicationIdentifier('391', 'Amount payable with ISO currency code', 18, true, true), | ||
new ApplicationIdentifier('392', 'Amount payable per single item local currency', 15, true, true), | ||
new ApplicationIdentifier('393', 'Amount payable persingle itemx with ISO currency code', 18, true, true), | ||
new ApplicationIdentifier('400', 'Customer Purchase Order Number', 30, true), | ||
new ApplicationIdentifier('401', 'Consignment Number', 30, true), | ||
new ApplicationIdentifier('402', 'BillofLadingnumber', 17, false), | ||
new ApplicationIdentifier('403', 'Routing code', 30, true), | ||
new ApplicationIdentifier('410', 'ShipTo/DeliverToLocationCode(GlobalLocationNumber', 13, false), | ||
new ApplicationIdentifier('411', 'BillTo/InvoiceLocationCode(GlobalLocationNumber', 13, false), | ||
new ApplicationIdentifier('412', 'PurchaseFromLocationCode(GlobalLocationNumber', 13, false), | ||
new ApplicationIdentifier('413', 'Shipfor,Deliver for,or Forward to Location Code', 13, false), | ||
new ApplicationIdentifier('414', 'Identification of a physical location', 13, false), | ||
new ApplicationIdentifier('420', 'ShipTo/DeliverToPostalCode', 20, true), | ||
new ApplicationIdentifier('421', 'ShipTo/DeliverToPostalCode', 15, true), | ||
new ApplicationIdentifier('422', 'Country of Origin', 3, false), | ||
new ApplicationIdentifier('423', 'Country or countries of initial processing', 15, true), | ||
new ApplicationIdentifier('424', 'Country of processing', 3, false), | ||
new ApplicationIdentifier('425', 'Country of disassembly', 3, false), | ||
new ApplicationIdentifier('426', 'Country of full process chain', 3, false), | ||
new ApplicationIdentifier('7001', 'NATO Stock Number NSN', 13, false), | ||
new ApplicationIdentifier('7002', 'UN/ECE Meat Carcasses and cuts classification', 30, true), | ||
new ApplicationIdentifier('7003', 'expiration date and time', 10, false), | ||
new ApplicationIdentifier('7004', 'Active Potency', 4, true), | ||
new ApplicationIdentifier('703n', 'Processor approval', 30, true), | ||
new ApplicationIdentifier('8001', 'Roll Products: Width/Length/CoreDiameter/Direction/Splices', 14, false), | ||
new ApplicationIdentifier('8002', 'Mobile phone identifier', 20, true), | ||
new ApplicationIdentifier('8003', 'Global ReturnableAssetIdentifier', 30, true), | ||
new ApplicationIdentifier('8004', 'Global IndividualAssetIdentifier', 30, true), | ||
new ApplicationIdentifier('8005', 'Price perUnitofMeasure', 6, false), | ||
new ApplicationIdentifier('8006', 'identification of the components of an item', 18, false), | ||
new ApplicationIdentifier('8007', 'International Bank Account Number', 30, true), | ||
new ApplicationIdentifier('8008', 'Date/time of production', 12, true), | ||
new ApplicationIdentifier('8018', 'Global ServiceRelationshipNumber', 18, false), | ||
new ApplicationIdentifier('8020', 'Payment slip preference number', 25, true), | ||
new ApplicationIdentifier('8100', 'CouponExtendedCode: Number System and Offer', 6, false), | ||
new ApplicationIdentifier('8101', 'CouponExtendedCode: Number System,Offer,End of Offer', 10, false), | ||
new ApplicationIdentifier('8102', 'CouponExtendedCode: Number System preceded by 0', 2, false), | ||
new ApplicationIdentifier('8110', 'CouponcodeID(NorthAmerica', 30, true), | ||
new ApplicationIdentifier('8200', 'Extended Packaging URL', 70, true), | ||
new ApplicationIdentifier('90', 'Mutually Agreed Between Trading Partners', 30, true), | ||
new ApplicationIdentifier('91', 'Internal Company Codes', 30, true), | ||
new ApplicationIdentifier('92', 'Internal Company Codes', 30, true), | ||
new ApplicationIdentifier('93', 'Internal Company Codes', 30, true), | ||
new ApplicationIdentifier('94', 'Internal Company Codes', 30, true), | ||
new ApplicationIdentifier('95', 'Internal Company Codes', 30, true), | ||
new ApplicationIdentifier('96', 'Internal Company Codes', 30, true), | ||
new ApplicationIdentifier('97', 'Internal Company Codes', 30, true), | ||
new ApplicationIdentifier('98', 'Internal Company Codes', 30, true), | ||
new ApplicationIdentifier('99', 'Internal Company Codes', 30, true), | ||
new ApplicationIdentifier( | ||
'00', | ||
'Serial Shipping Container Code', | ||
18, | ||
false | ||
), | ||
new ApplicationIdentifier('01', 'Global Trade Item Number', 14, false), | ||
new ApplicationIdentifier('02', 'GTIN of Contained Trade Items', 14, false), | ||
new ApplicationIdentifier('10', 'Batch/Lot Number', 20, true), | ||
new ApplicationIdentifier('11', 'Production Date', 6, false), | ||
new ApplicationIdentifier('12', 'DueDate', 6, false), | ||
new ApplicationIdentifier('13', 'Packaging Date', 6, false), | ||
new ApplicationIdentifier('15', 'Best Befor eDate YYMMDD', 6, false), | ||
new ApplicationIdentifier('17', 'Expiration Date', 6, false), | ||
new ApplicationIdentifier('20', 'Product Variant', 2, false), | ||
new ApplicationIdentifier('21', 'Serial Number', 20, true), | ||
new ApplicationIdentifier('22', 'Secondary Data Fields', 29, true), | ||
new ApplicationIdentifier('23n', 'Lot number[n]', 19, true), | ||
new ApplicationIdentifier( | ||
'240', | ||
'Additional Product Identification', | ||
30, | ||
true | ||
), | ||
new ApplicationIdentifier('241', 'Customer Part Number', 30, true), | ||
new ApplicationIdentifier('242', 'Made-to-Order Variation Number', 6, true), | ||
new ApplicationIdentifier('250', 'Secondary Serial Number', 30, true), | ||
new ApplicationIdentifier('251', 'Reference to SourceEntity', 30, true), | ||
new ApplicationIdentifier( | ||
'253', | ||
'Global Document Type Identifier', | ||
17, | ||
true | ||
), | ||
new ApplicationIdentifier('254', 'GLN Extension Component', 20, true), | ||
new ApplicationIdentifier('255', 'Global Coupon Number GCN', 25, true), | ||
new ApplicationIdentifier('30', 'Count of items', 8, true), | ||
new ApplicationIdentifier( | ||
'310', | ||
'Product Net Weight in kg', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'311', | ||
'Product Length/1st Dimension,in meters', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'312', | ||
'Product Width/Diameter/2nd Dimension,in meters', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'313', | ||
'Product Depth/Thickness/Height/3rd Dimension,in meters', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'314', | ||
'Product Area,in square meters', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'315', | ||
'Product Net Volume,in liters', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'316', | ||
'Product Net Volume,in cubic meters', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'320', | ||
'Product Net Weight,in pounds', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'321', | ||
'Product Length/1st Dimension,in inches', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'322', | ||
'Product Length/1st Dimension,in feet', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'323', | ||
'Product Length/1st Dimension,in yards', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'324', | ||
'Product Width/Diameter/2nd Dimension,in inches', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'325', | ||
'Product Width/Diameter/2nd Dimension,in feet', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'326', | ||
'Product Width/Diameter/2nd Dimension,in yards', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'327', | ||
'Product Depth/Thickness/Height/3rd Dimension,in inches', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'328', | ||
'Product Depth/Thickness/Height/3rd Dimension,in feet', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'329', | ||
'Product Depth/Thickness/3rd Dimension,in yards', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'330', | ||
'Container Gross Weight kg', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'331', | ||
'Container Length/1st Dimension Meters', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'332', | ||
'Container Width/Diameter/2nd Dimension Meters', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'333', | ||
'Container Depth/Thickness/3rdDimension Meters', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'334', | ||
'Container Area Square Meters', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'335', | ||
'Container Gross Volume Liters', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'336', | ||
'Container Gross Volume(CubicMeters', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'340', | ||
'Container Gross Weight(Pounds', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'341', | ||
'Container Length/1stDimension,ininches', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'342', | ||
'Container Length/1stDimension,infeet', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'343', | ||
'Container Length/1stDimensionin,inyards', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'344', | ||
'Container Width/Diameter/2nd Dimension,in inches', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'345', | ||
'Container Width/Diameter/2nd Dimension,in feet', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'346', | ||
'Container Width/Diameter/2nd Dimension,in yards', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'347', | ||
'Container Depth/Thickness/Height/3rd Dimension,in inches', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'348', | ||
'Container Depth/Thickness/Height/3rd Dimension,in feet', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'349', | ||
'Container Depth/Thickness/Height/3rd Dimension,in yards', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'350', | ||
'Product Area(SquareInches', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier('351', 'Product Area(SquareFeet', 6, false, true), | ||
new ApplicationIdentifier( | ||
'352', | ||
'Product Area(SquareYards', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'353', | ||
'Container Area(SquareInches', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'354', | ||
'Container Area(SquareFeet', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'355', | ||
'Container Area(SquareYards', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier('356', 'Net Weight(TroyOunces', 6, false, true), | ||
new ApplicationIdentifier( | ||
'357', | ||
'Net Weight/Volume(Ounces', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier('360', 'Product Volume(Quarts', 6, false, true), | ||
new ApplicationIdentifier('361', 'Product Volume(Gallons', 6, false, true), | ||
new ApplicationIdentifier( | ||
'362', | ||
'Container Gross Volume(Quarts', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'363', | ||
'ContainerGrossVolume(U.S.Gallons', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'364', | ||
'ProductVolume(CubicInches', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier('365', 'ProductVolume(CubicFeet', 6, false, true), | ||
new ApplicationIdentifier( | ||
'366', | ||
'ProductVolume(CubicYards', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'367', | ||
'ContainerGrossVolume(CubicInches', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'368', | ||
'ContainerGrossVolume(CubicFeet', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'369', | ||
'ContainerGrossVolume(CubicYards', | ||
6, | ||
false, | ||
true | ||
), | ||
new ApplicationIdentifier('37', 'NumberofUnitsContained', 8, true), | ||
new ApplicationIdentifier( | ||
'390', | ||
'Amount payable local currency)', | ||
15, | ||
true, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'391', | ||
'Amount payable with ISO currency code', | ||
18, | ||
true, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'392', | ||
'Amount payable per single item local currency', | ||
15, | ||
true, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'393', | ||
'Amount payable persingle itemx with ISO currency code', | ||
18, | ||
true, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'400', | ||
'Customer Purchase Order Number', | ||
30, | ||
true | ||
), | ||
new ApplicationIdentifier('401', 'Consignment Number', 30, true), | ||
new ApplicationIdentifier('402', 'BillofLadingnumber', 17, false), | ||
new ApplicationIdentifier('403', 'Routing code', 30, true), | ||
new ApplicationIdentifier( | ||
'410', | ||
'ShipTo/DeliverToLocationCode(GlobalLocationNumber', | ||
13, | ||
false | ||
), | ||
new ApplicationIdentifier( | ||
'411', | ||
'BillTo/InvoiceLocationCode(GlobalLocationNumber', | ||
13, | ||
false | ||
), | ||
new ApplicationIdentifier( | ||
'412', | ||
'PurchaseFromLocationCode(GlobalLocationNumber', | ||
13, | ||
false | ||
), | ||
new ApplicationIdentifier( | ||
'413', | ||
'Shipfor,Deliver for,or Forward to Location Code', | ||
13, | ||
false | ||
), | ||
new ApplicationIdentifier( | ||
'414', | ||
'Identification of a physical location', | ||
13, | ||
false | ||
), | ||
new ApplicationIdentifier('420', 'ShipTo/DeliverToPostalCode', 20, true), | ||
new ApplicationIdentifier('421', 'ShipTo/DeliverToPostalCode', 15, true), | ||
new ApplicationIdentifier('422', 'Country of Origin', 3, false), | ||
new ApplicationIdentifier( | ||
'423', | ||
'Country or countries of initial processing', | ||
15, | ||
true | ||
), | ||
new ApplicationIdentifier('424', 'Country of processing', 3, false), | ||
new ApplicationIdentifier('425', 'Country of disassembly', 3, false), | ||
new ApplicationIdentifier('426', 'Country of full process chain', 3, false), | ||
new ApplicationIdentifier('7001', 'NATO Stock Number NSN', 13, false), | ||
new ApplicationIdentifier( | ||
'7002', | ||
'UN/ECE Meat Carcasses and cuts classification', | ||
30, | ||
true | ||
), | ||
new ApplicationIdentifier('7003', 'expiration date and time', 10, false), | ||
new ApplicationIdentifier('7004', 'Active Potency', 4, true), | ||
new ApplicationIdentifier('703n', 'Processor approval', 30, true), | ||
new ApplicationIdentifier( | ||
'8001', | ||
'Roll Products: Width/Length/CoreDiameter/Direction/Splices', | ||
14, | ||
false | ||
), | ||
new ApplicationIdentifier('8002', 'Mobile phone identifier', 20, true), | ||
new ApplicationIdentifier( | ||
'8003', | ||
'Global ReturnableAssetIdentifier', | ||
30, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'8004', | ||
'Global IndividualAssetIdentifier', | ||
30, | ||
true | ||
), | ||
new ApplicationIdentifier('8005', 'Price perUnitofMeasure', 6, false), | ||
new ApplicationIdentifier( | ||
'8006', | ||
'identification of the components of an item', | ||
18, | ||
false | ||
), | ||
new ApplicationIdentifier( | ||
'8007', | ||
'International Bank Account Number', | ||
30, | ||
true | ||
), | ||
new ApplicationIdentifier('8008', 'Date/time of production', 12, true), | ||
new ApplicationIdentifier( | ||
'8018', | ||
'Global ServiceRelationshipNumber', | ||
18, | ||
false | ||
), | ||
new ApplicationIdentifier( | ||
'8020', | ||
'Payment slip preference number', | ||
25, | ||
true | ||
), | ||
new ApplicationIdentifier( | ||
'8100', | ||
'CouponExtendedCode: Number System and Offer', | ||
6, | ||
false | ||
), | ||
new ApplicationIdentifier( | ||
'8101', | ||
'CouponExtendedCode: Number System,Offer,End of Offer', | ||
10, | ||
false | ||
), | ||
new ApplicationIdentifier( | ||
'8102', | ||
'CouponExtendedCode: Number System preceded by 0', | ||
2, | ||
false | ||
), | ||
new ApplicationIdentifier('8110', 'CouponcodeID(NorthAmerica', 30, true), | ||
new ApplicationIdentifier('8200', 'Extended Packaging URL', 70, true), | ||
new ApplicationIdentifier( | ||
'90', | ||
'Mutually Agreed Between Trading Partners', | ||
30, | ||
true | ||
), | ||
new ApplicationIdentifier('91', 'Internal Company Codes', 30, true), | ||
new ApplicationIdentifier('92', 'Internal Company Codes', 30, true), | ||
new ApplicationIdentifier('93', 'Internal Company Codes', 30, true), | ||
new ApplicationIdentifier('94', 'Internal Company Codes', 30, true), | ||
new ApplicationIdentifier('95', 'Internal Company Codes', 30, true), | ||
new ApplicationIdentifier('96', 'Internal Company Codes', 30, true), | ||
new ApplicationIdentifier('97', 'Internal Company Codes', 30, true), | ||
new ApplicationIdentifier('98', 'Internal Company Codes', 30, true), | ||
new ApplicationIdentifier('99', 'Internal Company Codes', 30, true), | ||
]; |
import { IBarcodeValue } from './ibarcode-value'; | ||
export class BarcodeValue implements IBarcodeValue { | ||
private _values: any; | ||
private _errorMessage: string; | ||
private _success: boolean; | ||
private _checkDigit: number = -1; | ||
private _values: any; | ||
private _errorMessage: string; | ||
private _success: boolean; | ||
private _checkDigit: number = -1; | ||
constructor(private _symbology: string, private _rawValue: string) { | ||
this._success = true; | ||
this.values = []; | ||
} | ||
constructor(private _symbology: string, private _rawValue: string) { | ||
this._success = true; | ||
this.values = []; | ||
} | ||
public get symbology(): string { | ||
return this._symbology; | ||
} | ||
public get symbology(): string { | ||
return this._symbology; | ||
} | ||
public set symbology(value: string) { | ||
this._symbology = value; | ||
} | ||
public set symbology(value: string) { | ||
this._symbology = value; | ||
} | ||
public get rawValue(): string { | ||
return this._rawValue; | ||
} | ||
public get rawValue(): string { | ||
return this._rawValue; | ||
} | ||
public set rawValue(value: string) { | ||
this._rawValue = value; | ||
} | ||
public set rawValue(value: string) { | ||
this._rawValue = value; | ||
} | ||
public get values(): any { | ||
return this._values; | ||
} | ||
public get values(): any { | ||
return this._values; | ||
} | ||
public set values(value: any) { | ||
this._values = value; | ||
} | ||
public set values(value: any) { | ||
this._values = value; | ||
} | ||
public get errorMessage(): string { | ||
return this._errorMessage; | ||
} | ||
public get errorMessage(): string { | ||
return this._errorMessage; | ||
} | ||
public set errorMessage(value: string) { | ||
this._errorMessage = value; | ||
} | ||
public set errorMessage(value: string) { | ||
this._errorMessage = value; | ||
} | ||
public get success(): boolean { | ||
return this._success; | ||
} | ||
public get success(): boolean { | ||
return this._success; | ||
} | ||
public set success(value: boolean) { | ||
this._success = value; | ||
} | ||
public set success(value: boolean) { | ||
this._success = value; | ||
} | ||
public get checkDigit(): number { | ||
return this._checkDigit; | ||
} | ||
public get checkDigit(): number { | ||
return this._checkDigit; | ||
} | ||
public set checkDigit(value: number) { | ||
this._checkDigit = value; | ||
} | ||
public set checkDigit(value: number) { | ||
this._checkDigit = value; | ||
} | ||
public pluck(valueKey: string): any { | ||
if (this.values !== undefined && this.values instanceof Array) { | ||
const result = this.values.filter((r: any) => { | ||
return r.code === valueKey; | ||
}); | ||
if (result[0]) { | ||
return result[0].value; | ||
} | ||
} | ||
} | ||
public pluck(valueKey: string): any { | ||
if (this.values !== undefined && this.values instanceof Array) { | ||
const result = this.values.filter((r: any) => { | ||
return r.code === valueKey; | ||
}); | ||
if (result[0]) { | ||
return result[0].value; | ||
} | ||
} | ||
} | ||
} |
export interface IEmbeddedData { | ||
valueType: string; | ||
start: number; | ||
length: number; | ||
valueType: string; | ||
start: number; | ||
length: number; | ||
} |
export interface IBarcodeValue { | ||
symbology: string; | ||
rawValue: string; | ||
values: any; | ||
errorMessage: string; | ||
success: boolean; | ||
checkDigit: number; | ||
pluck(valueKey: string): any; | ||
symbology: string; | ||
rawValue: string; | ||
values: any; | ||
errorMessage: string; | ||
success: boolean; | ||
checkDigit: number; | ||
pluck(valueKey: string): any; | ||
} |
@@ -1,11 +0,7 @@ | ||
import { BarcodeValue } from './barcode-value'; | ||
import { IBarcodeValue } from './ibarcode-value'; | ||
import { IReaderConfiguration } from './reader.configuration'; | ||
import { IParserConfiguration } from './parser.configuration'; | ||
export { | ||
BarcodeValue, | ||
IBarcodeValue, | ||
IReaderConfiguration, | ||
IParserConfiguration, | ||
}; | ||
export * from './application-identifier'; | ||
export * from './application-identifiers'; | ||
export * from './barcode-value'; | ||
export * from './embedded-data'; | ||
export * from './ibarcode-value'; | ||
export * from './parser.configuration'; | ||
export * from './reader.configuration'; |
import { IReaderConfiguration } from './reader.configuration'; | ||
export interface IParserConfiguration { | ||
readers: string[]; | ||
readerConfigurations: IReaderConfiguration[]; | ||
readers: string[]; | ||
readerConfigurations: IReaderConfiguration[]; | ||
} |
import { IEmbeddedData } from './embedded-data'; | ||
export interface IReaderConfiguration { | ||
symbology: string; | ||
delimiter: string; | ||
identifier: string; | ||
values: IEmbeddedData[]; | ||
symbology: string; | ||
delimiter: string; | ||
identifier: string; | ||
values: IEmbeddedData[]; | ||
} |
import { BaseReader } from './base.reader'; | ||
import { AimParser } from '../utils/aim-parser'; | ||
import { IReaderConfiguration } from '../models/reader.configuration'; | ||
import { IBarcodeValue, BarcodeValue } from '../models'; | ||
import { AimParser } from '../utils'; | ||
import { IBarcodeValue, BarcodeValue, IReaderConfiguration } from '../models'; | ||
export class BaseGtinReader extends BaseReader { | ||
constructor( | ||
symbology: string, | ||
validationExpression: RegExp, | ||
readerConfig?: IReaderConfiguration | ||
) { | ||
super(symbology, validationExpression, readerConfig); | ||
} | ||
constructor( | ||
symbology: string, | ||
validationExpression: any, | ||
protected _length: number, | ||
readerConfig?: IReaderConfiguration) { | ||
public decode(value: string): IBarcodeValue { | ||
const result = new BarcodeValue(this.symbology, value); | ||
try { | ||
this.tryValidate(value); | ||
result.values = this.parseValues(value); | ||
result.checkDigit = this.checkDigit(value); | ||
} catch (ex) { | ||
result.success = false; | ||
result.errorMessage = ex.message; | ||
} | ||
return result; | ||
} | ||
super(symbology, validationExpression, readerConfig); | ||
} | ||
protected checkDigit(value: string): number { | ||
return parseInt(value.substring(value.length - 1), null); | ||
} | ||
public decode(value: string): IBarcodeValue { | ||
const result = new BarcodeValue(this.symbology, value); | ||
try { | ||
this.tryValidate(value); | ||
result.values = this.parseValues(value); | ||
result.checkDigit = this.checkDigit(value); | ||
} catch (ex) { | ||
result.success = false; | ||
result.errorMessage = ex.message; | ||
} | ||
return result; | ||
} | ||
protected checkDigit(value: string): number { | ||
return parseInt(value.substring(value.length - 1), null); | ||
} | ||
protected parseValues(value: string): string { | ||
return AimParser.parseAimCode(this.symbology, value); | ||
} | ||
protected parseValues(value: string): string { | ||
return AimParser.parseAimCode(this.symbology, value); | ||
} | ||
} |
@@ -1,34 +0,33 @@ | ||
import { IReaderConfiguration } from '../models/reader.configuration'; | ||
import { IBarcodeValue } from '../models'; | ||
import { IBarcodeValue, IReaderConfiguration } from '../models'; | ||
export abstract class BaseReader { | ||
constructor( | ||
protected _symbology: string, | ||
protected _validationExpression: RegExp, | ||
protected _readerConfig: IReaderConfiguration | ||
) {} | ||
constructor( | ||
protected _symbology: string, | ||
protected _validationExpression: any, | ||
protected _readerConfig: IReaderConfiguration) {} | ||
public get configuration(): IReaderConfiguration { | ||
return this._readerConfig; | ||
} | ||
public get configuration(): IReaderConfiguration { | ||
return this._readerConfig; | ||
} | ||
public get symbology(): string { | ||
return this._symbology; | ||
} | ||
public get symbology(): string { | ||
return this._symbology; | ||
} | ||
public get validationExpression(): RegExp { | ||
return this._validationExpression; | ||
} | ||
public get validationExpression(): any { | ||
return this._validationExpression; | ||
} | ||
public validate(value: string): boolean { | ||
return this.validationExpression.test(value); | ||
} | ||
public validate(value: string): boolean { | ||
return this.validationExpression.test(value); | ||
} | ||
public abstract decode(value: string): IBarcodeValue; | ||
public abstract decode(value: string): IBarcodeValue; | ||
protected tryValidate(value: string): void { | ||
if (!this.validate(value)) { | ||
throw new Error('Invalid Value'); | ||
} | ||
} | ||
protected tryValidate(value: string): void { | ||
if (!this.validate(value)) { | ||
throw new Error('Invalid Value'); | ||
} | ||
} | ||
} |
@@ -1,95 +0,101 @@ | ||
import { BaseReader } from '../readers/base.reader'; | ||
import { IReaderConfiguration } from '../models/reader.configuration'; | ||
import { IBarcodeValue } from '../models/ibarcode-value'; | ||
import { ApplicationIdentifier } from '../models/application-identifier'; | ||
import { BarcodeValue } from '../models/barcode-value'; | ||
import { APPLICATION_IDENTIFIERS } from '../models/application-identifiers'; | ||
import { CONTROLCHARS } from '../config/control-characters.config'; | ||
import { AIMCODES } from '../config/aim-codes'; | ||
import { AimParser } from '../utils/aim-parser'; | ||
import { BaseReader } from './base.reader'; | ||
import { | ||
APPLICATION_IDENTIFIERS, | ||
IBarcodeValue, | ||
IReaderConfiguration, | ||
ApplicationIdentifier, | ||
BarcodeValue, | ||
} from '../models'; | ||
import { AimCodes, CONTROLCHARS, Symbologies } from '../config'; | ||
import { AimParser } from '../utils'; | ||
const SYMBOLOGY: string = 'code_128'; | ||
const DELIMITER: string = ' '; | ||
export class Code128Reader extends BaseReader { | ||
constructor(readerConfig?: IReaderConfiguration) { | ||
super(Symbologies.Code128, null, readerConfig); | ||
} | ||
constructor(readerConfig?: IReaderConfiguration) { | ||
super(SYMBOLOGY, null, readerConfig); | ||
} | ||
public validate(value: string): boolean { | ||
const idPrefix = value.indexOf(AimCodes.CODE128); | ||
public validate(value: string): boolean { | ||
const valueLength = AimParser.parseAimCode(this.symbology, value) | ||
.length; | ||
return idPrefix === 0 && valueLength > 0; | ||
} | ||
const idPrefix = value.indexOf(AIMCODES.CODE128); | ||
const valueLength = AimParser.parseAimCode(this.symbology, value).length; | ||
return idPrefix === 0 && valueLength > 0; | ||
} | ||
public decode(value: string): IBarcodeValue { | ||
const sterilizedValue = this.removeControlCharacters(value); | ||
const result = new BarcodeValue(this.symbology, value); | ||
try { | ||
this.tryValidate(value); | ||
const valWithoutId = AimParser.parseAimCode( | ||
this.symbology, | ||
sterilizedValue | ||
); | ||
result.values = [].concat.apply( | ||
[], | ||
valWithoutId.split(DELIMITER).map(val => this.parseValues(val)) | ||
); | ||
} catch (ex) { | ||
result.success = false; | ||
result.errorMessage = ex; | ||
} | ||
return result; | ||
} | ||
public decode(value: string): IBarcodeValue { | ||
const sterilizedValue = this.removeControlCharacters(value); | ||
const result = new BarcodeValue(this.symbology, value); | ||
try { | ||
this.tryValidate(value); | ||
const valWithoutId = AimParser.parseAimCode(this.symbology, sterilizedValue); | ||
result.values = [].concat.apply([], valWithoutId.split(DELIMITER).map((val) => this.parseValues(val))); | ||
} catch (ex) { | ||
result.success = false; | ||
result.errorMessage = ex; | ||
} | ||
return result; | ||
} | ||
protected removeControlCharacters(value: string): string { | ||
let result = value; | ||
CONTROLCHARS.forEach(charCode => { | ||
result = result.replace(String.fromCharCode(charCode), DELIMITER); | ||
}); | ||
return result; | ||
} | ||
protected removeControlCharacters(value: string): string { | ||
let result = value; | ||
CONTROLCHARS.forEach((charCode) => { | ||
result = result.replace(String.fromCharCode(charCode), DELIMITER); | ||
}); | ||
return result; | ||
} | ||
protected findAi(value: string): ApplicationIdentifier { | ||
let ai: ApplicationIdentifier = null; | ||
let codeLength = 2; | ||
while (ai === null && codeLength < 5) { | ||
const code = value.substr(0, codeLength); | ||
const ais = APPLICATION_IDENTIFIERS.filter(x => { | ||
return x.code === code; | ||
}); | ||
if (ais.length > 0) { | ||
ai = ais[0]; | ||
} else { | ||
codeLength++; | ||
} | ||
} | ||
return ai; | ||
} | ||
protected findAi(value: string): ApplicationIdentifier { | ||
let ai: ApplicationIdentifier = null; | ||
let codeLength = 2; | ||
while (ai === null && codeLength < 5) { | ||
const code = value.substr(0, codeLength); | ||
const ais = APPLICATION_IDENTIFIERS.filter((x) => { | ||
return x.code === code; | ||
}); | ||
if (ais.length > 0) { | ||
ai = ais[0]; | ||
} else { | ||
codeLength++; | ||
} | ||
} | ||
return ai; | ||
} | ||
protected parseValue(ai: ApplicationIdentifier, input: string): object { | ||
let val: any = null; | ||
if (ai.fractional !== true) { | ||
val = input.substr(ai.code.length, ai.length); | ||
} else { | ||
const scale = Number(input.charAt(ai.code.length)); | ||
const num = input.substr(ai.code.length + 1, ai.length); | ||
protected parseValue(ai: ApplicationIdentifier, input: string): object { | ||
let val: any = null; | ||
if (ai.fractional !== true) { | ||
val = input.substr(ai.code.length, ai.length); | ||
} else { | ||
const scale = Number(input.charAt(ai.code.length)); | ||
const num = input.substr(ai.code.length + 1, ai.length); | ||
val = Number(num) / Math.pow(10, scale); | ||
} | ||
val = Number(num) / Math.pow(10, scale); | ||
} | ||
return { | ||
code: ai.code, | ||
value: val, | ||
}; | ||
} | ||
return { | ||
code: ai.code, | ||
value: val, | ||
}; | ||
} | ||
protected parseValues(input: string): object[] { | ||
let vals = Array<object>(); | ||
const ai = this.findAi(input); | ||
protected parseValues(input: string): object[] { | ||
let vals = Array<object>(); | ||
const ai = this.findAi(input); | ||
if (input.length > ai.totalLength) { | ||
vals = vals.concat(this.parseValues(input.substr(ai.totalLength))); | ||
} | ||
if (input.length > ai.totalLength) { | ||
vals = vals.concat(this.parseValues(input.substr(ai.totalLength))); | ||
} | ||
vals.push(this.parseValue(ai, input)); | ||
vals.push(this.parseValue(ai, input)); | ||
return vals; | ||
} | ||
return vals; | ||
} | ||
} |
import { BaseReader } from './base.reader'; | ||
import { IReaderConfiguration } from '../models/reader.configuration'; | ||
import { IBarcodeValue, BarcodeValue } from '../models'; | ||
import { AIMCODES } from '../config/aim-codes'; | ||
import { AimParser } from '../utils/aim-parser'; | ||
import { IBarcodeValue, IReaderConfiguration, BarcodeValue } from '../models'; | ||
import { AimCodes, Symbologies } from '../config'; | ||
import { AimParser } from '../utils'; | ||
const REG: any = /^[A-Z0-9* \-$%.+\/]{1,43}$/; | ||
const SYMBOLOGY: string = 'code_39'; | ||
const REG: RegExp = /^[A-Z0-9* \-$%.+\/]{1,43}$/; | ||
// todo this should probably eventually move into host app | ||
const defaultConfig = { | ||
values: [ | ||
{ | ||
length: 1, | ||
start: 0, | ||
valueType: 'documentType', | ||
}, | ||
{ | ||
length: 2, | ||
start: -4, | ||
valueType: 'companyId', | ||
}, | ||
{ | ||
length: 2, | ||
start: -2, | ||
valueType: 'locationId', | ||
}, | ||
{ | ||
length: 9, | ||
start: 1, | ||
valueType: 'documentId', | ||
}, | ||
], | ||
} as IReaderConfiguration; | ||
values: [ | ||
{ | ||
length: 1, | ||
start: 0, | ||
valueType: 'documentType', | ||
}, | ||
{ | ||
length: 2, | ||
start: -4, | ||
valueType: 'companyId', | ||
}, | ||
{ | ||
length: 2, | ||
start: -2, | ||
valueType: 'locationId', | ||
}, | ||
{ | ||
length: 9, | ||
start: 1, | ||
valueType: 'documentId', | ||
}, | ||
], | ||
} as IReaderConfiguration; | ||
export class Code39Reader extends BaseReader { | ||
constructor(readerConfig?: IReaderConfiguration) { | ||
const config = readerConfig || defaultConfig; | ||
super(Symbologies.Code39, REG, config); | ||
} | ||
constructor(readerConfig?: IReaderConfiguration) { | ||
const config = readerConfig || defaultConfig; | ||
super(SYMBOLOGY, REG, config); | ||
} | ||
public validate(value: string): boolean { | ||
const aimPrefix = value.indexOf(AimCodes.CODE39); | ||
return ( | ||
aimPrefix === 0 && | ||
super.validate(AimParser.parseAimCode(this.symbology, value)) | ||
); | ||
} | ||
public validate(value: string): boolean { | ||
const aimPrefix = value.indexOf(AIMCODES.CODE39); | ||
return aimPrefix === 0 && super.validate(AimParser.parseAimCode(this.symbology, value)); | ||
} | ||
public decode(value: string): IBarcodeValue { | ||
const result = new BarcodeValue(this.symbology, value); | ||
try { | ||
this.tryValidate(value); | ||
// result.values = this.parseValues(value); | ||
result.values = AimParser.parseAimCode(this.symbology, value); | ||
} catch (ex) { | ||
result.success = false; | ||
result.errorMessage = ex; | ||
} | ||
return result; | ||
} | ||
public decode(value: string): IBarcodeValue { | ||
const result = new BarcodeValue(this.symbology, value); | ||
try { | ||
this.tryValidate(value); | ||
result.values = AimParser.parseAimCode(this.symbology, value); | ||
} catch (ex) { | ||
result.success = false; | ||
result.errorMessage = ex; | ||
} | ||
return result; | ||
} | ||
} |
@@ -1,94 +0,102 @@ | ||
import { BaseReader } from '../readers/base.reader'; | ||
import { IReaderConfiguration } from '../models/reader.configuration'; | ||
import { IBarcodeValue } from '../models/ibarcode-value'; | ||
import { ApplicationIdentifier } from '../models/application-identifier'; | ||
import { BarcodeValue } from '../models/barcode-value'; | ||
import { APPLICATION_IDENTIFIERS } from '../models/application-identifiers'; | ||
import { CONTROLCHARS } from '../config/control-characters.config'; | ||
import { AIMCODES } from '../config/aim-codes'; | ||
import { AimParser } from '../utils/aim-parser'; | ||
import { BaseReader } from './base.reader'; | ||
import { | ||
IReaderConfiguration, | ||
IBarcodeValue, | ||
ApplicationIdentifier, | ||
BarcodeValue, | ||
APPLICATION_IDENTIFIERS, | ||
} from '../models'; | ||
import { CONTROLCHARS, AimCodes, Symbologies } from '../config'; | ||
const SYMBOLOGY: string = 'gs1_128'; | ||
import { AimParser } from '../utils'; | ||
const DELIMITER: string = ' '; | ||
export class GS1Reader extends BaseReader { | ||
constructor(readerConfig?: IReaderConfiguration) { | ||
super(Symbologies.GS1128, null, readerConfig); | ||
} | ||
constructor(readerConfig?: IReaderConfiguration) { | ||
super(SYMBOLOGY, null, readerConfig); | ||
} | ||
public validate(value: string): boolean { | ||
const idPrefix = value.indexOf(AimCodes.GS1); | ||
public validate(value: string): boolean { | ||
const idPrefix = value.indexOf(AIMCODES.GS1); | ||
const valueLength = AimParser.parseAimCode(this.symbology, value).length; | ||
return idPrefix === 0 && valueLength > 0; | ||
} | ||
const valueLength = AimParser.parseAimCode(this.symbology, value) | ||
.length; | ||
return idPrefix === 0 && valueLength > 0; | ||
} | ||
public decode(value: string): IBarcodeValue { | ||
const sterilizedValue = this.removeControlCharacters(value); | ||
const result = new BarcodeValue(this.symbology, value); | ||
try { | ||
this.tryValidate(value); | ||
const valWithoutId = AimParser.parseAimCode(this.symbology, sterilizedValue); | ||
result.values = [].concat.apply([], valWithoutId.split(DELIMITER).map((val) => this.parseValues(val))); | ||
} catch (ex) { | ||
result.success = false; | ||
result.errorMessage = ex; | ||
} | ||
return result; | ||
} | ||
public decode(value: string): IBarcodeValue { | ||
const sterilizedValue = this.removeControlCharacters(value); | ||
const result = new BarcodeValue(this.symbology, value); | ||
try { | ||
this.tryValidate(value); | ||
const valWithoutId = AimParser.parseAimCode( | ||
this.symbology, | ||
sterilizedValue | ||
); | ||
result.values = [].concat.apply( | ||
[], | ||
valWithoutId.split(DELIMITER).map(val => this.parseValues(val)) | ||
); | ||
} catch (ex) { | ||
result.success = false; | ||
result.errorMessage = ex; | ||
} | ||
return result; | ||
} | ||
protected removeControlCharacters(value: string): string { | ||
let result = value; | ||
CONTROLCHARS.forEach((charCode) => { | ||
result = result.replace(String.fromCharCode(charCode), DELIMITER); | ||
}); | ||
return result; | ||
} | ||
protected removeControlCharacters(value: string): string { | ||
let result = value; | ||
CONTROLCHARS.forEach(charCode => { | ||
result = result.replace(String.fromCharCode(charCode), DELIMITER); | ||
}); | ||
return result; | ||
} | ||
protected findAi(value: string): ApplicationIdentifier { | ||
let ai: ApplicationIdentifier = null; | ||
let codeLength = 2; | ||
while (ai === null && codeLength < 5) { | ||
const code = value.substr(0, codeLength); | ||
const ais = APPLICATION_IDENTIFIERS.filter((x) => { | ||
return x.code === code; | ||
}); | ||
if (ais.length > 0) { | ||
ai = ais[0]; | ||
} else { | ||
codeLength++; | ||
} | ||
} | ||
return ai; | ||
} | ||
protected findAi(value: string): ApplicationIdentifier { | ||
let ai: ApplicationIdentifier = null; | ||
let codeLength = 2; | ||
while (ai === null && codeLength < 5) { | ||
const code = value.substr(0, codeLength); | ||
const ais = APPLICATION_IDENTIFIERS.filter(x => { | ||
return x.code === code; | ||
}); | ||
if (ais.length > 0) { | ||
ai = ais[0]; | ||
} else { | ||
codeLength++; | ||
} | ||
} | ||
return ai; | ||
} | ||
protected parseValue(ai: ApplicationIdentifier, input: string): object { | ||
let val: any = null; | ||
if (ai.fractional !== true) { | ||
val = input.substr(ai.code.length, ai.length); | ||
} else { | ||
const scale = Number(input.charAt(ai.code.length)); | ||
const num = input.substr(ai.code.length + 1, ai.length); | ||
protected parseValue(ai: ApplicationIdentifier, input: string): object { | ||
let val: any = null; | ||
if (ai.fractional !== true) { | ||
val = input.substr(ai.code.length, ai.length); | ||
} else { | ||
const scale = Number(input.charAt(ai.code.length)); | ||
const num = input.substr(ai.code.length + 1, ai.length); | ||
val = Number(num) / Math.pow(10, scale); | ||
} | ||
val = Number(num) / Math.pow(10, scale); | ||
} | ||
return { | ||
code: ai.code, | ||
value: val, | ||
}; | ||
} | ||
return { | ||
code: ai.code, | ||
value: val, | ||
}; | ||
} | ||
protected parseValues(input: string): object[] { | ||
let vals = Array<object>(); | ||
const ai = this.findAi(input); | ||
protected parseValues(input: string): object[] { | ||
let vals = Array<object>(); | ||
const ai = this.findAi(input); | ||
if (input.length > ai.totalLength) { | ||
vals = vals.concat(this.parseValues(input.substr(ai.totalLength))); | ||
} | ||
if (input.length > ai.totalLength) { | ||
vals = vals.concat(this.parseValues(input.substr(ai.totalLength))); | ||
} | ||
vals.push(this.parseValue(ai, input)); | ||
vals.push(this.parseValue(ai, input)); | ||
return vals; | ||
} | ||
return vals; | ||
} | ||
} |
@@ -1,13 +0,11 @@ | ||
import { IReaderConfiguration } from '../models/reader.configuration'; | ||
import { IReaderConfiguration } from '../models'; | ||
import { BaseGtinReader } from './base-gtin.reader'; | ||
import { Symbologies } from '../config'; | ||
const REG: any = /^\]E[0-9]{12,12}$/; | ||
const SYMBOLOGY: string = 'gtin_12'; | ||
const LENGTH: number = 12; | ||
const REG: RegExp = /^\]E0[0-9]{12,12}$/; | ||
export class Gtin12Reader extends BaseGtinReader { | ||
constructor(readerConfig?: IReaderConfiguration) { | ||
super(SYMBOLOGY, REG, LENGTH, readerConfig); | ||
} | ||
constructor(readerConfig?: IReaderConfiguration) { | ||
super(Symbologies.GTIN12, REG, readerConfig); | ||
} | ||
} |
@@ -1,13 +0,11 @@ | ||
import { IReaderConfiguration } from '../models/reader.configuration'; | ||
import { IReaderConfiguration } from '../models'; | ||
import { BaseGtinReader } from './base-gtin.reader'; | ||
import { Symbologies } from '../config'; | ||
const REG: any = /^\]E[0-9]{13,13}$/; | ||
const SYMBOLOGY: string = 'gtin_13'; | ||
const LENGTH: number = 13; | ||
const REG: RegExp = /^\]E0[0-9]{13,13}$/; | ||
export class Gtin13Reader extends BaseGtinReader { | ||
constructor(readerConfig?: IReaderConfiguration) { | ||
super(SYMBOLOGY, REG, LENGTH, readerConfig); | ||
} | ||
constructor(readerConfig?: IReaderConfiguration) { | ||
super(Symbologies.GTIN13, REG, readerConfig); | ||
} | ||
} |
@@ -1,13 +0,11 @@ | ||
import { IReaderConfiguration } from '../models/reader.configuration'; | ||
import { IReaderConfiguration } from '../models'; | ||
import { BaseGtinReader } from './base-gtin.reader'; | ||
import { Symbologies } from '../config'; | ||
const REG: any = /^\]E[0-9]{14,14}$/; | ||
const SYMBOLOGY: string = 'gtin_14'; | ||
const LENGTH: number = 14; | ||
const REG: RegExp = /^\]E0[0-9]{14,14}$/; | ||
export class Gtin14Reader extends BaseGtinReader { | ||
constructor(readerConfig?: IReaderConfiguration) { | ||
super(SYMBOLOGY, REG, LENGTH, readerConfig); | ||
} | ||
constructor(readerConfig?: IReaderConfiguration) { | ||
super(Symbologies.GTIN14, REG, readerConfig); | ||
} | ||
} |
@@ -1,13 +0,11 @@ | ||
import { IReaderConfiguration } from '../models/reader.configuration'; | ||
import { IReaderConfiguration } from '../models'; | ||
import { BaseGtinReader } from './base-gtin.reader'; | ||
import { Symbologies } from '../config'; | ||
const REG: any = /^\]E[0-9]{8,8}$/; | ||
const SYMBOLOGY: string = 'gtin_8'; | ||
const LENGTH: number = 8; | ||
const REG: RegExp = /^\]E4[0-9]{8,8}$/; | ||
export class Gtin8Reader extends BaseGtinReader { | ||
constructor(readerConfig?: IReaderConfiguration) { | ||
super(SYMBOLOGY, REG, LENGTH, readerConfig); | ||
} | ||
constructor(readerConfig?: IReaderConfiguration) { | ||
super(Symbologies.GTIN8, REG, readerConfig); | ||
} | ||
} |
@@ -12,43 +12,51 @@ import { Code39Reader } from './code-39.reader'; | ||
import { Code128Reader } from './code-128.reader'; | ||
import { Ean13Reader } from './ean-13.reader'; | ||
import { Ean8Reader } from './ean-8.reader'; | ||
export { | ||
Code39Reader, | ||
Code128Reader, | ||
Gtin8Reader, | ||
Gtin12Reader, | ||
Gtin13Reader, | ||
Gtin14Reader, | ||
Itf8Reader, | ||
Itf12Reader, | ||
Itf13Reader, | ||
Itf14Reader, | ||
GS1Reader, | ||
Code39Reader, | ||
Code128Reader, | ||
Ean8Reader, | ||
Ean13Reader, | ||
Gtin8Reader, | ||
Gtin12Reader, | ||
Gtin13Reader, | ||
Gtin14Reader, | ||
GS1Reader, | ||
Itf8Reader, | ||
Itf12Reader, | ||
Itf13Reader, | ||
Itf14Reader, | ||
}; | ||
export const READERS = [ | ||
Code39Reader, | ||
Code128Reader, | ||
Gtin8Reader, | ||
Gtin12Reader, | ||
Gtin13Reader, | ||
Gtin14Reader, | ||
Itf8Reader, | ||
Itf12Reader, | ||
Itf13Reader, | ||
Itf14Reader, | ||
GS1Reader, | ||
Code39Reader, | ||
Code128Reader, | ||
Ean8Reader, | ||
Ean13Reader, | ||
Gtin8Reader, | ||
Gtin12Reader, | ||
Gtin13Reader, | ||
Gtin14Reader, | ||
GS1Reader, | ||
Itf8Reader, | ||
Itf12Reader, | ||
Itf13Reader, | ||
Itf14Reader, | ||
]; | ||
export const READER_TYPES = { | ||
code_39: Code39Reader, | ||
code_128: Code128Reader, | ||
gs1_128: GS1Reader, | ||
gtin_12: Gtin12Reader, | ||
gtin_13: Gtin13Reader, | ||
gtin_14: Gtin14Reader, | ||
gtin_8: Gtin8Reader, | ||
itf_12: Itf12Reader, | ||
itf_13: Itf13Reader, | ||
itf_14: Itf14Reader, | ||
itf_8: Itf8Reader, | ||
code_39: Code39Reader, | ||
code_128: Code128Reader, | ||
ean_8: Ean8Reader, | ||
ean_13: Ean13Reader, | ||
gs1_128: GS1Reader, | ||
gtin_12: Gtin12Reader, | ||
gtin_13: Gtin13Reader, | ||
gtin_14: Gtin14Reader, | ||
gtin_8: Gtin8Reader, | ||
itf_12: Itf12Reader, | ||
itf_13: Itf13Reader, | ||
itf_14: Itf14Reader, | ||
itf_8: Itf8Reader, | ||
}; |
@@ -1,13 +0,11 @@ | ||
import { IReaderConfiguration } from '../models/reader.configuration'; | ||
import { IReaderConfiguration } from '../models'; | ||
import { BaseGtinReader } from './base-gtin.reader'; | ||
import { Symbologies } from '../config'; | ||
const REG: any = /^\]I0[0-9]{12,12}$/; | ||
const SYMBOLOGY: string = 'itf_12'; | ||
const LENGTH: number = 12; | ||
const REG: RegExp = /^\]I0[0-9]{12,12}$/; | ||
export class Itf12Reader extends BaseGtinReader { | ||
constructor(readerConfig?: IReaderConfiguration) { | ||
super(SYMBOLOGY, REG, LENGTH, readerConfig); | ||
} | ||
constructor(readerConfig?: IReaderConfiguration) { | ||
super(Symbologies.ITF12, REG, readerConfig); | ||
} | ||
} |
@@ -1,13 +0,11 @@ | ||
import { IReaderConfiguration } from '../models/reader.configuration'; | ||
import { IReaderConfiguration } from '../models'; | ||
import { BaseGtinReader } from './base-gtin.reader'; | ||
import { Symbologies } from '../config'; | ||
const REG: any = /^\]I0[0-9]{13,13}$/; | ||
const SYMBOLOGY: string = 'itf_13'; | ||
const LENGTH: number = 13; | ||
const REG: RegExp = /^\]I0[0-9]{13,13}$/; | ||
export class Itf13Reader extends BaseGtinReader { | ||
constructor(readerConfig?: IReaderConfiguration) { | ||
super(SYMBOLOGY, REG, LENGTH, readerConfig); | ||
} | ||
constructor(readerConfig?: IReaderConfiguration) { | ||
super(Symbologies.ITF13, REG, readerConfig); | ||
} | ||
} |
@@ -1,13 +0,11 @@ | ||
import { IReaderConfiguration } from '../models/reader.configuration'; | ||
import { IReaderConfiguration } from '../models'; | ||
import { BaseGtinReader } from './base-gtin.reader'; | ||
import { Symbologies } from '../config'; | ||
const REG: any = /^\]I0[0-9]{14,14}$/; | ||
const SYMBOLOGY: string = 'itf_14'; | ||
const LENGTH: number = 14; | ||
const REG: RegExp = /^\]I0[0-9]{14,14}$/; | ||
export class Itf14Reader extends BaseGtinReader { | ||
constructor(readerConfig?: IReaderConfiguration) { | ||
super(SYMBOLOGY, REG, LENGTH, readerConfig); | ||
} | ||
constructor(readerConfig?: IReaderConfiguration) { | ||
super(Symbologies.ITF14, REG, readerConfig); | ||
} | ||
} |
@@ -1,13 +0,11 @@ | ||
import { IReaderConfiguration } from '../models/reader.configuration'; | ||
import { IReaderConfiguration } from '../models'; | ||
import { BaseGtinReader } from './base-gtin.reader'; | ||
import { Symbologies } from '../config'; | ||
const REG: any = /^\]I0[0-9]{8,8}$/; | ||
const SYMBOLOGY: string = 'itf_8'; | ||
const LENGTH: number = 8; | ||
const REG: RegExp = /^\]I0[0-9]{8,8}$/; | ||
export class Itf8Reader extends BaseGtinReader { | ||
constructor(readerConfig?: IReaderConfiguration) { | ||
super(SYMBOLOGY, REG, LENGTH, readerConfig); | ||
} | ||
constructor(readerConfig?: IReaderConfiguration) { | ||
super(Symbologies.ITF8, REG, readerConfig); | ||
} | ||
} |
@@ -1,36 +0,1 @@ | ||
import { Symbologies } from './../config/symbologies'; | ||
import { AIMCODES } from '../config/aim-codes'; | ||
export class AimParser { | ||
public static parseAimCode(symbology: string, value: string): string { | ||
switch (symbology) { | ||
case Symbologies.GTIN8: | ||
return value.replace(AIMCODES.GTIN, ''); | ||
case Symbologies.GTIN12: | ||
return value.replace(AIMCODES.GTIN, ''); | ||
case Symbologies.GTIN13: | ||
return value.replace(AIMCODES.GTIN, ''); | ||
case Symbologies.GTIN14: | ||
return value.replace(AIMCODES.GTIN, ''); | ||
case Symbologies.ITF8: | ||
return value.replace(AIMCODES.ITF, ''); | ||
case Symbologies.ITF12: | ||
return value.replace(AIMCODES.ITF, ''); | ||
case Symbologies.ITF13: | ||
return value.replace(AIMCODES.ITF, ''); | ||
case Symbologies.ITF14: | ||
return value.replace(AIMCODES.ITF, ''); | ||
case Symbologies.GS1128: | ||
return value.replace(AIMCODES.GS1, ''); | ||
case Symbologies.Code39: | ||
return value.replace(AIMCODES.CODE39, ''); | ||
case Symbologies.Code128: | ||
return value.replace(AIMCODES.CODE128, ''); | ||
default: | ||
return value; | ||
} | ||
} | ||
} | ||
import { AimCodes, Symbologies } from './../config'; export class AimParser { public static parseAimCode(symbology: string, value: string): string { switch (symbology) { case Symbologies.GTIN8: return value.replace(AimCodes.GTIN, ''); case Symbologies.GTIN12: return value.replace(AimCodes.GTIN, ''); case Symbologies.GTIN13: return value.replace(AimCodes.GTIN, ''); case Symbologies.GTIN14: return value.replace(AimCodes.GTIN, ''); case Symbologies.ITF8: return value.replace(AimCodes.ITF, ''); case Symbologies.ITF12: return value.replace(AimCodes.ITF, ''); case Symbologies.ITF13: return value.replace(AimCodes.ITF, ''); case Symbologies.ITF14: return value.replace(AimCodes.ITF, ''); case Symbologies.GS1128: return value.replace(AimCodes.GS1, ''); case Symbologies.Code39: return value.replace(AimCodes.CODE39, ''); case Symbologies.Code128: return value.replace(AimCodes.CODE128, ''); default: return value; } } } |
@@ -0,0 +0,0 @@ { |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
356264
12
62
2416