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 1
1
'use strict' ;
2
2
const {
3
+ SafeArrayIterator,
3
4
globalThis,
4
5
} = primordials ;
5
6
@@ -8,8 +9,13 @@ const { emitExperimentalWarning } = require('internal/util');
8
9
emitExperimentalWarning ( 'SQLite' ) ;
9
10
module . exports = internalBinding ( 'sqlite' ) ;
10
11
11
- const { Iterator } = globalThis ;
12
+ const { Iterator} = globalThis ;
12
13
const statementIterate = module . exports . StatementSync . prototype . iterate ;
13
14
module . 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
+ ) ;
15
21
} ;
Original file line number Diff line number Diff line change @@ -474,6 +474,10 @@ struct IterateCaptureContext {
474
474
StatementSync* stmt;
475
475
};
476
476
477
+ void IteratorFunc (const v8::FunctionCallbackInfo<v8::Value>& info) {
478
+ info.GetReturnValue ().Set (info.Holder ());
479
+ }
480
+
477
481
void StatementSync::IterateReturnCallback (
478
482
const FunctionCallbackInfo<Value>& args) {
479
483
Environment* env = Environment::GetCurrent (args);
@@ -584,11 +588,15 @@ void StatementSync::Iterate(const FunctionCallbackInfo<Value>& args) {
584
588
v8::FunctionTemplate::New (isolate,
585
589
StatementSync::IterateReturnCallback,
586
590
External::New (isolate, captureContext));
591
+ v8::Local<v8::FunctionTemplate> iteratorFuncTemplate =
592
+ v8::FunctionTemplate::New (isolate, IteratorFunc);
587
593
588
594
iterableIteratorTemplate->Set (String::NewFromUtf8Literal (isolate, " next" ),
589
595
nextFuncTemplate);
590
596
iterableIteratorTemplate->Set (String::NewFromUtf8Literal (isolate, " return" ),
591
597
returnFuncTemplate);
598
+ iterableIteratorTemplate->Set (v8::Symbol::GetIterator (isolate),
599
+ iteratorFuncTemplate);
592
600
593
601
auto iterableIterator =
594
602
iterableIteratorTemplate->NewInstance (context).ToLocalChecked ();
You can’t perform that action at this time.
0 commit comments