pub trait Generator {
    type Yield: ToNapiValue;
    type Next: FromNapiValue;
    type Return: FromNapiValue;

    fn next(&mut self, value: Option<Self::Next>) -> Option<Self::Yield>;

    fn complete(&mut self, value: Option<Self::Return>) -> Option<Self::Yield> { ... }
    fn catch(
        &mut self,
        env: Env,
        value: Unknown
    ) -> Result<Option<Self::Yield>, Unknown> { ... } }
Expand description

Implement a Iterator for the JavaScript Class. This feature is an experimental feature and is not yet stable.

Required Associated Types

Required Methods

Handle the Generator.next() https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/next

Provided Methods

Implement complete to handle the Generator.return() https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/return

Implement catch to handle the Generator.throw() https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator/throw

Implementors