@s-libs/js-core
    Preparing search index...

    Class Debouncer

    Like a standard debounce from e.g. micro-dash, but can execute a different function for a different wait period at each invocation.

    const print = (value) => console.log(value);
    const debouncer = new Debouncer();

    debouncer.run(print, 1000, 1);
    await sleep(500);

    debouncer.run(print, 1000, 2);
    await sleep(1000); // prints "2"

    debouncer.run(print, 0, 3);
    debouncer.run(print, 1000, 4);
    await sleep(500);

    debouncer.run(print, 2000, 5);
    debouncer.run(print, 50, 6);
    await sleep(50); // prints "6"
    Index

    Constructors

    Methods

    Constructors

    Methods

    • Type Parameters

      • T extends (...args: any[]) => any

      Parameters

      • func: T
      • wait: number = 0
      • ...args: Parameters<T>

      Returns void