Executes a given function approximately once every count calls.
count
This function uses a random number generator to determine if the provided function should be executed. On average, the function will be executed once every count calls.
The type of the function to be executed.
The function to be executed.
The approximate number of calls after which the function should be executed once.
const logMessage = () => console.log("Function executed");sampler(logMessage, 10); // logMessage will be executed approximately once every 10 calls Copy
const logMessage = () => console.log("Function executed");sampler(logMessage, 10); // logMessage will be executed approximately once every 10 calls
Executes a given function approximately once every
count
calls.This function uses a random number generator to determine if the provided function should be executed. On average, the function will be executed once every
count
calls.