deno.land / x / masx200_leetcode_test@10.6.5 / design-a-number-container-system / Computed.ts

نووسراو ببینە
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
export class Computed<T> { #refresh() { this.#cached = this.#getter();
this.#dirty = false; } #cached: T; #dirty = false; #getter: () => T; trigger() { this.#dirty = true; } get value(): T { if (this.#dirty) { this.#refresh(); }
return this.#cached; } constructor(getter: () => T) { this.#getter = getter; this.#cached = this.#getter(); }}
masx200_leetcode_test

Version Info

Tagged at
a year ago