Socket
Socket
Sign inDemoInstall

use-debounce

Package Overview
Dependencies
3
Maintainers
1
Versions
75
Alerts
File Explorer

Advanced tools

Install Socket

Detect and block malicious and high-risk dependencies

Install

Comparing version 8.0.1 to 8.0.2

4

dist/index.d.ts
import useDebounce from './useDebounce';
import useDebouncedCallback from './useDebouncedCallback';
import useDebouncedCallback, { CallOptions, ControlFunctions, DebouncedState, Options } from './useDebouncedCallback';
import useThrottledCallback from './useThrottledCallback';
export { useDebounce, useDebouncedCallback, useThrottledCallback };
export { useDebounce, useDebouncedCallback, useThrottledCallback, CallOptions, ControlFunctions, DebouncedState, Options, };
export interface CallOptions {
/**
* Controls if the function should be invoked on the leading edge of the timeout.
*/
leading?: boolean;
/**
* Controls if the function should be invoked on the trailing edge of the timeout.
*/
trailing?: boolean;
}
export interface Options extends CallOptions {
/**
* The maximum time the given function is allowed to be delayed before it's invoked.
*/
maxWait?: number;
}
export interface ControlFunctions {
/**
* Cancel pending function invocations
*/
cancel: () => void;
/**
* Immediately invoke pending function invocations
*/
flush: () => void;
/**
* Returns `true` if there are any pending function invocations
*/
isPending: () => boolean;

@@ -23,10 +41,14 @@ }

* milliseconds have elapsed since the last time the debounced function was
* invoked, or until the next browser frame is drawn. The debounced function
* comes with a `cancel` method to cancel delayed `func` invocations and a
* `flush` method to immediately invoke them. Provide `options` to indicate
* whether `func` should be invoked on the leading and/or trailing edge of the
* `wait` timeout. The `func` is invoked with the last arguments provided to the
* debounced function. Subsequent calls to the debounced function return the
* result of the last `func` invocation.
* invoked, or until the next browser frame is drawn.
*
* The debounced function comes with a `cancel` method to cancel delayed `func`
* invocations and a `flush` method to immediately invoke them.
*
* Provide `options` to indicate whether `func` should be invoked on the leading
* and/or trailing edge of the `wait` timeout. The `func` is invoked with the
* last arguments provided to the debounced function.
*
* Subsequent calls to the debounced function return the result of the last
* `func` invocation.
*
* **Note:** If `leading` and `trailing` options are `true`, `func` is

@@ -52,7 +74,7 @@ * invoked on the trailing edge of the timeout only if the debounced function

* @param {Object} [options={}] The options object.
* Specify invoking on the leading edge of the timeout.
* Controls if `func` should be invoked on the leading edge of the timeout.
* @param {boolean} [options.leading=false]
* The maximum time `func` is allowed to be delayed before it's invoked.
* @param {number} [options.maxWait]
* Specify invoking on the trailing edge of the timeout.
* Controls if `func` should be invoked the trailing edge of the timeout.
* @param {boolean} [options.trailing=true]

@@ -59,0 +81,0 @@ * @returns {Function} Returns the new debounced function.

import { CallOptions, DebouncedState } from './useDebouncedCallback';
/**
* Creates a throttled function that only invokes `func` at most once per
* every `wait` milliseconds (or once per browser frame). The throttled function
* comes with a `cancel` method to cancel delayed `func` invocations and a
* `flush` method to immediately invoke them. Provide `options` to indicate
* whether `func` should be invoked on the leading and/or trailing edge of the
* `wait` timeout. The `func` is invoked with the last arguments provided to the
* throttled function. Subsequent calls to the throttled function return the
* result of the last `func` invocation.
* every `wait` milliseconds (or once per browser frame).
*
* The throttled function comes with a `cancel` method to cancel delayed `func`
* invocations and a `flush` method to immediately invoke them.
*
* Provide `options` to indicate whether `func` should be invoked on the leading
* and/or trailing edge of the `wait` timeout. The `func` is invoked with the
* last arguments provided to the throttled function.
*
* Subsequent calls to the throttled function return the result of the last
* `func` invocation.
*
* **Note:** If `leading` and `trailing` options are `true`, `func` is

@@ -13,0 +17,0 @@ * invoked on the trailing edge of the timeout only if the throttled function

{
"name": "use-debounce",
"version": "8.0.1",
"version": "8.0.2",
"description": "Debounce hook for react",

@@ -5,0 +5,0 @@ "source": "src/index.ts",

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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