UNPKG

rvx

Version:

A signal based rendering library

15 lines 509 B
import { $, teardown, watchUpdates } from "../core/signals.js"; export function debounce(source, delay) { const input = $(source.value, source); watchUpdates(input, value => { if (!Object.is(source.value, value)) { const timeout = setTimeout(() => { source.value = value; }, delay); teardown(() => clearTimeout(timeout)); } }); watchUpdates(source, value => { input.value = value; }); return input; } //# sourceMappingURL=debounce.js.map