chore: format everything
This commit is contained in:
@@ -6,12 +6,12 @@ export const makeMutex = () => {
|
||||
|
||||
return {
|
||||
mutex<T>(code: () => Promise<T> | T): Promise<T> {
|
||||
task = (async() => {
|
||||
task = (async () => {
|
||||
// wait for the previous task to complete
|
||||
// if there is an error, we swallow so as to not block the queue
|
||||
try {
|
||||
await task
|
||||
} catch{ }
|
||||
} catch {}
|
||||
|
||||
try {
|
||||
// execute the current task
|
||||
@@ -24,7 +24,7 @@ export const makeMutex = () => {
|
||||
// we replace the existing task, appending the new piece of execution to it
|
||||
// so the next task will have to wait for this one to finish
|
||||
return task
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,11 +35,11 @@ export const makeKeyedMutex = () => {
|
||||
|
||||
return {
|
||||
mutex<T>(key: string, task: () => Promise<T> | T): Promise<T> {
|
||||
if(!map[key]) {
|
||||
if (!map[key]) {
|
||||
map[key] = makeMutex()
|
||||
}
|
||||
|
||||
return map[key].mutex(task)
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user