refactor: Prevent negated conditions

This commit is contained in:
Joachim Van Herwegen
2023-10-30 17:04:20 +01:00
parent c9e4c7041c
commit 98f5d8fb73
9 changed files with 28 additions and 30 deletions

View File

@@ -14,13 +14,12 @@ class MemoryLocker implements ResourceLocker {
public async acquire(identifier: ResourceIdentifier): Promise<void> {
const { path } = identifier;
if (!this.locks[path]) {
this.locks[path] = [];
} else {
if (this.locks[path]) {
return new Promise((resolve): void => {
this.locks[path].push(resolve);
});
}
this.locks[path] = [];
}
public async release(identifier: ResourceIdentifier): Promise<void> {