ixfx
    Preparing search index...

    Function elapsedSince

    • Returns elapsed time since the initial call.

      // Record start
      const elapsed = elapsedSince();

      // Get elapsed time in millis
      // since Elapsed.since()
      elapsed(); // Yields number

      If you want to initialise a stopwatch, but not yet start it, consider:

      // Init
      let state = {
      sinceClicked: elapsedInfinity()
      };

      state.sinceClicked(); // Returns a giant value

      // Later, when click happens:
      document.addEventListener('click', () => {
      state.sinceClicked = elapsedSince();
      });

      The skip option allows you to skip the first N calls to the returned function before starting the timer. For example, if you want to skip the first 2 calls:

      const elapsed = elapsedSince({ skip: 2 });

      elapsed(); // First call, timer not started yet. Get NaN
      elapsed(); // Second call, timer still not started. Get NaN
      elapsed(); // Third call, returns elapsed time since last `elapsed()` call.

      See also: elapsedOnce if you want to measure a single period, and stop it. elapsedInterval time between calls

      Parameters

      • options: Partial<ElapsedOptions> = {}

        Options to control the elapsed timer. Currently only supports skip which will skip the first N calls to the returned function before starting the timer.

      Returns Since

      Since