Skip to content

Commit c7a2352

Browse files
authored
Merge pull request #35 from dmurvihill/issues/pausable-stream
Changes stream to implement the Readable interface
2 parents dbf77f8 + 321cfd7 commit c7a2352

File tree

1 file changed

+9
-3
lines changed

1 file changed

+9
-3
lines changed

src/firestore-query.js

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -110,13 +110,19 @@ MockFirestoreQuery.prototype.get = function () {
110110
};
111111

112112
MockFirestoreQuery.prototype.stream = function () {
113-
var stream = new Stream();
113+
var stream = new Stream.Transform({
114+
objectMode: true,
115+
transform: function (chunk, encoding, done) {
116+
this.push(chunk);
117+
done();
118+
}
119+
});
114120

115121
this.get().then(function (snapshots) {
116122
snapshots.forEach(function (snapshot) {
117-
stream.emit('data', snapshot);
123+
stream.write(snapshot);
118124
});
119-
stream.emit('end');
125+
stream.end();
120126
});
121127

122128
return stream;

0 commit comments

Comments
 (0)