Files
svelte-headlessui/src/lib/utils/once.ts
Ryan Gossiaux db9ec57065 Initial commit with files
Still need to fix the imports
2021-12-13 17:13:47 -08:00

10 lines
216 B
TypeScript

export function once<T>(cb: (...args: T[]) => void) {
let state = { called: false }
return (...args: T[]) => {
if (state.called) return
state.called = true
return cb(...args)
}
}