You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 

14 lines
278 B

export function once(callback, fallback = () => {}) {
let called = false
return function () {
if (! called) {
called = true
callback.apply(this, arguments)
} else {
fallback.apply(this, arguments)
}
}
}