Update app and tooling
This commit is contained in:
parent
3046531bdd
commit
e620ec7349
4950 changed files with 2975120 additions and 10 deletions
32
node_modules/throttleit/index.d.ts
generated
vendored
Normal file
32
node_modules/throttleit/index.d.ts
generated
vendored
Normal file
|
|
@ -0,0 +1,32 @@
|
|||
/**
|
||||
Throttle a function to limit its execution rate.
|
||||
|
||||
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.
|
||||
|
||||
@param function_ - The function to be throttled.
|
||||
@param wait - The number of milliseconds to throttle invocations to.
|
||||
@returns A new throttled version of the provided function.
|
||||
|
||||
@example
|
||||
```
|
||||
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');
|
||||
```
|
||||
*/
|
||||
declare function throttle<T extends (...arguments_: any[]) => unknown>(function_: T, wait: number): T;
|
||||
|
||||
export = throttle;
|
||||
30
node_modules/throttleit/index.js
generated
vendored
Normal file
30
node_modules/throttleit/index.js
generated
vendored
Normal file
|
|
@ -0,0 +1,30 @@
|
|||
function throttle(function_, wait) {
|
||||
if (typeof function_ !== 'function') {
|
||||
throw new TypeError(`Expected the first argument to be a \`function\`, got \`${typeof function_}\`.`);
|
||||
}
|
||||
|
||||
// TODO: Add `wait` validation too in the next major version.
|
||||
|
||||
let timeoutId;
|
||||
let lastCallTime = 0;
|
||||
|
||||
return function throttled(...arguments_) { // eslint-disable-line func-names
|
||||
clearTimeout(timeoutId);
|
||||
|
||||
const now = Date.now();
|
||||
const timeSinceLastCall = now - lastCallTime;
|
||||
const delayForNextCall = wait - timeSinceLastCall;
|
||||
|
||||
if (delayForNextCall <= 0) {
|
||||
lastCallTime = now;
|
||||
function_.apply(this, arguments_);
|
||||
} else {
|
||||
timeoutId = setTimeout(() => {
|
||||
lastCallTime = Date.now();
|
||||
function_.apply(this, arguments_);
|
||||
}, delayForNextCall);
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
module.exports = throttle;
|
||||
10
node_modules/throttleit/license
generated
vendored
Normal file
10
node_modules/throttleit/license
generated
vendored
Normal file
|
|
@ -0,0 +1,10 @@
|
|||
MIT License
|
||||
|
||||
Copyright (c) TJ Holowaychuk <tj@tjholowaychuk.com>
|
||||
Copyright (c) Sindre Sorhus <sindresorhus@gmail.com> (https://sindresorhus.com)
|
||||
|
||||
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
|
||||
|
||||
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
||||
|
||||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||
49
node_modules/throttleit/package.json
generated
vendored
Normal file
49
node_modules/throttleit/package.json
generated
vendored
Normal file
|
|
@ -0,0 +1,49 @@
|
|||
{
|
||||
"name": "throttleit",
|
||||
"version": "2.1.0",
|
||||
"description": "Throttle a function to limit its execution rate",
|
||||
"license": "MIT",
|
||||
"repository": "sindresorhus/throttleit",
|
||||
"funding": "https://github.com/sponsors/sindresorhus",
|
||||
"exports": {
|
||||
"types": "./index.d.ts",
|
||||
"default": "./index.js"
|
||||
},
|
||||
"main": "./index.js",
|
||||
"types": "./index.d.ts",
|
||||
"sideEffects": false,
|
||||
"engines": {
|
||||
"node": ">=18"
|
||||
},
|
||||
"scripts": {
|
||||
"test": "xo && ava"
|
||||
},
|
||||
"files": [
|
||||
"index.js",
|
||||
"index.d.ts"
|
||||
],
|
||||
"keywords": [
|
||||
"throttle",
|
||||
"rate",
|
||||
"limit",
|
||||
"limited",
|
||||
"rate-limit",
|
||||
"ratelimit",
|
||||
"throttling",
|
||||
"optimization",
|
||||
"performance",
|
||||
"function",
|
||||
"execution",
|
||||
"interval",
|
||||
"batch"
|
||||
],
|
||||
"devDependencies": {
|
||||
"ava": "^5.3.1",
|
||||
"xo": "^0.56.0"
|
||||
},
|
||||
"xo": {
|
||||
"rules": {
|
||||
"unicorn/prefer-module": "off"
|
||||
}
|
||||
}
|
||||
}
|
||||
53
node_modules/throttleit/readme.md
generated
vendored
Normal file
53
node_modules/throttleit/readme.md
generated
vendored
Normal file
|
|
@ -0,0 +1,53 @@
|
|||
# throttleit
|
||||
|
||||
> Throttle a function to limit its execution rate
|
||||
|
||||
## Install
|
||||
|
||||
```sh
|
||||
npm install throttleit
|
||||
```
|
||||
|
||||
## Usage
|
||||
|
||||
```js
|
||||
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](https://github.com/sindresorhus/p-throttle) - Throttle async functions
|
||||
- [debounce](https://github.com/sindresorhus/debounce) - Delay function calls until a set time elapses after the last invocation
|
||||
Loading…
Add table
Add a link
Reference in a new issue