Initial commit with files
Still need to fix the imports
This commit is contained in:
9
src/lib/utils/once.ts
Normal file
9
src/lib/utils/once.ts
Normal file
@@ -0,0 +1,9 @@
|
||||
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)
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user