2025-03-03 · Anthony Fu (antfu)

Async, Sync, in Between

commentary

read at source ↗ antfu.me

Async, Sync, in Between

Source: Anthony Fu (antfu) Date: 2025-03-03 URL: https://antfu.me/posts/async-sync-in-between

Summary

Architectural essay introducing Quansync — a JavaScript generator-based pattern for functions that adapt to their calling context (synchronous or asynchronous) without duplicate implementations. Addresses the “function coloring problem” where async cascades force library authors to maintain both findUp and findUpSync variants. Uses yield* to create “superposition” between sync/async states; also describes a build-time macro version using familiar async/await syntax transformed at compile time.

Implications

The function coloring problem is a real library design pain point — every package that currently ships paired fn/fnSync exports is a potential Quansync adopter. Whether Quansync achieves adoption depends on ecosystem momentum and tooling integration. The generator-based approach is clever but has a learning curve; the macro version is more approachable. Watch for adoption in the Vite/Vitest/Nuxt toolchain where Fu has the most influence to drive uptake.

← all signals