@liaoys/debounce
TypeScript icon, indicating that this package has built-in type declarations

1.0.0 • Public • Published

@liaoys/debounce

A debounce function.

See example

Installation

npm install @liaoys/debounce

Usage

import debounce from '@liaoys/debounce'

const debounceHandler = debounce((e) => {
  console.log(e.target.scrollTop)
}, 200)

window.addEventListener('scroll', debounceHandler);

API

debounce(callback: (...args: any[]) => void, delay?: number): (...args: any[]) => void

Returns Function

Debounce execution of a function.

callback

Type: Function

The original function executed after delay milliseconds.

delay

Type: number

Default: 100

Debounce delay. Unit: ms.

Readme

Keywords

Package Sidebar

Install

npm i @liaoys/debounce

Weekly Downloads

0

Version

1.0.0

License

ISC

Unpacked Size

18.4 kB

Total Files

35

Last publish

Collaborators

  • liaoyuesheng