There is an async iterable
class Fasta {
    //read file line by line and yield a class based on every four lines
    constructor(path) {
        this.path = path
        const filestream = fs.createReadStream(this.path)
        if (this.path.match(/(\.fastq)|(\.fq)$/)) {
            this.filetype = 'fastq'
            this.handle = readline.createInterface({
                input: filestream,
                crlfDelay: Infinity
            })
        } else if (this.path.match(/\.gz$/)) {
            this.filetype = 'fqgz'
            this.handle = readline.createInterface({
                input: filestream.pipe(zlib.createGunzip()),
                crlfDelay: Infinity
            })
        }
    }
    async * [Symbol.asyncIterator]() {
        let counter = 0
        const rec = {0: '', 1: '', 2: '', 3: ''}
        for await (const line of this.handle) {
            if (counter < 3) {
                rec[counter] = line.trim()
                counter +=1
            } else if (counter == 3) {
                rec[counter] = line.trim()
                counter = 0
                yield new Dna(rec[0], rec[1], rec[3])
            }
        }
    }
}
and I want to do someting like this.
for await (const i of zip(new Fasta(args.filea), new Fasta(args.fileb))) {
// do the work
}
I've found several walkarouds here, but they all seem to be based on Array.map(). In this way I need to create an array to carry all the data. When the files are big, things go wrong.
I tried
async function * zip(fasta1, fasta2) {
    for await (const [i,j] of [fasta1, fasta2]) {
        yield [i,j]
    }
}
but it gave me a 'TypeError: .for is not iterable'.
Any help would be appreciated!
 
                        
Here's an async variation of my answer here: