Skip to content

Commit 762e0dc

Browse files
committed
fix: js iterate method wrap Iterate into a Iterator.from
I did not found how to produce an iterator extending Iterator with v8. So I've done this part in js side.
1 parent bd9a192 commit 762e0dc

File tree

2 files changed

+9
-4
lines changed

2 files changed

+9
-4
lines changed

lib/sqlite.js

+5
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,8 @@ const { emitExperimentalWarning } = require('internal/util');
33

44
emitExperimentalWarning('SQLite');
55
module.exports = internalBinding('sqlite');
6+
7+
const statementIterate = module.exports.StatementSync.prototype.iterate;
8+
module.exports.StatementSync.prototype.iterate = function iterate() {
9+
return Iterator.from(statementIterate.apply(this, arguments));
10+
}

src/node_sqlite.cc

+4-4
Original file line numberDiff line numberDiff line change
@@ -539,12 +539,12 @@ void StatementSync::Iterate(const FunctionCallbackInfo<Value>& args) {
539539
v8::External::New(isolate, captureContext)
540540
);
541541

542-
iterableIteratorTemplate->Set(String::NewFromUtf8Literal(isolate, "next"), nextFuncTemplate);
542+
iterableIteratorTemplate->Set(
543+
String::NewFromUtf8Literal(isolate, "next"),
544+
nextFuncTemplate
545+
);
543546

544547
auto iterableIterator = iterableIteratorTemplate->NewInstance(context).ToLocalChecked();
545-
auto JSIteratorPrototype = context->Global()->Get(context, String::NewFromUtf8Literal(isolate, "Iterator.prototype")).ToLocalChecked();
546-
iterableIterator->SetPrototype(context, JSIteratorPrototype).Check();
547-
548548
args.GetReturnValue().Set(iterableIterator);
549549
}
550550

0 commit comments

Comments
 (0)