2.0.2 • Published 9 months ago

@pacote/throttle v2.0.2

Weekly downloads
55
License
MIT
Repository
github
Last release
9 months ago

@pacote/throttle

version minified minified + gzip

A tiny throttler.

Installation

yarn add @pacote/throttle

Usage

import { throttle } from '@pacote/throttle'

const throttledFn = throttle(fn, 100)

throttledFn() // fn() is called immediately
throttledFn() // fn() is scheduled for execution after 100ms
throttledFn() // fn() is scheduled for execution, cancelling the previous one

throttle<T>(fn: (...args: T[]) => any, delay = 0): (...args: T[]) => void

throttle() creates a throttled version of the passed function.

By calling the throttled function repeatedly, the original function is called once immediately and then at most once for every period of time determined by the delay argument.

The delay argument is optional and defaults to 0 when not supplied.

The throttled function supplies a .cancel() method that can be used to cancel a pending invocation.

License

MIT © Luís Rodrigues.

2.0.2

9 months ago

2.0.1

1 year ago

2.0.0

1 year ago

1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

4 years ago

1.0.3

4 years ago

1.0.2

4 years ago

1.0.1

4 years ago

1.0.0

4 years ago