JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 487264
  • Score
    100M100P100Q171108F
  • License MIT

TypeScript implementation of debounce

Package Exports

  • ts-debounce

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (ts-debounce) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

TypeScript implementation of debounce function Build Status

Debounce create a new function g, which when called will delay the invocation of the original function f until n milliseconds after it was last called.

It's very useful for scenarios where it's better to limit the number of times the function is called. E.g. think of search input which fetches data from API. It's enough display search results after user stopped entering characters for some time.

Function arguments

import { debounce } from 'ts-debounce';

const debouncedFunction = debounce(originalFunction, waitMilliseconds, options);
  • originalFunction
    • the function which we want to debounce
  • waitMilliseconds
    • how many seconds must pass after most recent function call, for the original function to be called
  • options
    • options object supports now one argument
    • isImmediate
      • if set to true then originalFunction will be called immediately, but on subsequent calls of the debounced function original function won't be called, unless waitMilliseconds passed after last call

Credits & inspiration

This implementation is based upon following sources:

Contributors


Karol Majewski

💻

Fabien Rogeret

💻