- 6cbd9ee: Add dom and node exports in package.json exports field
-
cc33aa9: DOM-Specific Leaf Futures
Two new futures ship under
@michthemaker/futures/dom— a dedicated browser entrypoint built with no Node.js dependencies.Browser —
@michthemaker/futures/dom-
FetchFuture<T>— full HTTP client built onXMLHttpRequest. Nofetch, no Promises, no Node.js.- Same API surface as the Node version — drop-in familiar if you've used
@michthemaker/futures/node. - Supports
GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS. - Query params appended automatically via
queryoption. - Objects in
bodyareJSON.stringify'd automatically withContent-Type: application/json. - Configurable timeout via
xhr.timeout(default 30s). - Error taxonomy via
Result.Err:http,network,timeout,parse,aborted,invalid_url. networkabsorbs everything the browser won't tell you about — DNS failures, SSL errors, CORS blocks all come back asnetworksince XHR gives no further detail.- Response headers parsed from
getAllResponseHeaders()intoRecord<string, string>, keys lowercased. cancel()callsxhr.abort()— resolves withResult.Err({ kind: "aborted" }), safe to call at any point.
- Same API surface as the Node version — drop-in familiar if you've used
-
AnimationFrameFuture— wrapsrequestAnimationFrameas a lazy future. Resolves with the frame timestamp on the next animation frame.cancel()callscancelAnimationFrameand prevents resolution.
-
-
f5fac94: Poll-based async runtime for TypeScript — first real release
Here's everything that shipped:
Core
Future<T>— abstract base class, the whole runtime contract lives inpoll(waker). Nothing runs until you say so.Future.run(future, onComplete)— the one and only way to execute a future. Marks the instance as consumed so you can't accidentally run it twice.- Single-use enforcement — run a future twice and it throws. Intentional. Create a new instance.
Primitives
Ready<T>— resolves immediately with a known value. Great for kicking off chains or wrapping sync values in a future context.TimerFuture— lazysetTimeoutwrapper. The timer doesn't start until the future is polled. Supportscancel()to clear it early.YieldNow— yields one event loop tick viasetTimeout(fn, 0)then resolves. Handy when you need to let other work breathe in a tight chain.
Combinators
andThen(fn)— sequences two futures. The second doesn't start until the first resolves. Short-circuits the chain if the upstream resolves with aResult.Err— your callback is skipped and the error passes through as-is.Future.all([...])— runs futures concurrently, resolves when every one of them is done. Results come back as a tuple in the original order, fully typed.Future.race([...])— resolves with the first future to finish and immediately cancels the rest. All futures must share the same value type.
Cancellation
- Every
Futurehas acancel()method. Base is a no-op, leaf futures override it to clean up their resources. - Cancellation propagates through
andThen,all, andracechains — cancel the top and everything underneath gets cancelled too.
Result type
Result.Ok(value)/Result.Err(error)— errors as values, no try/catch anywhere.Result.isResult(value)— symbol-tagged runtime check so plain{ ok: true }objects don't accidentally match.
Node.js —
@michthemaker/futures/nodeFetchFuture<T>— full HTTP client on top ofnode:http/node:https. Nofetch, no Promises.- Supports
GET,POST,PUT,PATCH,DELETE,HEAD,OPTIONS. - Query params appended automatically. Objects in
bodyareJSON.stringify'd with the rightContent-Type. - Configurable timeout (default 30s).
- Full error taxonomy via
Result.Err:http,network,dns,timeout,parse,ssl,aborted,invalid_url. cancel()destroys the underlying socket — safe to call at any point.