@jbouduin/holidays-lib
Version:
Get World-Wide Holidays
53 lines (52 loc) • 2.24 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 (Object.prototype.hasOwnProperty.call(b, p)) d[p] = b[p]; };
return extendStatics(d, b);
};
return function (d, b) {
if (typeof b !== "function" && b !== null)
throw new TypeError("Class extends value " + String(b) + " is not a constructor or null");
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.IslamicFactory = void 0;
var errors_1 = require("../errors");
var holidays_1 = require("../holidays");
var types_1 = require("../types");
var base_factory_1 = require("./base-factory");
var IslamicFactory = /** @class */ (function (_super) {
__extends(IslamicFactory, _super);
//#region Constructor & C°
function IslamicFactory() {
return _super.call(this) || this;
}
//#endregion
//#region Abstract methods implementation
IslamicFactory.prototype.createHoliday = function (key, category, cycle, validFrom, validTo) {
return new holidays_1.IslamicHoliday(key, category, cycle, validFrom, validTo);
};
// eslint-disable-next-line @typescript-eslint/no-unused-vars
IslamicFactory.prototype.extractData = function (_obj) {
// nothing to do here
};
IslamicFactory.prototype.extractKey = function (obj) {
var result = types_1.IslamicHolidayType[obj.key];
if (!result && result !== 0) {
if (!obj.key) {
this.addError(errors_1.ErrorKey.ISLAMIC_TYPE_MISSING);
}
else {
this.addError(errors_1.ErrorKey.ISLAMIC_TYPE_INVALID, obj.key);
}
}
return result;
};
return IslamicFactory;
}(base_factory_1.BaseFactory));
exports.IslamicFactory = IslamicFactory;