@canonical/util-throttle
TypeScript icon, indicating that this package has built-in type declarations

0.0.0-experimental.2 • Public • Published

Throttle Util

Throttling limits the number of times a function can be called over a specified period. This is particularly useful for event listeners (such as scroll or resize), which can trigger frequently and lead to performance issues.

By using throttle, you can ensure that a function runs at most once in each specified time interval, reducing application load and improving responsiveness.

Example

import throttle from "@canonical/util-throttle";

window.addEventListener(
  'resize',
  throttle(() => {
    console.log("window was resized!");
  }, 10);
);

Readme

Keywords

none

Package Sidebar

Install

npm i @canonical/util-throttle

Weekly Downloads

10

Version

0.0.0-experimental.2

License

LGPL-3.0

Unpacked Size

3.4 kB

Total Files

6

Last publish

Collaborators

  • jmuzina
  • lukewh
  • mtruj
  • edlerd
  • seulkee
  • canonical-organization
  • petesfrench
  • frankban
  • huwshimi
  • anthonydillon
  • steverydz
  • amylily1011
  • bartaz
  • jpmartinspt