UNPKG

@graphiql/react

Version:

[Changelog](https://github.com/graphql/graphiql/blob/main/packages/graphiql-react/CHANGELOG.md) | [API Docs](https://graphiql-test.netlify.app/typedoc/modules/graphiql_react.html) | [NPM](https://www.npmjs.com/package/@graphiql/react)

22 lines (20 loc) 484 B
'use no memo'; /** * Provided a duration and a function, returns a new function which is called * `duration` milliseconds after the last call. */ export default function debounce<F extends (...args: any[]) => any>( duration: number, fn: F, ) { let timeout: number | null; return function (...args) { if (timeout) { window.clearTimeout(timeout); } timeout = window.setTimeout(() => { timeout = null; fn(...args); }, duration); } as F; }