Skip to main content

@generator

Syntax

@generator

Overview

@generator marks a function as a generator. JSDoc detects function* syntax automatically, so this tag is mainly used to be explicit or when the generator pattern is not obvious.

Example

/**
* @generator
* @yields {number} Integers starting from 0.
*/
function* counter() {
let n = 0;
while (true) yield n++;
}

See also

Official reference: jsdoc.app/tags-generator