@benev/slate
Version:
frontend web stuff
20 lines • 630 B
JavaScript
import { maptool } from "../../tools/maptool.js";
import { make_map, make_set } from "./makers.js";
export class Recorder {
#recordings = [];
record(fn) {
const recording = make_map();
this.#recordings.push(recording);
const payload = fn();
this.#recordings.pop();
return { payload, recording };
}
record_that_key_was_accessed(state, key) {
const recording = this.#recordings.at(-1);
if (recording) {
const keyset = maptool(recording).guarantee(state, make_set);
keyset.add(key);
}
}
}
//# sourceMappingURL=recorder.js.map