Ever struggled with UI freezing on every keystroke or APIs getting hammered with duplicate calls? flowx-control solves exactly that.
What is flowx-control?
A zero-dependency TypeScript library that gives you precise control over function execution timing. Debounce, throttle, rate-limit, and more — all type-safe and tree-shakeable.
npm install flowx-control
bun add flowx-control
Core Features
Debounce
Delay execution until after calls stop:
import { debounce } from 'flowx-control';
const search = debounce(async (query: string) => {
const results = await api.search(query);
updateUI(results);
}, 300);
// Only fires 300ms after user stops typing
input.addEventListener('input', (e) => search(e.target.value));
Throttle
Limit execution to once per interval:
import { throttle } from 'flowx-control';
const onScroll = throttle(() => {
updateScrollPosition();
}, 100);
window.addEventListener('scroll', onScroll);
Rate Limit
Control how many calls per time window:
import { rateLimit } from 'flowx-control';
const apiCall = rateLimit(fetchData, {
maxCalls: 10,
windowMs: 1000 // 10 calls per second
});
Once
Execute only on first call:
import { once } from 'flowx-control';
const init = once(() => {
setupDatabase();
loadConfig();
});
init(); // runs
init(); // skipped
Why flowx-control?
- Zero dependencies
- Full TypeScript support with generics
- Works in Node.js, Bun, Deno, browsers, and edge runtimes
- Tiny bundle size
- Cancellable and flushable debounces
Works Everywhere
Tree-shakeable, dual ESM/CJS output. Drop it into any modern stack.
GitHub: https://github.com/Avinashvelu03/flowx-control
What flow control patterns do you use in your TypeScript projects?
Top comments (0)