MCPcopy Create free account
hub / github.com/esengine/esengine / WeakRefPolyfill

Class WeakRefPolyfill

packages/core/src/ECS/Core/ReferenceTracker.ts:23–33  ·  view source on GitHub ↗

* WeakRef Polyfill for ES2020 compatibility * * 为了兼容 Cocos Creator、Laya、微信小游戏等目标平台(仅支持 ES2020), * 提供 WeakRef 的 Polyfill 实现。 * * - 现代浏览器:自动使用原生 WeakRef (自动 GC) * - 旧环境:使用 Polyfill (无自动 GC,但 Scene 销毁时会手动清理)

Source from the content-addressed store, hash-verified

21 * - 旧环境:使用 Polyfill (无自动 GC,但 Scene 销毁时会手动清理)
22 */
23class WeakRefPolyfill<T extends object> implements IWeakRef<T> {
24 private _target: T;
25
26 constructor(target: T) {
27 this._target = target;
28 }
29
30 deref(): T | undefined {
31 return this._target;
32 }
33}
34
35/**
36 * WeakRef 构造函数类型

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected