Summary
The short answer to the question "What is a generator?" is:Generators are pull streams in JavaScript. You will see code examples for pull streams soon when you're going to see generator code.
Promises in JavaScript exhibit eager evaluation for several reasons. Eager means data is evaluated immediately, regardless of whether the result is needed in that moment. LazyLazy means only evaluated when the value is needed (not before)
The processData function never runs and you never see "Processing 5" This shows that the expression only evaluates what is needed to get the result.
Function* numberGenerator() yields values based on the input it receives. If a value is not found, the generator is considered to be done and marks it as such. If the generator fails to yield a value, it is marked as "unusable"
Sagas are a prime example of handling asynchronous I/O operations. But you're going to learn how to use sagas in a future article.
The position of the main user in the test is unknown in the sortedUsers array. This allows the test to dynamically assign each user a unique role from a predefined list.