@eluvio/elv-docdash
Version:
A customized version of the Docdash JSDoc theme (https://github.com/clenemt/docdash)
18 lines (16 loc) • 356 B
JavaScript
/**
* Generate numbers in the Fibonacci sequence.
*
* @generator
* @function fibonacci
* @yields {number} The next number in the Fibonacci sequence.
*/
function *fibonacci(n) {
const infinite = !n && n !== 0;
let current = 0;
let next = 1;
while (infinite || n--) {
yield current;
[current, next] = [next, current + next];
}
}