Relaxed enum value

This commit is contained in:
barsdeveloper
2023-04-26 22:56:46 +02:00
parent 53c28e7049
commit d97f1f39d7
8 changed files with 91 additions and 25 deletions

View File

@@ -0,0 +1,37 @@
import IEntity from "./IEntity.js"
/** @typedef {import("./IEntity.js").EntityConstructor} EntityConstructor */
export default class MirroredEntity extends IEntity {
static attributes = {
...super.attributes,
type: {
ignored: true,
},
key: {
ignored: true,
},
object: {
ignored: true,
},
}
constructor(values = {}) {
super({})
/** @type {EntityConstructor} */ this.type
/** @type {String} */ this.key
/** @type {IEntity} */ this.object
}
get() {
return this.object?.[this.key]
}
set(value) {
if (this.object[this.key]) {
this.object[this.key] = value
}
}
}