The throttle is not performing as expected.
- Lenguaje dominante
- TypeScript
- Estrellas
- 229
- Forks
- 18
- Merge medio
- 1 d 10 h
- PR fusionados (30 d)
- 2
Descripción
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](https://npm.runkit.com/%40github%2Fmini-throttle). Instead of behaving like [the marble in the test cases](https://github.com/github/mini-throttle/blob/7fb6f52c98c735fe44f6096c8bddd051976d3ae0/test/index.ts#L167), 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 |

```javascript
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
Guía de contribución
Línea de trabajo
Comienza con el comportamiento de throttle descrito por el marble en test/index.ts alrededor de la línea 167 y, después, ejecuta la reproducción enlazada de RunKit o CodeSandbox para comparar las llamadas reales y esperadas. Traza el punto de entrada de throttle y verifica que las llamadas repetidas produzcan el timing documentado similar a lodash.throttle, en lugar del comportamiento de debounce; se considera terminado cuando la reproducción y las pruebas relevantes coincidan con el marble.
Escrito por el modelo de indexación a partir del texto del issue.
Evaluación
- Stack tecnológico
- javascript, typescript
- Área
- tooling
- Tipo de issue
- Error
- Dificultad
- 3/5
- Tiempo estimado
- 1-2 días
- Estado de actividad
- Estancado
- Claridad
- Bastante claro
- Aptitud para principiantes
- 42/100