From bfc2cec7d43eb8eaa46dd3f91084932381257059 Mon Sep 17 00:00:00 2001 From: kj_sh604 Date: Sun, 15 Mar 2026 16:19:35 -0400 Subject: refactor: excalidraw-app/ --- excalidraw-app/data/Locker.ts | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) create mode 100644 excalidraw-app/data/Locker.ts (limited to 'excalidraw-app/data/Locker.ts') diff --git a/excalidraw-app/data/Locker.ts b/excalidraw-app/data/Locker.ts new file mode 100644 index 0000000..c99673e --- /dev/null +++ b/excalidraw-app/data/Locker.ts @@ -0,0 +1,18 @@ +export class Locker { + private locks = new Map(); + + lock = (lockType: T) => { + this.locks.set(lockType, true); + }; + + /** @returns whether no locks remaining */ + unlock = (lockType: T) => { + this.locks.delete(lockType); + return !this.isLocked(); + }; + + /** @returns whether some (or specific) locks are present */ + isLocked(lockType?: T) { + return lockType ? this.locks.has(lockType) : !!this.locks.size; + } +} -- cgit v1.2.3