chevrotain
Version:
Chevrotain is a high performance fault tolerant javascript parsing DSL for building recursive decent parsers
34 lines • 1.15 kB
JavaScript
Object.defineProperty(exports, "__esModule", { value: true });
exports.isValidRange = exports.Range = void 0;
var Range = /** @class */ (function () {
function Range(start, end) {
this.start = start;
this.end = end;
if (!isValidRange(start, end)) {
throw new Error("INVALID RANGE");
}
}
Range.prototype.contains = function (num) {
return this.start <= num && this.end >= num;
};
Range.prototype.containsRange = function (other) {
return this.start <= other.start && this.end >= other.end;
};
Range.prototype.isContainedInRange = function (other) {
return other.containsRange(this);
};
Range.prototype.strictlyContainsRange = function (other) {
return this.start < other.start && this.end > other.end;
};
Range.prototype.isStrictlyContainedInRange = function (other) {
return other.strictlyContainsRange(this);
};
return Range;
}());
exports.Range = Range;
function isValidRange(start, end) {
return !(start < 0 || end < start);
}
exports.isValidRange = isValidRange;
//# sourceMappingURL=range.js.map
;