File tree Expand file tree Collapse file tree 2 files changed +16
-2
lines changed
Expand file tree Collapse file tree 2 files changed +16
-2
lines changed Original file line number Diff line number Diff line change 11'use strict' ;
22const {
3+ SafeArrayIterator,
34 globalThis,
45} = primordials ;
56
@@ -8,8 +9,13 @@ const { emitExperimentalWarning } = require('internal/util');
89emitExperimentalWarning ( 'SQLite' ) ;
910module . exports = internalBinding ( 'sqlite' ) ;
1011
11- const { Iterator } = globalThis ;
12+ const { Iterator} = globalThis ;
1213const statementIterate = module . exports . StatementSync . prototype . iterate ;
1314module . exports . StatementSync . prototype . iterate = function iterate ( ) {
14- return Iterator . from ( statementIterate . apply ( this , arguments ) ) ;
15+ return new SafeArrayIterator ( statementIterate . apply ( this , arguments ) ) ;
16+ return statementIterate . apply ( this , arguments ) ;
17+ return Iterator . from (
18+ statementIterate . apply ( this , arguments )
19+ // new SafeArrayIterator(statementIterate.apply(this, arguments))
20+ ) ;
1521} ;
Original file line number Diff line number Diff line change @@ -474,6 +474,10 @@ struct IterateCaptureContext {
474474 StatementSync* stmt;
475475};
476476
477+ void IteratorFunc (const v8::FunctionCallbackInfo<v8::Value>& info) {
478+ info.GetReturnValue ().Set (info.Holder ());
479+ }
480+
477481void StatementSync::IterateReturnCallback (
478482 const FunctionCallbackInfo<Value>& args) {
479483 Environment* env = Environment::GetCurrent (args);
@@ -584,11 +588,15 @@ void StatementSync::Iterate(const FunctionCallbackInfo<Value>& args) {
584588 v8::FunctionTemplate::New (isolate,
585589 StatementSync::IterateReturnCallback,
586590 External::New (isolate, captureContext));
591+ v8::Local<v8::FunctionTemplate> iteratorFuncTemplate =
592+ v8::FunctionTemplate::New (isolate, IteratorFunc);
587593
588594 iterableIteratorTemplate->Set (String::NewFromUtf8Literal (isolate, " next" ),
589595 nextFuncTemplate);
590596 iterableIteratorTemplate->Set (String::NewFromUtf8Literal (isolate, " return" ),
591597 returnFuncTemplate);
598+ iterableIteratorTemplate->Set (v8::Symbol::GetIterator (isolate),
599+ iteratorFuncTemplate);
592600
593601 auto iterableIterator =
594602 iterableIteratorTemplate->NewInstance (context).ToLocalChecked ();
You can’t perform that action at this time.
0 commit comments