package.src.utils.once.js Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of alpinejs Show documentation
Show all versions of alpinejs Show documentation
The rugged, minimal JavaScript framework
export function once(callback, fallback = () => {}) {
let called = false
return function () {
if (! called) {
called = true
callback.apply(this, arguments)
} else {
fallback.apply(this, arguments)
}
}
}