UNPKG

@regionorebrolan/extensions

Version:
74 lines 3.34 kB
"use strict"; var __extends = (this && this.__extends) || (function () { var extendStatics = function (d, b) { extendStatics = Object.setPrototypeOf || ({ __proto__: [] } instanceof Array && function (d, b) { d.__proto__ = b; }) || function (d, b) { for (var p in b) if (b.hasOwnProperty(p)) d[p] = b[p]; }; return extendStatics(d, b); }; return function (d, b) { extendStatics(d, b); function __() { this.constructor = d; } d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __()); }; })(); var __importDefault = (this && this.__importDefault) || function (mod) { return (mod && mod.__esModule) ? mod : { "default": mod }; }; Object.defineProperty(exports, "__esModule", { value: true }); var ContentReference_1 = __importDefault(require("../ContentReference")); var QueryValueComparer_1 = __importDefault(require("../../Collections/QueryValueComparer")); var QueryValueComparer = /** @class */ (function (_super) { __extends(QueryValueComparer, _super); // Constructors function QueryValueComparer(caseInsensitive, contentReferenceComparer, contentReferenceParser) { var _this = this; if (!contentReferenceComparer) throw new Error("The content-reference-comparer can not be null."); if (!contentReferenceParser) throw new Error("The content-reference-parser can not be null."); _this = _super.call(this, caseInsensitive) || this; _this._contentReferenceComparer = contentReferenceComparer; _this._contentReferenceParser = contentReferenceParser; return _this; } Object.defineProperty(QueryValueComparer.prototype, "contentReferenceComparer", { // Properties get: function () { return this._contentReferenceComparer; }, enumerable: false, configurable: true }); Object.defineProperty(QueryValueComparer.prototype, "contentReferenceParser", { get: function () { return this._contentReferenceParser; }, enumerable: false, configurable: true }); // Methods QueryValueComparer.prototype.compareInternal = function (first, second) { first = this.tryGetValueAsContentReference(first); second = this.tryGetValueAsContentReference(second); if (first && first instanceof ContentReference_1.default) { if (second && second instanceof ContentReference_1.default) return this.contentReferenceComparer.compare(first, second); return -1; } if (second && second instanceof ContentReference_1.default) return 1; return _super.prototype.compareInternal.call(this, first, second); }; QueryValueComparer.prototype.tryGetValueAsContentReference = function (value) { if (value && typeof value === "string") { var parseResult = this.contentReferenceParser.parse(value); if (parseResult.valid) return parseResult.value; } return value; }; return QueryValueComparer; }(QueryValueComparer_1.default)); exports.default = QueryValueComparer; //# sourceMappingURL=QueryValueComparer.js.map