@regionorebrolan/extensions
Version:
Library with JavaScript additions and extensions.
67 lines • 3.03 kB
JavaScript
;
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 BasicComparer_1 = __importDefault(require("../../Collections/BasicComparer"));
var Utility_1 = __importDefault(require("../../Utility"));
var ContentReferenceComparer = /** @class */ (function (_super) {
__extends(ContentReferenceComparer, _super);
// Constructors
function ContentReferenceComparer(providerComparer, versionInsensitive) {
var _this = _super.call(this) || this;
if (Utility_1.default.isNullOrUndefined(providerComparer))
throw new Error("The provider-comparer can not be null.");
_this._providerComparer = providerComparer;
_this._versionInsensitive = versionInsensitive;
return _this;
}
Object.defineProperty(ContentReferenceComparer.prototype, "providerComparer", {
// Properties
get: function () {
return this._providerComparer;
},
enumerable: false,
configurable: true
});
Object.defineProperty(ContentReferenceComparer.prototype, "versionInsensitive", {
get: function () {
return this._versionInsensitive;
},
enumerable: false,
configurable: true
});
// Methods
ContentReferenceComparer.prototype.compareInternal = function (first, second) {
var compare = this.providerComparer.compare(first.provider || "", second.provider || "");
if (compare !== 0)
return compare;
var firstId = first.id;
var secondId = second.id;
compare = firstId - secondId;
if (this.versionInsensitive || compare !== 0)
return compare;
var firstVersion = !Utility_1.default.isNullOrUndefined(first.version) ? first.version : 0;
var secondVersion = !Utility_1.default.isNullOrUndefined(second.version) ? second.version : 0;
return firstVersion - secondVersion;
};
ContentReferenceComparer.prototype.equalsInternal = function (first, second) {
return this.compareInternal(first, second) === 0;
};
return ContentReferenceComparer;
}(BasicComparer_1.default));
exports.default = ContentReferenceComparer;
//# sourceMappingURL=ContentReferenceComparer.js.map