1.0.10 • Published 5 months ago

@frankykubo/debounce-tools v1.0.10

Weekly downloads
-
License
ISC
Repository
github
Last release
5 months ago

Debounce Tools

Debounce Tools is a TypeScript library for debouncing function calls in both synchronous and asynchronous contexts.

Installation

To install Debounce Tools, you can use NPM:

npm install @frankykubo/debounce-tools

Usage

Here are the available functions in Debounce Tools:

FunctionParametersDescription
debounceMemoizecallback: (...args: any[], prevArgs: any[][] = []) => any, delay: numberAsync function that debounces and memoizes the result of the callback function
syncDebounceMemoizecallback: (...args: any[], prevArgs: any[][] = []) => void, delay: numberSync function that debounces and memoizes the result of the callback function

Example 1

import { debounceMemoize } from '@frankykubo/debounce-tools';

const printStr = (someString: string, prevArgs: string[][] = []) => {
    console.log(someString);
    console.log(prevArgs.flatMap(str => str));
}

const printStrWrapped = debounceMemoize(printStr, 100);

printStrWrapped('Test');
printStrWrapped('debounced');
printStrWrapped('printStr');
printStrWrapped('function');


$ 'function'
$ [ 'Test', 'debounced', 'printStr' ]

Example 2

import { syncDebounceMemoize } from '@frankykubo/debounce-tools';

const printStr = (someString: string, prevArgs: string[][] = []) => {
    console.log(someString);
    console.log(prevArgs.flatMap(str => str));
    return someString;
}

const printStrWrapped = syncDebounceMemoize(printStr, 100);

printStrWrapped('Test');
printStrWrapped('debounced');
printStrWrapped('printStr');
printStrWrapped('function');


$ 'function'
$ [ 'Test', 'debounced', 'printStr' ]

Contributing

Contributions are welcome! Please feel free to open issues and pull requests on GitHub.

License

This project is licensed under the MIT License.

1.0.9

5 months ago

1.0.10

5 months ago

1.0.8

1 year ago

1.0.7

1 year ago

1.0.6

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.3

1 year ago

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

1 year ago