MCPcopy Create free account
hub / github.com/marijnh/Eloquent-JavaScript /

Class

code/solutions/08_2_the_locked_box.js:1–11  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1const box = new class {
2 locked = true;
3 #content = [];
4
5 unlock() { this.locked = false; }
6 lock() { this.locked = true; }
7 get content() {
8 if (this.locked) throw new Error("Locked!");
9 return this.#content;
10 }
11};
12
13function withBoxUnlocked(body) {
14 let locked = box.locked;

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected