Socket
Socket
Sign inDemoInstall

debounce-fn

Package Overview
Dependencies
Maintainers
1
Versions
13
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

debounce-fn - npm Package Compare versions

Comparing version 5.1.2 to 6.0.0

24

index.d.ts

@@ -1,2 +0,2 @@

export interface Options {
export type Options = {
/**

@@ -33,17 +33,17 @@ Time in milliseconds to wait until the `input` function is called.

readonly after?: boolean;
}
};
export interface BeforeOptions extends Options {
export type BeforeOptions = {
readonly before: true;
}
} & Options;
export interface NoBeforeNoAfterOptions extends Options {
export type NoBeforeNoAfterOptions = {
readonly after: false;
readonly before?: false;
}
} & Options;
export interface DebouncedFunction<ArgumentsType extends unknown[], ReturnType> {
export type DebouncedFunction<ArgumentsType extends unknown[], ReturnType> = {
(...arguments: ArgumentsType): ReturnType;
cancel(): void;
}
};

@@ -67,3 +67,3 @@ /**

*/
declare function debounceFn<ArgumentsType extends unknown[], ReturnType>(
export default function debounceFn<ArgumentsType extends unknown[], ReturnType>(
input: (...arguments: ArgumentsType) => ReturnType,

@@ -73,3 +73,3 @@ options: BeforeOptions

declare function debounceFn<ArgumentsType extends unknown[], ReturnType>(
export default function debounceFn<ArgumentsType extends unknown[], ReturnType>(
input: (...arguments: ArgumentsType) => ReturnType,

@@ -79,7 +79,5 @@ options: NoBeforeNoAfterOptions

declare function debounceFn<ArgumentsType extends unknown[], ReturnType>(
export default function debounceFn<ArgumentsType extends unknown[], ReturnType>(
input: (...arguments: ArgumentsType) => ReturnType,
options?: Options
): DebouncedFunction<ArgumentsType, ReturnType | undefined>;
export default debounceFn;

@@ -1,4 +0,4 @@

import mimicFn from 'mimic-fn';
import mimicFunction from 'mimic-function';
const debounceFn = (inputFunction, options = {}) => {
const debounceFunction = (inputFunction, options = {}) => {
if (typeof inputFunction !== 'function') {

@@ -15,2 +15,6 @@ throw new TypeError(`Expected the first argument to be a function, got \`${typeof inputFunction}\``);

if (wait < 0 || maxWait < 0) {
throw new RangeError('`wait` and `maxWait` must not be negative.');
}
if (!before && !after) {

@@ -68,3 +72,3 @@ throw new Error('Both `before` and `after` are false, function wouldn\'t be called.');

mimicFn(debouncedFunction, inputFunction);
mimicFunction(debouncedFunction, inputFunction);

@@ -86,2 +90,2 @@ debouncedFunction.cancel = () => {

export default debounceFn;
export default debounceFunction;
{
"name": "debounce-fn",
"version": "5.1.2",
"version": "6.0.0",
"description": "Debounce a function",

@@ -14,5 +14,9 @@ "license": "MIT",

"type": "module",
"exports": "./index.js",
"exports": {
"types": "./index.d.ts",
"default": "./index.js"
},
"sideEffects": false,
"engines": {
"node": ">=12"
"node": ">=18"
},

@@ -37,10 +41,10 @@ "scripts": {

"dependencies": {
"mimic-fn": "^4.0.0"
"mimic-function": "^5.0.0"
},
"devDependencies": {
"ava": "^3.15.0",
"delay": "^5.0.0",
"tsd": "^0.19.1",
"xo": "^0.47.0"
"ava": "^5.3.1",
"delay": "^6.0.0",
"tsd": "^0.29.0",
"xo": "^0.56.0"
}
}

@@ -14,5 +14,5 @@ # debounce-fn

```js
import debounceFn from 'debounce-fn';
import debounceFunction from 'debounce-fn';
window.onresize = debounceFn(() => {
window.onresize = debounceFunction(() => {
// Do something on window resize

@@ -24,3 +24,3 @@ }, {wait: 100});

### debounceFn(input, options?)
### debounceFunction(input, options?)

@@ -27,0 +27,0 @@ 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.

SocketSocket SOC 2 Logo

Product

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

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc