@securecall/client-component
Version:
SecureCall Core Web Component
46 lines (45 loc) • 1.55 kB
JavaScript
export class MetadataField {
_name;
_value;
constructor() {
this._name = 'metadata';
this._value = {};
return new Proxy(this, {
get(target, prop, receiver) {
const propStr = prop.toString();
const methods = Object.getOwnPropertyNames(Object.getPrototypeOf(target)).concat(Object.getOwnPropertyNames(target));
// console.log('** metadata get:', propStr, methods)
if (methods.includes(propStr)) {
return Reflect.get(target, prop, receiver);
}
else {
return target.rawValue[propStr];
}
},
set(target, prop, v, receiver) {
const propStr = prop.toString();
const methods = Object.getOwnPropertyNames(Object.getPrototypeOf(target)).concat(Object.getOwnPropertyNames(target));
// console.log('** metadata set:', propStr, methods)
if (methods.includes(propStr)) {
return Reflect.set(target, prop, v, receiver);
}
else {
target.rawValue[propStr] = v;
return true;
}
}
});
}
toJSON() {
return {
[this._name]: this.calculatedValue()
};
}
calculatedValue() {
return { value: this._value };
}
get rawValue() {
return this._value;
}
}
//# sourceMappingURL=metadata_field.js.map