UNPKG

@opra/common

Version:
29 lines (28 loc) 939 B
import { omitUndefined } from '@jsopen/objects'; import { CLASS_NAME_PATTERN } from '../constants.js'; import { DocumentElement } from './document-element.js'; export class ApiBase extends DocumentElement { name = 'OpraApi'; description; constructor(init) { super(init.owner); this.name = init.name; this.description = init.description; } // eslint-disable-next-line @typescript-eslint/no-unused-vars toJSON(options) { return omitUndefined({ transport: this.transport, name: this.name, description: this.description, }); } async _initialize(init, // eslint-disable-next-line @typescript-eslint/no-unused-vars context) { if (!CLASS_NAME_PATTERN.test(init.name)) throw new TypeError(`Invalid api name (${init.name})`); this.name = init.name; this.description = init?.description; } }