Skip to content

delay ​

This is a delay function that accepts a function func and a delay wait in milliseconds, and returns a function that will call the provided function after the specified delay.

Added in v0.0.1

Usage ​

typescript
import { delay } from 'parsnip-kit'

const handler = () => console.log('Function call')
const delayed = delay(handler, 3000)
delayed()
// console.log is called after 3s

API ​

Type Parameter ​

ArgTypeDescription
Textends (...args: any[]) => anyFunction type

Arguments ​

ArgTypeOptionalDefaultDescription
funcTfalseundefinedThe function to delay
waitnumberfalseundefinedThe delay time (in milliseconds)

Returns ​

Type
(...args: Parameters<T>) => void