Skip to content

Commit

Permalink
fix(cursor): remove deprecated notice on forEach
Browse files Browse the repository at this point in the history
  • Loading branch information
j authored and mbroadst committed Aug 25, 2018
1 parent a12aa15 commit a474158
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions lib/cursor.js
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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;
Expand Down

0 comments on commit a474158

Please sign in to comment.