MCPcopy
hub / github.com/sveltejs/svelte / once

Function once

packages/svelte/src/internal/client/dom/legacy/event-modifiers.js:59–69  ·  view source on GitHub ↗
(fn)

Source from the content-addressed store, hash-verified

57 * @returns {(event: Event, ...args: unknown[]) => void}
58 */
59export function once(fn) {
60 var ran = false;
61
62 return function (...args) {
63 if (ran) return;
64 ran = true;
65
66 // @ts-ignore
67 return fn?.apply(this, args);
68 };
69}
70
71/**
72 * Substitute for the `stopImmediatePropagation` event modifier

Callers

nothing calls this directly

Calls 1

applyMethod · 0.45

Tested by

no test coverage detected