Skip to content

Commit a474158

Browse files
jmbroadst
authored andcommitted
fix(cursor): remove deprecated notice on forEach
1 parent a12aa15 commit a474158

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

lib/cursor.js

+8-2
Original file line numberDiff line numberDiff line change
@@ -729,8 +729,14 @@ Cursor.prototype.each = deprecate(function(callback) {
729729
* @return {Promise} if no callback supplied
730730
*/
731731
Cursor.prototype.forEach = function(iterator, callback) {
732+
// Rewind cursor state
733+
this.rewind();
734+
735+
// Set current cursor to INIT
736+
this.s.state = Cursor.INIT;
737+
732738
if (typeof callback === 'function') {
733-
this.each((err, doc) => {
739+
each(this, (err, doc) => {
734740
if (err) {
735741
callback(err);
736742
return false;
@@ -748,7 +754,7 @@ Cursor.prototype.forEach = function(iterator, callback) {
748754
});
749755
} else {
750756
return new this.s.promiseLibrary((fulfill, reject) => {
751-
this.each((err, doc) => {
757+
each(this, (err, doc) => {
752758
if (err) {
753759
reject(err);
754760
return false;

0 commit comments

Comments
 (0)