Erster Commit
This commit is contained in:
46
node_modules/ts-edifact/lib/edi/unecePageParser.js
generated
vendored
Normal file
46
node_modules/ts-edifact/lib/edi/unecePageParser.js
generated
vendored
Normal file
@@ -0,0 +1,46 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.UNECEPageParser = void 0;
|
||||
const htmlparser2_1 = require("htmlparser2");
|
||||
const uneceDomHandler_1 = require("./uneceDomHandler");
|
||||
const tsm_1 = require("@initics/tsm");
|
||||
const util_1 = require("../util");
|
||||
class UNECEPageParser {
|
||||
constructor(smdef) {
|
||||
this.sm = new tsm_1.StateMachine(smdef);
|
||||
}
|
||||
get spec() {
|
||||
if (!this._spec) {
|
||||
throw new Error(`EdifactMessageSpecification not defined`);
|
||||
}
|
||||
return this._spec;
|
||||
}
|
||||
parse(page) {
|
||||
const parser = new htmlparser2_1.Parser(this.setupHandler());
|
||||
parser.write(page);
|
||||
parser.end();
|
||||
}
|
||||
setupHandler() {
|
||||
return new class extends uneceDomHandler_1.UNECEDomHandler {
|
||||
onOpenTag() {
|
||||
}
|
||||
onText() {
|
||||
}
|
||||
}();
|
||||
}
|
||||
extractTextValue(text, regex, index = 0) {
|
||||
const arr = regex.exec(text);
|
||||
if ((0, util_1.isDefined)(arr)) {
|
||||
return arr[index];
|
||||
}
|
||||
return "";
|
||||
}
|
||||
throwInvalidParserState(state) {
|
||||
throw new Error(`Invalid parser state: ${state}`);
|
||||
}
|
||||
throwCouldNotParsePage() {
|
||||
throw new Error('Could not parse page');
|
||||
}
|
||||
}
|
||||
exports.UNECEPageParser = UNECEPageParser;
|
||||
//# sourceMappingURL=unecePageParser.js.map
|
||||
Reference in New Issue
Block a user