UNPKG

@johanblumenberg/ts-mockito

Version:
46 lines 1.75 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 __()); }; })(); Object.defineProperty(exports, "__esModule", { value: true }); exports.isValidDate = exports.InvalidDateError = exports.DateMatcher = void 0; var Matcher_1 = require("../Matcher"); var DateMatcher = (function (_super) { __extends(DateMatcher, _super); function DateMatcher(date) { var _this = _super.call(this) || this; _this.date = new Date(date); if (!isValidDate(_this.date)) { throw new InvalidDateError(date); } return _this; } return DateMatcher; }(Matcher_1.Matcher)); exports.DateMatcher = DateMatcher; var InvalidDateError = (function (_super) { __extends(InvalidDateError, _super); function InvalidDateError(date) { var _this = _super.call(this, "Invalid date: " + date) || this; _this.name = _this.constructor.name; Object.setPrototypeOf(_this, InvalidDateError.prototype); return _this; } return InvalidDateError; }(Error)); exports.InvalidDateError = InvalidDateError; function isValidDate(date) { return !Number.isNaN(date.getTime()); } exports.isValidDate = isValidDate; //# sourceMappingURL=DateMatcher.js.map