once
Enforces that a function is only callable one time.
Usage
ts
import { once } from '@screaming/utils'
const ribbit = once(() => {
console.log('ribbit')
})
ribbit()
// logs "ribbit"
ribbit()
// logs nothing
1
2
3
4
5
6
7
8
9
10
11
2
3
4
5
6
7
8
9
10
11
Type Definitions
ts
/**
* @param fn - The function.
* @returns The one-time callable function.
*/
export declare function once(fn: (...args: any[]) => void): (...args: any[]) => void
1
2
3
4
5
2
3
4
5