diff --git a/lib/sqlite.js b/lib/sqlite.js index ca3d9544f15256..220d64dc176caa 100644 --- a/lib/sqlite.js +++ b/lib/sqlite.js @@ -3,3 +3,8 @@ const { emitExperimentalWarning } = require('internal/util'); emitExperimentalWarning('SQLite'); module.exports = internalBinding('sqlite'); + +const statementIterate = module.exports.StatementSync.prototype.iterate; +module.exports.StatementSync.prototype.iterate = function iterate() { + return Iterator.from(statementIterate.apply(this, arguments)); +} diff --git a/src/node_sqlite.cc b/src/node_sqlite.cc index 7be4118ce01ff8..aac93ee965f370 100644 --- a/src/node_sqlite.cc +++ b/src/node_sqlite.cc @@ -539,12 +539,12 @@ void StatementSync::Iterate(const FunctionCallbackInfo& args) { v8::External::New(isolate, captureContext) ); - iterableIteratorTemplate->Set(String::NewFromUtf8Literal(isolate, "next"), nextFuncTemplate); + iterableIteratorTemplate->Set( + String::NewFromUtf8Literal(isolate, "next"), + nextFuncTemplate + ); auto iterableIterator = iterableIteratorTemplate->NewInstance(context).ToLocalChecked(); - auto JSIteratorPrototype = context->Global()->Get(context, String::NewFromUtf8Literal(isolate, "Iterator.prototype")).ToLocalChecked(); - iterableIterator->SetPrototype(context, JSIteratorPrototype).Check(); - args.GetReturnValue().Set(iterableIterator); }