mirror of
https://github.com/barsdeveloper/ueblueprint.git
synced 2026-02-13 00:24:48 +08:00
24 lines
615 B
JavaScript
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)
|
|
}
|
|
}
|