From d6481502659136ba64f8280d92a087456706eecf Mon Sep 17 00:00:00 2001 From: Magnus Hoff Date: Fri, 3 Jun 2016 21:44:42 +0200 Subject: [PATCH] Keep producing data as long as Readable.push wants more --- index.js | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index 03fd35c..30c5034 100644 --- a/index.js +++ b/index.js @@ -15,13 +15,14 @@ StreamGenerators.prototype = Object.create(Readable.prototype, {constructor: {va StreamGenerators.prototype._read = function(size) { try { - var r = this._g.next(); + do { + var r = this._g.next(); - if (false === r.done) { - this.push(r.value); - } else { - this.push(null); - } + if (r.done) { + this.push(null); + break; + } + } while (this.push(r.value)); } catch (e) { this.emit('error', e); }