Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 2 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,8 @@
"@splinetool/[email protected]": "patches/@[email protected]",
"[email protected]": "patches/[email protected]",
"[email protected]": "patches/[email protected]",
"[email protected]": "patches/[email protected]"
"[email protected]": "patches/[email protected]",
"@tanstack/[email protected]": "patches/@[email protected]"
}
}
}
65 changes: 65 additions & 0 deletions patches/@[email protected]
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
diff --git a/build/modern/asyncThrottle.js b/build/modern/asyncThrottle.js
index 15654ccb191ea5320a6302a6d298ce6c8e74ec56..3c3b5468a23bc97bff1231cb4bc2f75bebd924cb 100644
--- a/build/modern/asyncThrottle.js
+++ b/build/modern/asyncThrottle.js
@@ -1,49 +1,17 @@
// src/asyncThrottle.ts
var noop = () => {
};
-function asyncThrottle(func, { interval = 1e3, onError = noop } = {}) {
- if (typeof func !== "function")
- throw new Error("argument is not function.");
- let running = false;
- let lastTime = 0;
- let timeout;
- let currentArgs = null;
- const execFunc = async () => {
- if (currentArgs) {
- const args = currentArgs;
- currentArgs = null;
- try {
- running = true;
- await func(...args);
- } catch (error) {
- onError(error);
- } finally {
- lastTime = Date.now();
- running = false;
- }
- }
- };
- const delayFunc = async () => {
- clearTimeout(timeout);
- timeout = setTimeout(() => {
- if (running) {
- delayFunc();
- } else {
- execFunc();
- }
- }, interval);
- };
+function asyncThrottle2(func, { interval = 1e3, onError = noop } = {}) {
+ if (typeof func !== 'function') throw new Error('argument is not function.')
+ let currentArgs = null
+ setInterval(() => {
+ if (!currentArgs) return
+ Promise.resolve(func(...currentArgs)).catch(onError)
+ currentArgs = null
+ }, interval)
return (...args) => {
- currentArgs = args;
- const tooSoon = Date.now() - lastTime < interval;
- if (running || tooSoon) {
- delayFunc();
- } else {
- execFunc();
- }
- };
+ currentArgs = args
+ }
}
-export {
- asyncThrottle
-};
+export { asyncThrottle2 as asyncThrottle }
//# sourceMappingURL=asyncThrottle.js.map
1 change: 1 addition & 0 deletions patches/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@
- react-spline: <https://github.com/splinetool/react-spline/issues/133>
- eslint-plugin-i: <https://github.com/import-js/eslint-plugin-import/pull/1900/>
- react-devtools-inline: <https://github.com/facebook/react/pull/27733>
- @tanstack/query-async-storage-persister: Performance problem <https://github.com/TanStack/query/issues/6489>

## CSP

Expand Down
8 changes: 6 additions & 2 deletions pnpm-lock.yaml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.