dynamicsmobile
Version:
Allows development of off-line mobile and web business apps over the Dynamics Mobile platform. More info on https://www.dynamicsmobile.com
85 lines • 3.5 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.BarcodeParser = exports.BarcodeMaskSegmentDetectonType = exports.BarcodeMaskDetectionType = void 0;
var BarcodeMaskDetectionType;
(function (BarcodeMaskDetectionType) {
BarcodeMaskDetectionType[BarcodeMaskDetectionType["LeadingChar"] = 0] = "LeadingChar";
BarcodeMaskDetectionType[BarcodeMaskDetectionType["BarcodeLength"] = 1] = "BarcodeLength";
})(BarcodeMaskDetectionType || (exports.BarcodeMaskDetectionType = BarcodeMaskDetectionType = {}));
var BarcodeMaskSegmentDetectonType;
(function (BarcodeMaskSegmentDetectonType) {
BarcodeMaskSegmentDetectonType[BarcodeMaskSegmentDetectonType["Delimiter"] = 0] = "Delimiter";
BarcodeMaskSegmentDetectonType[BarcodeMaskSegmentDetectonType["Length"] = 1] = "Length";
})(BarcodeMaskSegmentDetectonType || (exports.BarcodeMaskSegmentDetectonType = BarcodeMaskSegmentDetectonType = {}));
class BarcodeParser {
constructor(settings) {
this.settings = settings;
}
parse(barcode) {
return null;
// if(!this.settings || !this.settings.masks || this.settings.masks.length==0 || !barcode){
// return {
// mask: null,
// raw: null,
// detectedSegments: []
// };
// }
// const activeMask = this.detectMask(barcode, this.settings);
// if (!activeMask){
// return {
// mask: null,
// raw: barcode,
// detectedSegments: []
// };
// }
// if(!activeMask.segments || activeMask.segments.length==0){
// throw `Mask ${activeMask.name} does not have segments!`;
// }
// const parsedResult = {
// mask: activeMask,
// detectedSegments: [],
// raw: barcode
// };
// switch(activeMask.segmentDetectionType){
// case BarcodeMaskSegmentDetectonType.Delimiter:
// break;
// case BarcodeMaskSegmentDetectonType.Length:
// const rawBarcode = activeMask.maskLengthIncludeLeadingChar?barcode.substr(1):barcode.substr(0);
// for(let i=0;i<segments.length;i++)(
// rawBarcode.sub
// parsedResult.detectedSegments.push(s.length);
// })
// break;
// }
// return {
// mask: activeMask,
// detectedSegments: [],
// raw: barcode
// }
}
detectMask(barcode, settings) {
return null;
// let activeMask;
// const firstChar = barcode[0];
// settings.masks.forEach(m => {
// if (m.maskDetectionType == BarcodeMaskDetectionType.LeadingChar) {
// if (m.charToActivate == firstChar) {
// activeMask = m;
// }
// }
// });
// if (!activeMask) {
// settings.masks.forEach(m => {
// if (m.maskDetectionType == BarcodeMaskDetectionType.BarcodeLength) {
// const maskLen = m.maskLengthIncludeLeadingChar ? m.length : m.length - 1;
// if (maskLen == barcode.length) {
// activeMask = m;
// }
// }
// });
// }
// return activeMask;
}
}
exports.BarcodeParser = BarcodeParser;
//# sourceMappingURL=barcodeparser.js.map