Skip to content

Commit

Permalink
Check for last error on foreach.
Browse files Browse the repository at this point in the history
  • Loading branch information
sorribas committed Mar 21, 2015
1 parent 23c1a82 commit a27cdcc
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions lib/cursor.js
Original file line number Diff line number Diff line change
Expand Up @@ -91,6 +91,8 @@ Cursor.prototype.forEach = function(fn) {

var loop = function() {
self.next(function(err, obj) {
if (err) return fn(err);
if (!obj) return;
fn(err, obj);
loop();
});
Expand Down

0 comments on commit a27cdcc

Please sign in to comment.