Callforth is a lightweight utility library designed to streamline common asynchronous JavaScript patterns by converting them into Promise-based operations. Currently at version 0.4.0, it offers a small collection of functions to replace traditional callback APIs, enabling developers to leverage `async/await` syntax for cleaner, more readable code. Its primary utilities include `eventOn` for awaiting specific events on any `EventTarget`, `timeout` for promise-based delays, and `polling` for repeatedly checking a predicate until it returns true or a maximum number of tries is reached. The library differentiates itself by focusing on simplifying frequently re-implemented patterns into a tiny, focused package, aiming to provide a 'don't callback, callforth' experience. There isn't a specified strict release cadence, but as a pre-1.0.0 project, updates are likely as needed.
npm install callforthVerified import paths — ran on the pinned version, not inferred.
Demonstrates `eventOn` to asynchronously load a script and wait for its 'load' or 'error' event, combined with `timeout` for controlled delays, showcasing common browser-side async patterns.
Always review the changelog when updating minor versions. Consider pinning to exact versions or exercising caution with automatic updates in production environments.
If continuous listening is required, you must re-call `eventOn` or use standard `addEventListener` for persistent behavior. `eventOn` is best suited for 'one-shot' event waiting.
Change `const { symbol } = require('callforth')` to `import { symbol } from 'callforth'`.Ensure the `target` parameter for `eventOn` is an object that correctly implements the `EventTarget` interface, such as `document.body`, `window`, or a `new EventTarget()` instance.
No dependency data recorded yet.