BlueGit

blue-star danique-bot

Files

danique-bot / node_modules / throttleit / Readme.md

Readme.md

Import template
timfa Tim · pushed by timfa · 4 years ago
c788ad20 History
Readme.md 611 B Download Raw

throttle

Throttle a function

Installation

$ component install component/throttle

Example

var throttle = require('throttle'); window.onresize = throttle(resize, 200);

function resize(e) { console.log('height', window.innerHeight); console.log('width', window.innerWidth); }

API

throttle(fn, wait)

Creates a function that will call fn at most once every wait milliseconds.

Supports leading and trailing invocation.

fn will receive last context (this) and last arguments passed to a throttled wrapper before fn was invoked.

License

MIT

Source
1
2# throttle
3
4 Throttle a function
5
6## Installation
7
8 $ component install component/throttle
9
10## Example
11
12 var throttle = require('throttle');
13 window.onresize = throttle(resize, 200);
14
15 function resize(e) {
16 console.log('height', window.innerHeight);
17 console.log('width', window.innerWidth);
18 }
19
20## API
21
22### throttle(fn, wait)
23
24Creates a function that will call `fn` at most once every `wait` milliseconds.
25
26Supports leading and trailing invocation.
27
28`fn` will receive last context (`this`) and last arguments passed to a throttled wrapper before `fn` was invoked.
29
30## License
31
32 MIT