Returns a function that reports an 'infinite' elapsed time. this can be useful as an initialiser for elapsedSince et al.
elapsedSince
// Init clicked to be an infinite timelet clicked = elapsedInfinity();document.addEventListener('click', () => { // Now that click has happened, we can assign it properly clicked = elapsedSince();}); Copy
// Init clicked to be an infinite timelet clicked = elapsedInfinity();document.addEventListener('click', () => { // Now that click has happened, we can assign it properly clicked = elapsedSince();});
Use isInfiniteSince to check if a function is of type infinity:
infinity
let clicked = elapsedInfinity();document.addEventListener('click', () => { if (isInfiniteSince(clicked)) { console.log(`First time clicked!`); } clicked = elapsedSince();}); Copy
let clicked = elapsedInfinity();document.addEventListener('click', () => { if (isInfiniteSince(clicked)) { console.log(`First time clicked!`); } clicked = elapsedSince();});
A function that returns Number.POSITIVE_INFINITY when called.
Number.POSITIVE_INFINITY
Returns a function that reports an 'infinite' elapsed time. this can be useful as an initialiser for
elapsedSinceet al.Use isInfiniteSince to check if a function is of type
infinity: