import { debounce } from"@thalesrc/js-utils/promise";
functionfoo() {
console.log("hello");
}
for (let i = 0; i < 5; i++) {
debounce(foo);
}
// logs "hello" only once
Static usage example:
import"@thalesrc/js-utils/dist/as-proto/debounce";
functionfoo() {
console.log("hello");
}
for (let i = 0; i < 5; i++) {
foo.debounce();
}
// logs "hello" only once
Debounces a function that delays invoking until after given time have elapsed since the last time the debounced function was invoked
Example usage:
import { debounce } from "@thalesrc/js-utils/promise"; function foo() { console.log("hello"); } for (let i = 0; i < 5; i++) { debounce(foo); } // logs "hello" only once
Static usage example:
import "@thalesrc/js-utils/dist/as-proto/debounce"; function foo() { console.log("hello"); } for (let i = 0; i < 5; i++) { foo.debounce(); } // logs "hello" only once