UNPKG

ravendb

Version:
51 lines 1.37 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.DatesComparator = void 0; exports.leftDate = leftDate; exports.rightDate = rightDate; exports.definedDate = definedDate; const index_js_1 = require("../Exceptions/index.js"); class DatesComparator { static compare(lhs, rhs) { if (lhs.date && rhs.date) { return lhs.date.getTime() - rhs.date.getTime(); } // lhr or rhs is null - unify values using context const leftValue = lhs.date ? lhs.date.getTime() : (lhs.context === "From" ? Number.MIN_SAFE_INTEGER : Number.MAX_SAFE_INTEGER); const rightValue = rhs.date ? rhs.date.getTime() : (rhs.context === "From" ? Number.MIN_SAFE_INTEGER : Number.MAX_SAFE_INTEGER); return leftValue - rightValue; } } exports.DatesComparator = DatesComparator; /** * Date or MinDate if null */ function leftDate(date) { return { date, context: "From" }; } /** * Date or MaxDate if null */ function rightDate(date) { return { date, context: "To" }; } function definedDate(date) { if (!date) { (0, index_js_1.throwError)("InvalidArgumentException", "Date cannot be null"); } return { date, context: "To" }; } //# sourceMappingURL=DatesComparator.js.map