admin felület különválasztva

This commit is contained in:
Roo
2026-06-24 11:29:45 +00:00
parent 71ef33bb85
commit 80a5d67f79
462 changed files with 87873 additions and 312 deletions

View File

@@ -0,0 +1,59 @@
'use strict';
const DEBOUNCE_DEFAULTS = {
trailing: true
};
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;
};
return function(...args) {
if (currentPromise) {
if (options.trailing) {
trailingArgs = args;
}
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);
for (const _resolve of resolveList) {
_resolve(promise);
}
resolveList = [];
}, wait);
if (shouldCallNow) {
leadingValue = applyFn(this, args);
resolve(leadingValue);
} else {
resolveList.push(resolve);
}
});
};
}
async function _applyPromised(fn, _this, args) {
return await fn.apply(_this, args);
}
exports.debounce = debounce;

View File

@@ -0,0 +1,44 @@
{
"name": "perfect-debounce",
"version": "1.0.0",
"description": "",
"repository": "unjs/perfect-debounce",
"license": "MIT",
"sideEffects": false,
"type": "module",
"exports": {
".": {
"types": "./dist/index.d.ts",
"import": "./dist/index.mjs",
"require": "./dist/index.cjs"
}
},
"main": "./dist/index.cjs",
"module": "./dist/index.mjs",
"types": "./dist/index.d.ts",
"files": [
"dist"
],
"scripts": {
"build": "unbuild",
"dev": "vitest dev",
"lint": "eslint --ext .ts,.js,.mjs,.cjs . && prettier --check src test",
"lint:fix": "eslint --ext .ts,.js,.mjs,.cjs . --fix && prettier -w src test",
"release": "pnpm test && pnpm build && changelogen --release --push && npm publish",
"test": "vitest run --coverage"
},
"devDependencies": {
"@types/node": "^18.16.3",
"@vitest/coverage-c8": "^0.31.0",
"changelogen": "^0.5.3",
"eslint": "^8.39.0",
"eslint-config-unjs": "^0.1.0",
"in-range": "^3.0.0",
"prettier": "^2.8.8",
"time-span": "^5.1.0",
"typescript": "^5.0.4",
"unbuild": "^1.2.1",
"vitest": "^0.31.0"
},
"packageManager": "pnpm@8.4.0"
}