@configurator/ravendb
Version:
RavenDB client for Node.js
44 lines • 1.3 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.definedDate = exports.rightDate = exports.leftDate = exports.DatesComparator = void 0;
const Exceptions_1 = require("../Exceptions");
class DatesComparator {
static compare(lhs, rhs) {
if (lhs.date && rhs.date) {
return lhs.date.getTime() - rhs.date.getTime();
}
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;
function leftDate(date) {
return {
date,
context: "From"
};
}
exports.leftDate = leftDate;
function rightDate(date) {
return {
date,
context: "To"
};
}
exports.rightDate = rightDate;
function definedDate(date) {
if (!date) {
(0, Exceptions_1.throwError)("InvalidArgumentException", "Date cannot be null");
}
return {
date,
context: "To"
};
}
exports.definedDate = definedDate;
//# sourceMappingURL=DatesComparator.js.map