Something went wrong. Try again.
[READ-ONLY] Mirror of https://github.com/Aquaticat/Monochromatic. TypeScript and Rust monorepo: Claude Code and Pi coding-agent plugins, a m
Something went wrong. Try again.
2 folders · 5 files
README.md
module-async-time #
Ready to publish.
Async timing primitives.
Helpers #
| Function | Behavior |
|---|---|
| `wait` | Resolves after a delay in milliseconds; thin `setTimeout` wrapper |
| `withTimeout` | Races a promise against a deadline; rejects with a labeled `Error` if the deadline wins |
Usage #
import {
wait,
withTimeout,
} from '@monochromatic-dev/module-async-time';
await wait(500,);
const data = await withTimeout({
promise: fetch('/api/data',),
ms: 5000,
label: 'fetch user data',
},);
Design decisions #
- **Source-only.
** No build step;
consumers import directly from
src/index.ts. - **Direct named exports.
** No
$aliasing. - **One file per helper.
**
wait.ts,with-timeout.ts;index.tsre-exports. - **Family scope.
** This package owns deadline- and delay-based async primitives.
Future additions (
debounce,throttle,retry-with-backoff,cancelable-after) belong here as long as their core abstraction is "operate against a duration. " - **Extracted from
module-es. ** Previously lived att object/t promise/f/{t number/wait, t object/withTimeout}/r a/p p/index.tsand was exposed via the./waitand./with-timeoutsubpath exports. Promoting to its own package makes the dep edge honest at thepackage.jsonlevel: consumers that only need an async timer no longer advertise amodule-esdependency.