zigar.function.Generator(T, allocating) - chung-leong/zigar GitHub Wiki

Define a generator type that will act as an interface to a JavaScript async generator object. When yield() is called with a value, the generate returns a value on the JavaScript side. When the function is given an error instead, then the generator throws.

Arguments:

  • T: type
    Payload type. Must be an optional type.
  • allocating: bool Whether an allocator should be attached to the generator.

Struct fields:

  • allocator: std.mem.Allocator Source of memory for generated items. Each time yield() is called, previously allocated memory get released. It's present only if allocating is true.
  • ptr: ?*anyopaque
    Optional opaque pointer that gets passed to callback. Default to null.
  • callback *const fn (?*anyopaque, T) void
    Pointer to callback function that's called by yield().

Constants:

  • payload = T

Functions:


Generator