@pengzhanbo/utils - v3.4.1
    Preparing search index...

    Function createPromiseLock

    • Create a promise task execution lock

      创建一个 promise 任务执行锁

      Returns {
          clear: () => void;
          isWaiting: () => boolean;
          run: <T = void>(fn: () => Promise<T>) => Promise<T>;
          wait: () => Promise<void>;
      }

      const lock = createPromiseLock()

      lock.run(async () => {
      await doSomething()
      })

      // in anther context:
      await lock.wait() // it will wait all tasking finished