@opra/common
Version:
Opra common package
40 lines (39 loc) • 1.42 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.Value = void 0;
const objects_1 = require("@jsopen/objects");
const ts_gems_1 = require("ts-gems");
const document_element_js_1 = require("./document-element.js");
exports.Value = function (owner, initArgs) {
if (!this)
throw new TypeError('"this" should be passed to call class constructor');
document_element_js_1.DocumentElement.call(this, owner);
// if (args.name && !PARAMETER_NAME_PATTERN.test(args.name))
// throw new TypeError(`"${args.name}" is not a valid parameter name`);
const _this = (0, ts_gems_1.asMutable)(this);
_this.description = initArgs.description;
_this.type = initArgs.type;
_this.examples = initArgs.examples;
_this.isArray = initArgs.isArray;
};
/**
* @class Value
*/
class ValueClass extends document_element_js_1.DocumentElement {
toJSON(options) {
const typeName = this.type
? this.node.getDataTypeNameWithNs(this.type)
: undefined;
return (0, objects_1.omitUndefined)({
type: this.type
? typeName
? typeName
: this.type.toJSON(options)
: 'any',
description: this.description,
isArray: this.isArray,
examples: this.examples,
});
}
}
exports.Value.prototype = ValueClass.prototype;