UNPKG

@opra/common

Version:
41 lines (40 loc) 1.4 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.RpcHeader = void 0; const objects_1 = require("@jsopen/objects"); const ts_gems_1 = require("ts-gems"); const value_js_1 = require("../common/value.js"); const parse_regexp_util_js_1 = require("../utils/parse-regexp.util.js"); exports.RpcHeader = function (owner, initArgs) { if (!this) throw new TypeError('"this" should be passed to call class constructor'); value_js_1.Value.call(this, owner, initArgs); const _this = (0, ts_gems_1.asMutable)(this); if (initArgs.name) { _this.name = initArgs.name instanceof RegExp ? initArgs.name : initArgs.name.startsWith('/') ? (0, parse_regexp_util_js_1.parseRegExp)(initArgs.name, { includeFlags: 'i', excludeFlags: 'm', }) : initArgs.name; } _this.deprecated = initArgs.deprecated; _this.required = initArgs.required; }; /** * @class RpcHeader */ class RpcHeaderClass extends value_js_1.Value { toJSON() { return (0, objects_1.omitUndefined)({ ...super.toJSON(), name: this.name, required: this.required, deprecated: this.deprecated, }); } } exports.RpcHeader.prototype = RpcHeaderClass.prototype;