admin felület fejlesztése garázs, előfizeztési csomagok
This commit is contained in:
89
frontend_admin/.output/server/node_modules/.nitro/perfect-debounce@2.1.0/dist/index.mjs
generated
vendored
Normal file
89
frontend_admin/.output/server/node_modules/.nitro/perfect-debounce@2.1.0/dist/index.mjs
generated
vendored
Normal file
@@ -0,0 +1,89 @@
|
||||
//#region src/index.ts
|
||||
const DEBOUNCE_DEFAULTS = { trailing: true };
|
||||
/**
|
||||
Debounce functions
|
||||
@param fn - Promise-returning/async function to debounce.
|
||||
@param wait - Milliseconds to wait before calling `fn`. Default value is 25ms
|
||||
@returns A function that delays calling `fn` until after `wait` milliseconds have elapsed since the last time it was called.
|
||||
@example
|
||||
```
|
||||
import { debounce } from 'perfect-debounce';
|
||||
const expensiveCall = async input => input;
|
||||
const debouncedFn = debounce(expensiveCall, 200);
|
||||
for (const number of [1, 2, 3]) {
|
||||
console.log(await debouncedFn(number));
|
||||
}
|
||||
//=> 1
|
||||
//=> 2
|
||||
//=> 3
|
||||
```
|
||||
*/
|
||||
function debounce(fn, wait = 25, options = {}) {
|
||||
options = {
|
||||
...DEBOUNCE_DEFAULTS,
|
||||
...options
|
||||
};
|
||||
if (!Number.isFinite(wait)) throw new TypeError("Expected `wait` to be a finite number");
|
||||
let leadingValue;
|
||||
let timeout;
|
||||
let resolveList = [];
|
||||
let currentPromise;
|
||||
let trailingArgs;
|
||||
const applyFn = (_this, args) => {
|
||||
currentPromise = _applyPromised(fn, _this, args);
|
||||
currentPromise.finally(() => {
|
||||
currentPromise = null;
|
||||
if (options.trailing && trailingArgs && !timeout) {
|
||||
const promise = applyFn(_this, trailingArgs);
|
||||
trailingArgs = null;
|
||||
return promise;
|
||||
}
|
||||
});
|
||||
return currentPromise;
|
||||
};
|
||||
const debounced = function(...args) {
|
||||
if (options.trailing) trailingArgs = args;
|
||||
if (currentPromise) return currentPromise;
|
||||
return new Promise((resolve) => {
|
||||
const shouldCallNow = !timeout && options.leading;
|
||||
clearTimeout(timeout);
|
||||
timeout = setTimeout(() => {
|
||||
timeout = null;
|
||||
const promise = options.leading ? leadingValue : applyFn(this, args);
|
||||
trailingArgs = null;
|
||||
for (const _resolve of resolveList) _resolve(promise);
|
||||
resolveList = [];
|
||||
}, wait);
|
||||
if (shouldCallNow) {
|
||||
leadingValue = applyFn(this, args);
|
||||
resolve(leadingValue);
|
||||
} else resolveList.push(resolve);
|
||||
});
|
||||
};
|
||||
const _clearTimeout = (timer) => {
|
||||
if (timer) {
|
||||
clearTimeout(timer);
|
||||
timeout = null;
|
||||
}
|
||||
};
|
||||
debounced.isPending = () => !!timeout;
|
||||
debounced.cancel = () => {
|
||||
_clearTimeout(timeout);
|
||||
resolveList = [];
|
||||
trailingArgs = null;
|
||||
};
|
||||
debounced.flush = () => {
|
||||
_clearTimeout(timeout);
|
||||
if (!trailingArgs || currentPromise) return;
|
||||
const args = trailingArgs;
|
||||
trailingArgs = null;
|
||||
return applyFn(this, args);
|
||||
};
|
||||
return debounced;
|
||||
}
|
||||
async function _applyPromised(fn, _this, args) {
|
||||
return await fn.apply(_this, args);
|
||||
}
|
||||
|
||||
//#endregion
|
||||
export { debounce };
|
||||
41
frontend_admin/.output/server/node_modules/.nitro/perfect-debounce@2.1.0/package.json
generated
vendored
Normal file
41
frontend_admin/.output/server/node_modules/.nitro/perfect-debounce@2.1.0/package.json
generated
vendored
Normal file
@@ -0,0 +1,41 @@
|
||||
{
|
||||
"name": "perfect-debounce",
|
||||
"version": "2.1.0",
|
||||
"description": "",
|
||||
"repository": "unjs/perfect-debounce",
|
||||
"license": "MIT",
|
||||
"sideEffects": false,
|
||||
"type": "module",
|
||||
"exports": {
|
||||
".": "./dist/index.mjs"
|
||||
},
|
||||
"main": "./dist/index.mjs",
|
||||
"module": "./dist/index.mjs",
|
||||
"types": "./dist/index.d.mts",
|
||||
"files": [
|
||||
"dist"
|
||||
],
|
||||
"scripts": {
|
||||
"build": "obuild",
|
||||
"dev": "vitest dev",
|
||||
"lint": "eslint . && prettier --check src test",
|
||||
"lint:fix": "eslint . --fix && prettier -w src test",
|
||||
"release": "pnpm test && pnpm build && changelogen --release --push && npm publish",
|
||||
"test": "vitest run --coverage"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^25.0.10",
|
||||
"@vitest/coverage-v8": "^4.0.17",
|
||||
"automd": "^0.4.2",
|
||||
"changelogen": "^0.6.2",
|
||||
"eslint": "^9.39.2",
|
||||
"eslint-config-unjs": "^0.6.2",
|
||||
"in-range": "^3.0.0",
|
||||
"obuild": "^0.4.18",
|
||||
"prettier": "^3.8.1",
|
||||
"time-span": "^5.1.0",
|
||||
"typescript": "^5.9.3",
|
||||
"vitest": "^4.0.17"
|
||||
},
|
||||
"packageManager": "pnpm@10.28.1"
|
||||
}
|
||||
Reference in New Issue
Block a user