From a4741589921074bdb94dee1f12792fbe13b17dbe Mon Sep 17 00:00:00 2001 From: Jordan Date: Fri, 24 Aug 2018 13:41:15 -0700 Subject: [PATCH] fix(cursor): remove deprecated notice on forEach --- lib/cursor.js | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/lib/cursor.js b/lib/cursor.js index d7cd06493f..69293213ec 100644 --- a/lib/cursor.js +++ b/lib/cursor.js @@ -729,8 +729,14 @@ Cursor.prototype.each = deprecate(function(callback) { * @return {Promise} if no callback supplied */ Cursor.prototype.forEach = function(iterator, callback) { + // Rewind cursor state + this.rewind(); + + // Set current cursor to INIT + this.s.state = Cursor.INIT; + if (typeof callback === 'function') { - this.each((err, doc) => { + each(this, (err, doc) => { if (err) { callback(err); return false; @@ -748,7 +754,7 @@ Cursor.prototype.forEach = function(iterator, callback) { }); } else { return new this.s.promiseLibrary((fulfill, reject) => { - this.each((err, doc) => { + each(this, (err, doc) => { if (err) { reject(err); return false;