UNPKG

specpress

Version:

Export PDF and/or DOCX files from a subset of Markdown, ASN.1 and JSON files

34 lines 1.31 kB
// SubcarrierSpacing.ts — Subcarrier Spacing with validation import { IsInt } from "./Utils.js"; ////////////////////////////// // Constants export const VALID_SCS_VALUES = [15, 30, 60, 120, 240, 480, 960]; ////////////////////////////// // Exceptions export class InvalidScsException extends Error { constructor(message) { super(message); this.name = "InvalidScsException"; } } export class SCS { value; constructor(aValue) { if (aValue === null || aValue === undefined) { throw new InvalidScsException("The SCS shall not be None"); } if (aValue instanceof SCS) { this.value = aValue.value; return; } if (!IsInt(aValue)) { throw new InvalidScsException(`The SCS shall be an interger number but was ${aValue} (${typeof aValue})`); } const n = typeof aValue === "number" ? aValue : parseInt(String(aValue), 10); if (!VALID_SCS_VALUES.includes(n)) { throw new InvalidScsException(`The SCS must be one of ${VALID_SCS_VALUES} but was ${aValue}.`); } this.value = n; } valueOf() { return this.value; } toString() { return `${this.value}`; } equals(other) { return this.value === other.value; } } //# sourceMappingURL=SubcarrierSpacing.js.map