Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

The throttle is not performing as expected. #23

Open
1natsu172 opened this issue Sep 9, 2023 · 0 comments
Open

The throttle is not performing as expected. #23

1natsu172 opened this issue Sep 9, 2023 · 0 comments

Comments

@1natsu172
Copy link

The throttle of this library does not perform throttling (it behaves differently from what is described in the tests and documentation).

You will understand if you try the following reproduction code in RunKit. Instead of behaving like the marble in the test cases, it appears to perform a complete debounce operation, firing only once at the start and once at the end.

| throttle(fn, 100) | 1 2 4 6 8 10 |

image

var {throttle} = require("@github/mini-throttle")

const delay = (m) => new Promise(r => setTimeout(r, m))

const fn = throttle((...x)=>{console.log(x)},1000)

for (let i = 1; i <= 10; ++i) {
  fn(i)
  await delay(100)
}
await delay(1000)

You can also repro this in the following CodeSandbox. Please rapidly click the button. While the expected throttle behavior is that of lodash.throttle, but mini-throttle does not perform as its name "throttle".

https://codesandbox.io/p/sandbox/damp-browser-fyd2g4?file=/src/index.js:24,11

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant