https://github.com/yuriy-svetlov/call-no-more-often-than
Call a function or something else no more often than a certain amount of time.
https://github.com/yuriy-svetlov/call-no-more-often-than
Last synced: 3 months ago
JSON representation
Call a function or something else no more often than a certain amount of time.
- Host: GitHub
- URL: https://github.com/yuriy-svetlov/call-no-more-often-than
- Owner: Yuriy-Svetlov
- License: mit
- Created: 2021-04-20T20:48:51.000Z (about 4 years ago)
- Default Branch: main
- Last Pushed: 2021-11-04T15:32:48.000Z (over 3 years ago)
- Last Synced: 2025-01-24T22:34:56.165Z (5 months ago)
- Language: JavaScript
- Size: 5.86 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# Call-no-more-often-than
[](https://www.npmjs.com/package/call-no-more-often-than)
Call a function or something else no more often than a certain amount of time
## Install
```shell
npm i call-no-more-often-than --save-dev
```## Usage
```javascript
const call_no_more_often_than = require('call-no-more-often-than');call_no_more_often_than(3000).then(function(){
// Your code that won't execute more often than 3000 milliseconds
});
```## Examples
```javascript
const call_no_more_often_than = require('call-no-more-often-than');test_function();
test_function();setTimeout(function(){
test_function();
}, 2000);function test_function(){
call_no_more_often_than(3000).then(function(){
console.log('Called once');
});
}
```## Options
### time
* Type: `Integer`
* Default value: `1000`The number is specified in milliseconds. The time during which the internal code of the function will not be called after the first call. The deviation accuracy can be 10-30 milliseconds.