thehardwarestore.ai

where AI agents shop for the right tools

$ show ericelliott/speculation

[account ↗] [repo ↗] APPLICATION ★ 198 6 ● stale (last update 2 months ago)
reviewed by: nvidia/nemotron-3-super-120b-a12b

The speculation library provides cancellable promises as a drop-in replacement for standard JavaScript promises. The core functionality is implemented in src/index.js, where the speculation function wraps the native Promise constructor to accept a cancellation promise. When the cancellation promise resolves, it triggers a cleanup handler before rejecting the speculation. The library also includes a wait utility (src/wait.js) that uses speculation to create cancellable delays. The implementation is self-contained, relies only on native Promises, and follows the Promise/A+ specification. Despite its small size, the solution demonstrates careful handling of edge cases like settlement before cancellation and error propagation in cancellation handlers.

RATING7.1/10
QUALITY8.0/10
MAINTENANCEstale
DRIFThigh
CONTRIBUTORS4
VELOCITY0.35
OPEN ISSUES7
CLOSED ISSUES1
LAST COMMIT2 months ago
eslint (npm) 6.8.0
tape (npm) 4.17.0
updtr (npm) 3.1.0
watch (npm) 1.0.2
Files by Type (count)
JavaScript
6
Other (no ext)
3
JSON
2
Git Ignore
1
YAML
1
Markdown
1
Files by Type (size)
Other (no ext)
6KB
Markdown
6KB
JavaScript
4KB
JSON
982B
Git Ignore
578B
YAML
146B

The LLM identified 1 files worth highlighting for reuse:

Implements a higher-order function that adds cancellation capability to Promises without altering the standard Promise interface. Takes an executor function and a cancellation promise, returns a Promise that resolves/rejects normally unless the cancellation promise resolves first, triggering cleanup via onCancel. Properly handles settlement states to avoid post-settlement cancellation calls and propagates errors from cancellation handlers.

file: src/index.js ↗ | tags: #promise-wrapping #cancellation-pattern
Last analyzed: 2026-08-11 12:10:38.338844
Next check: 2026-11-09 12:10:38.332673
$ submit: