UNPKG

@opra/common

Version:
50 lines (49 loc) 1.82 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.HttpParameter = 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.HttpParameter = 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.location = initArgs.location; _this.deprecated = initArgs.deprecated; _this.required = initArgs.required; if (_this.required == null && initArgs.location === 'path') _this.required = true; _this.arraySeparator = initArgs.arraySeparator; _this.keyParam = initArgs.keyParam; _this.parser = initArgs.parser; }; /** * @class HttpParameter */ class HttpParameterClass extends value_js_1.Value { toJSON(options) { return (0, objects_1.omitUndefined)({ ...super.toJSON(options), name: this.name, location: this.location, arraySeparator: this.arraySeparator, keyParam: this.keyParam, required: this.required, deprecated: this.deprecated, }); } } exports.HttpParameter.prototype = HttpParameterClass.prototype;