@burmis/create-throttle
v0.0.4
Published
Throttle calls to a given function to ensure that they do not happen too often.
Downloads
11
Readme
create-throttle hook
This package contains a function you can use to create a throttle. Once a throttle is created you can call it passing in your own function to execute.
The throttle will execute your function immediately, and then wait for interval to complete before resolving. This allows you to limit the number of times a function is called in a given interval.
Example Usage
const throttle = createThrottle({
limit: 3, // number of calls allowed in the interval
interval: 100, // in milliseconds
});
await throttle(async () => console.log("Test Function 1")); // This will be called immediately
await throttle(async () => console.log("Test Function 2")); // This will be called immediately
await throttle(async () => console.log("Test Function 3")); // This will be called immediately
await throttle(async () => console.log("Test Function 4")); // This will be called after the 100ms interval has passed
Running Tests
deno task check
Publishing to NPM
deno task publish
Other Tasks
Run this command to print out all available tasks.
deno task
Note: In order to publish an update or new version, you must increment
VERSION
withinversion.ts
in the root directory.export const VERSION = x.x.x; // Increment me accordingly