Skip to content

Async functions

Chung Leong edited this page Mar 15, 2025 · 12 revisions

A Zig function becomes an async function on the JavaScript side when it accepts a Promise as an argument. Instead of being returned, the return value will be passed to the promise struct’s resolve() method.

A Generator argument works in a similar manner. Its turns a Zig function into an async generator function on the JavaScript side. Instead of one value, multiple values are returned asynchronously to the caller through the struct's yield() method.


Promise | Generator

Clone this wiki locally