Question:
Is it possible to compose two generators into one generator like you would with compose
?
function* type(vals) {
for(const v of vals) {
yield v;
}
}
const bool = type([true, false]);
const str = type([
'',
undefined,
'Lorem',
'Lorem ipsum dolor sit amet, consectetur adipiscing elit.',
''
]);
const composeGenerator = () => {/*???*/};
const input = composeGenerator(bool,str);
console.log(input, 'yes');
for (const i of bool) {
console.log(i); // true, false
}
for (const i of str) {
console.log(i); // '', undefined, 'Lorem', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', ''
}
for (const i of input) {
console.log(i); // '', undefined, 'Lorem', 'Lorem ipsum dolor sit amet, consectetur adipiscing elit.', '', true, false
}