class
Wrap a Zig struct as a JS class. The first argument is the JS-visible class name; the second is the Zig type.
For the conceptual model, see Classes.
Recognized members
init may also return !T to make construction fallible. Env is recognized in the constructor's first slot and any method's second slot, and does not consume a JS argument.
A next taking only self (plus optional Env) and returning an optional (or !?Item) makes instances iterable: they work with for..of, spread, and Array.from, and the generated .d.ts declares [Symbol.iterator](): IterableIterator<Item>. next is still exposed as a regular method. See Classes › Iterators.
Allocation
The instance is heap-allocated once (on std.heap.smp_allocator) during new and reused across every method call. Released automatically when JS collects the wrapper, after running deinit if defined.
If your fields hold long-lived allocations (strings, slices, file handles), free them in deinit. The arena from env.allocator() is per-call only and is not suitable for instance state.