Commit 8d777288 authored by David Votrubec's avatar David Votrubec

Added basic example, 00

parent b7673d55
"use strict";
/**
* Generator is a pauseable function
* so let's show some really basic example of pausing and resuming
*/
function* myGenerator() {
yield 1;
yield 2;
yield 3;
}
// create instance of an iterator
const it = myGenerator();
// Then iterate
console.log(it.next()); // outputs {value: 1, done: false}
console.log(it.next()); // outputs {value: 2, done: false}
console.log(it.next()); // outputs {value: 3, done: false}
console.log(it.next()); // outputs {value: undefined, done: true}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment