@opra/common
Version:
Opra common package
46 lines (45 loc) • 1.47 kB
JavaScript
import { omitUndefined } from '@jsopen/objects';
import { asMutable, } from 'ts-gems';
import { vg } from 'valgen';
import { Value } from '../common/value.js';
import { parseRegExp } from '../utils/parse-regexp.util.js';
export const MQHeader = function (owner, initArgs) {
if (!this)
throw new TypeError('"this" should be passed to call class constructor');
Value.call(this, owner, initArgs);
const _this = asMutable(this);
if (initArgs.name) {
_this.name =
initArgs.name instanceof RegExp
? initArgs.name
: initArgs.name.startsWith('/')
? parseRegExp(initArgs.name, {
includeFlags: 'i',
excludeFlags: 'm',
})
: initArgs.name;
}
_this.deprecated = initArgs.deprecated;
_this.required = initArgs.required;
_this.designType = initArgs.designType;
};
/**
* @class MQHeader
*/
class MQHeaderClass extends Value {
toJSON() {
return omitUndefined({
...super.toJSON(),
name: this.name,
required: this.required,
deprecated: this.deprecated,
});
}
generateCodec(codec, options, properties) {
return (this.type?.generateCodec(codec, options, {
...properties,
designType: this.designType,
}) || vg.isAny());
}
}
MQHeader.prototype = MQHeaderClass.prototype;