8 lines
202 B
JavaScript
8 lines
202 B
JavaScript
|
function *repeat(seq, times) {
|
||
|
for(let i = 0; i < times; i++) yield *seq
|
||
|
}
|
||
|
function *alternate(a, delim) {
|
||
|
for(const x of a) { yield *[x, delim] }
|
||
|
}
|
||
|
Object.assign(module.exports, {repeat, alternate})
|