UNPKG

emsi-lib

Version:

A EMSI (Emergency Management Shared Information) object model to manipulate emergency messages defined in ISO/TR 22351 document

58 lines (57 loc) 2.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RType = void 0; const config_1 = require("../../common/config"); const default_1 = require("../../common/default"); const resource_error_1 = require("../../error/resource.error"); class RType extends default_1.Default { constructor(classes) { classes.forEach((add) => resource_error_1.ResourceError.checkLength(add, config_1.MAX_RTYPE_LENGTH)); super(); this.class = classes; } addCapability(capabilities) { capabilities.forEach((add) => resource_error_1.ResourceError.checkLength(add, config_1.MAX_RTYPE_LENGTH)); if (!this.capability) this.capability = new Array(); this.capability.push(...capabilities); return this; } addCharacteristics(characteristics) { characteristics.forEach((add) => resource_error_1.ResourceError.checkLength(add, config_1.MAX_RTYPE_LENGTH)); if (!this.characteristics) this.characteristics = new Array(); this.characteristics.push(...characteristics); return this; } static default() { return new RType(['']); } assign(source) { let key; const keys = Object.keys(source); if ((key = keys.find(f => f === 'class'))) { this.class = new Array(); if (source[key] instanceof Array) source[key].forEach((add) => { var _a; return (_a = this.class) === null || _a === void 0 ? void 0 : _a.push(add); }); else this.class.push(source[key]); } if ((key = keys.find(f => f === 'capability'))) { this.capability = new Array(); if (source[key] instanceof Array) source[key].forEach((add) => { var _a; return (_a = this.capability) === null || _a === void 0 ? void 0 : _a.push(add); }); else this.capability.push(source[key]); } if ((key = keys.find(f => f === 'characteristics'))) { this.characteristics = new Array(); if (source[key] instanceof Array) source[key].forEach((add) => { var _a; return (_a = this.characteristics) === null || _a === void 0 ? void 0 : _a.push(add); }); else this.characteristics.push(source[key]); } return this; } } exports.RType = RType;