]> git.r.bdr.sh - rbdr/forum/blobdiff - src/lib/utils/resolve_after.ts
Don't remember what this WIP was about
[rbdr/forum] / src / lib / utils / resolve_after.ts
index 95a477e1bdf2f2c7c9e6c7211c7891014535ef6c..5d35f1c4b906c28c948df0749ab4e18b40c477f8 100644 (file)
@@ -1,29 +1,26 @@
 export type ResolveAfterPromise = {
-  counter: () => void,
-  promise: Promise<void>
+       counter: () => void;
+       promise: Promise<void>;
 };
 
 export const resolveAfter = function (timesUntilResolve: number): ResolveAfterPromise {
+       let counter = null;
+       let currentValue = 0;
 
-  let counter = null;
-  let currentValue = 0;
+       if (timesUntilResolve <= 0) {
+               throw new Error('Resolve after requires a positive integer');
+       }
 
-  if (timesUntilResolve <= 0) {
-    throw new Error('Resolve after requires a positive integer');
-  }
+       const promise: Promise<void> = new Promise((resolvePromise) => {
+               counter = () => {
+                       if (++currentValue === timesUntilResolve) {
+                               resolvePromise();
+                       }
+               };
+       });
 
-  const promise: Promise<void> = new Promise((resolvePromise) => {
-
-    counter = () => {
-
-      if (++currentValue === timesUntilResolve) {
-        resolvePromise();
-      }
-    };
-  });
-
-  return {
-    counter,
-    promise
-  };
+       return {
+               counter,
+               promise
+       };
 };