jspurefix
Version:
pure node js fix engine
61 lines • 2.35 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ParseProgress = void 0;
const parse_state_1 = require("./parse-state");
class ParseProgress {
constructor() {
this.parseState = parse_state_1.ParseState.Begin;
this.numberPasses = 0;
this.cacheMisses = 0;
this.newDefines = 0;
this.newAdds = 0;
this.newContexts = 0;
this.previousDelta = 0;
this.componentPasses = 0;
this.maxIterations = 5;
this.groupDefinitionCache = new Map();
}
toString() {
return `parseState = ${this.parseState}, numberPasses = ${this.numberPasses}, componentPasses = ${this.componentPasses}, groupCount = ${this.groupDefinitionCache.size}, cacheMisses = ${this.cacheMisses}, newContexts = ${this.newContexts}, newDefines = ${this.newDefines}, newAdds = ${this.newAdds}, previousDelta = ${this.previousDelta}, delta = ${this.delta()}, changed = ${this.changed()}`;
}
delta() {
return this.newDefines + this.newAdds + this.newContexts;
}
changed() {
return this.cacheMisses > 0 || this.delta() !== this.previousDelta;
}
reset() {
this.previousDelta = this.delta();
this.cacheMisses = 0;
this.newDefines = 0;
this.newAdds = 0;
this.newContexts = 0;
}
next() {
this.numberPasses++;
switch (this.parseState) {
case parse_state_1.ParseState.Begin: {
this.parseState = parse_state_1.ParseState.FieldDefinitions;
break;
}
case parse_state_1.ParseState.FieldDefinitions: {
this.parseState = parse_state_1.ParseState.Components;
break;
}
case parse_state_1.ParseState.Components: {
this.componentPasses++;
const endComponentPass = this.numberPasses > this.maxIterations;
if (endComponentPass) {
this.parseState = parse_state_1.ParseState.Messages;
}
break;
}
case parse_state_1.ParseState.Messages: {
this.parseState = parse_state_1.ParseState.End;
break;
}
}
}
}
exports.ParseProgress = ParseProgress;
//# sourceMappingURL=parse-progress.js.map