2.0.0 • Published 5 months ago

throttleit v2.0.0

Weekly downloads
2,877,796
License
MIT
Repository
github
Last release
5 months ago

throttleit

Throttle a function to limit its execution rate

Install

npm install throttleit

Usage

import throttle from 'throttleit';

// Throttling a function that processes data.
function processData(data) {
	console.log('Processing:', data);

	// Add data processing logic here.
}

// Throttle the `processData` function to be called at most once every 3 seconds.
const throttledProcessData = throttle(processData, 3000);

// Simulate calling the function multiple times with different data.
throttledProcessData('Data 1');
throttledProcessData('Data 2');
throttledProcessData('Data 3');

API

throttle(function, wait)

Creates a throttled function that limits calls to the original function to at most once every wait milliseconds. It guarantees execution after the final invocation and maintains the last context (this) and arguments.

function

Type: function

The function to be throttled.

wait

Type: number

The number of milliseconds to throttle invocations to.

Related

  • p-throttle - Throttle async functions
  • debounce - Delay function calls until a set time elapses after the last invocation
request-progressemuloadnode-noodle@infinitebrahmanuniverse/nolb-thro@everything-registry/sub-chunk-2940editorjs_forkededitor.js-custom-multiple-selected@edoroshenko/codemirrorvue-dev-clonevue-choicevue-mugen-scrollwebtorrent-remoteweptwept-sdkwept-tracweptsweb-elements-iconswikibattlethrottled-log@faizanhaider/iconsax@felixrieseberg/nuggetux-work-reportvideo-multi-uploaderfenglin-uploaderfget-clisweetalert2-denazificationtauizombieteer@dz-web/reactjs-pull-refresh-jtfept@headgum/tko-mapping@internetarchive/dweb-archivenuggetcloudup-clientdesign-system-fitbank-450r2-testapp-jsdocumarkreactjs-scrollrefinejs-reporequest-download-inforequest-progress-exreact-scroll-sensorselect2-selectallstreat@cdevine49/react-numeric-inputss-actionsstock-ticker-react-widgetsvavatar@licq/dl@oudyworks/ttlmapfixer-jsfixer.jsimagebox@retailica/sweetalert2infinity-component@seculum/vue-dev-cloneiscroll-componentitalent-portal@swimlane/docspa-corekokk@stayradiated/web-audiomobile-listblockcity-weptneoclide-clientneoget@cardbox/editoravatar-toolkitmodeify@beisen/grid-page-builder@beisen/page-builderlrchaos-ormatomic-frameworkmore-mobilebiko2_shufflejsnpm-all-packages@tbo-it/decommerce-admin-ui-components@tbo-it/decommerce-white-label-componentslight-bounds@yak-spirit/yak-swap-uicomponent-infinity@devorso/dcountdowncypress-spellcheckprejoininreact-flow-highly-customizable-edgesreact-carousel-ninjareact-page-designerreact-picky-with-clearreact-navigatep2p-graphfluidfont@jaw-aid/npmpractice@lofcz/sweetalert2-neutral@namtoonix/editorjs-custom-multiple-selected@odopod/odo-window-events
1.0.1

5 months ago

2.0.0

5 months ago

1.0.0

9 years ago

0.0.2

11 years ago

0.0.1

11 years ago