Function since

Returns elapsed time since the initial call.

// Record start
const elapsed = Stopwatch.since();

// 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 = {
clicked: Stopwatch.infinity()
};

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

// Later, when click happens:
state = { click: Stopwatch.since() }

See also:

  • once if you want to measure a single period, and stop it.
  • interval time between calls