0.0.4 • Published 4 years ago

proxy-debounce-with-accumulator v0.0.4

Weekly downloads
-
License
MIT
Repository
-
Last release
4 years ago

coverage lines coverage functions coverage branches coverage statements

Proxy debounce with accumulator

This is a simple package implementing debounce with JS Proxy.

However, there is a big twist:

import debounce from "proxy-debounce-with-accumulator"

const f = debounce((n) => n), 100)

for (let i = 0; i < 10; i++) {
    f(i)
}

such a code would call the f function once, as expected of a debounced function, but during this call the value of n would equal [0,1,2,3,4,5,6,7,8,9], since the call arguments are accumulated.

You can also await such a function:

import debounce from "proxy-debounce-with-accumulator"

const f = debounce((n) => n), 100)

for (let i = 0; i < 10; i++) {
    if (i === 4) {
        await f(i)
    }
    else {
        f(i)
    }
}

In such a code the arguments passed to the function would be: [0,1,2,3,4] and [5,6,7,8,9].

Performance

Run tests in order to see detailed performance differences between this package, lodash and regular objects.

1.0.0

4 years ago

1.0.1

4 years ago

0.0.4

4 years ago

0.0.3

4 years ago

0.0.2

4 years ago

0.0.1

4 years ago