Files
ueblueprint/js/entity/ComputedTypeEntity.js
barsdeveloper ad4ba2c46d WIP
2024-06-06 20:10:17 +02:00

24 lines
615 B
JavaScript

import IEntity from "./IEntity.js"
export default class ComputedTypeEntity extends IEntity {
static grammar = undefined
/** @type {(entity: IEntity) => typeof IEntity} */
static f
/**
* @template {typeof ComputedTypeEntity.f} T
* @param {T} producer
*/
static from(producer) {
const result = /** @type {(typeof ComputedTypeEntity) & { f: T }} */(this.asUniqueClass())
result.f = producer
return result
}
/** @param {IEntity} entity */
compute(entity) {
return /** @type {typeof ComputedTypeEntity} */(this.Self()).f(entity)
}
}