UNPKG

@tanstack/db

Version:

A reactive client store for building super fast apps on sync

32 lines (31 loc) • 835 B
"use strict"; Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" }); const liteDebouncer = require("@tanstack/pacer-lite/lite-debouncer"); function debounceStrategy(options) { const trailing = options.trailing ?? true; const debouncer = new liteDebouncer.LiteDebouncer( (callback) => callback(), { ...options, leading: options.leading ?? false, trailing } ); return { _type: `debounce`, options, execute: (fn) => { const execution = { happened: false }; debouncer.maybeExecute(() => { execution.happened = true; return fn(); }); if (!trailing && !execution.happened) return false; return; }, cleanup: () => { } }; } exports.debounceStrategy = debounceStrategy; //# sourceMappingURL=debounceStrategy.cjs.map