Utilities provide immediate value across platforms without requiring design decisions or framework-specific implementations. They establish the foundation for cross-platform parity and can be used in any codebase. UI components will be considered in future phases once the utility layer is stable.
KompKit Core 0.4.0-alpha.0 currently provides:
debounce— Delay function execution until after a wait periodisEmail— Validate email addresses with a regex patternformatCurrency— Format numbers as localized currency stringsclamp— Constrain a number within an inclusive[min, max]rangethrottle— Limit a function to execute at most once per wait period
All utilities are available on Web (TypeScript), Android (Kotlin), and Flutter (Dart) with identical APIs.
Both limit how often a function runs, but in different ways:
debouncewaits until calls have stopped for the wait period before executing. Useful for search inputs — you only want to fire after the user stops typing.throttleexecutes immediately on the first call, then ignores further calls until the wait period has elapsed. Useful for scroll or resize handlers — you want regular updates but not on every single event.
Yes. Both return an object with a cancel() method that resets internal state immediately — no pending execution will fire after cancel() is called. Always call cancel() on component unmount or when the handler is no longer needed to avoid stale callbacks.
Both debounce and throttle throw immediately:
- TypeScript:
Error - Kotlin:
IllegalArgumentException - Dart:
ArgumentError
clamp throws a RangeError (TS) / IllegalArgumentException (Kotlin) / ArgumentError (Dart) if min > max or any argument is NaN / Infinity.
Yes. The web package is built with tsup and exports individual functions. Modern bundlers like Webpack, Vite, and Rollup will only include the utilities you import.
Yes. The formatCurrency utility accepts a locale parameter (e.g., "en-US", "es-ES", "ja-JP"). It uses Intl.NumberFormat on web, NumberFormat on Android, and the intl package on Flutter — all of which support standard BCP 47 locale tags.
Yes. debounce and throttle both require a CoroutineScope to manage their internal timing. This is a deliberate design choice — it integrates with Kotlin's structured concurrency so that pending work is automatically cancelled when the scope is cancelled (e.g., a viewModelScope or lifecycleScope). isEmail, formatCurrency, and clamp have no coroutine dependency.
Possibly. The current utilities are framework-agnostic and work directly in React, Vue, or vanilla JS. If specific hooks or composables would add value (e.g., useDebounce, useThrottle), they may be added as optional packages in the future.
Not yet. The library is at 0.4.0-alpha.0. APIs may change, and the test coverage is still expanding. Use it in experimental projects, but avoid production deployments until a stable 1.0.0 release.