UNPKG

@drift-labs/common

Version:

Common functions for Drift

27 lines 898 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.SlotBasedResultValidator = void 0; /** * Utility class which makes sure that all results with a slot are only accepted if the slot is higher than the previous result */ class SlotBasedResultValidator { constructor(allowUndefined = true) { this.resultIncrements = new Map(); this.allowUndefined = allowUndefined; } handleResult(key, slot) { if (slot === undefined) { return this.allowUndefined; } const previous = this.resultIncrements.get(key); if (!previous || slot >= previous) { this.resultIncrements.set(key, slot); return true; } else { return false; } } } exports.SlotBasedResultValidator = SlotBasedResultValidator; //# sourceMappingURL=SlotBasedResultValidator.js.map