Custom iterable builder
const MyIterable = createIterableBuilder(function* (count: number) { for (let i = 0; i < count; i++) { const response: string = yield i + 1; // yield number; receive string }});const myIterable = MyIterable(3);for (const trial of myIterable) { // set current trial response to calculate next value myIterable.response(`Response to ${trial}`);} Copy
const MyIterable = createIterableBuilder(function* (count: number) { for (let i = 0; i < count; i++) { const response: string = yield i + 1; // yield number; receive string }});const myIterable = MyIterable(3);for (const trial of myIterable) { // set current trial response to calculate next value myIterable.response(`Response to ${trial}`);}
Example
Custom iterable builder