Socket
Socket
Sign inDemoInstall

debounce-fn

Package Overview
Dependencies
1
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

    debounce-fn

Debounce a function


Version published
Maintainers
1
Install size
16.3 kB
Created

Readme

Source

debounce-fn Build Status

Debounce a function

Install

$ npm install debounce-fn

Usage

const debounceFn = require('debounce-fn');

window.onresize = debounceFn(() => {
	// Do something on window resize
}, {wait: 100});

API

debounceFn(input, options?)

Returns a debounced function that delays calling the input function until after wait milliseconds have elapsed since the last time the debounced function was called.

It comes with a .cancel() method to cancel any scheduled input function calls.

input

Type: Function

Function to debounce.

options

Type: object

wait

Type: number
Default: 0

Time to wait until the input function is called.

before

Type: boolean
Default: false

Trigger the function on the leading edge of the wait interval.

For example, can be useful for preventing accidental double-clicks on a "submit" button from firing a second time.

after

Type: boolean
Default: true

Trigger the function on the trailing edge of the wait interval.

  • p-debounce - Debounce promise-returning & async functions

Keywords

FAQs

Last updated on 19 Feb 2020

Did you know?

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc