@chromakit/core
    Preparing search index...

    Function withProgressBar

    • Animates a progress bar for async work. Calls your fn with an update callback. Handles drawing, cleanup, and percent for you.

      Type Parameters

      • T

      Parameters

      • fn: (update: (progress: number, label?: string) => void) => Promise<T>

        Function which receives update(progress, label?)

      • opts: ProgressBarOptions = {}

        ProgressBar display options

      Returns Promise<T>

      await withProgressBar(async update => {
      for (let i = 0; i <= 100; i++) {
      await sleep(25);
      update(i / 100, `Step ${i}`);
      }
      }, { color: 'green' });