@@ -12,6 +12,7 @@ import type {
12
12
EitherFFI ,
13
13
UInt32Pointer ,
14
14
JSValuePointerPointerPointer ,
15
+ JSVoidPointer ,
15
16
} from "@jitl/quickjs-ffi-types"
16
17
import { debugLog } from "./debug"
17
18
import type { JSPromiseState } from "./deferred-promise"
@@ -58,7 +59,6 @@ import type {
58
59
VmPropertyDescriptor ,
59
60
} from "./vm-interface"
60
61
import { QuickJSIterator } from "./QuickJSIterator"
61
- import { JSVoidPointer } from "@jitl/quickjs-ffi-types"
62
62
63
63
export type ContextResult < S > = DisposableResult < S , QuickJSHandle >
64
64
@@ -868,7 +868,17 @@ export class QuickJSContext
868
868
869
869
/**
870
870
* `Object.getOwnPropertyNames(handle)`.
871
- * Similar to the [standard semantics](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames).
871
+ * Similar to the [standard semantics](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Object/getOwnPropertyNames),
872
+ * but with extra, non-standard options for:
873
+ *
874
+ * - fetching array indexes as numbers
875
+ * - including symbols
876
+ * - only iterating over enumerable properties
877
+ *
878
+ * To emulate the standard, use these options:
879
+ * ```typescript
880
+ * context.getOwnPropertyNames(handle, { strings: true, numbersAsStrings: true })
881
+ * ```
872
882
*/
873
883
getOwnPropertyNames (
874
884
handle : QuickJSHandle ,
@@ -924,13 +934,13 @@ export class QuickJSContext
924
934
* }
925
935
* ```
926
936
*/
927
- getIterator ( handle : QuickJSHandle ) : ContextResult < QuickJSIterator > {
937
+ getIterator ( iterableHandle : QuickJSHandle ) : ContextResult < QuickJSIterator > {
928
938
const SymbolIterator = ( this . _SymbolIterator ??= this . memory . manage (
929
939
this . getWellKnownSymbol ( "iterator" ) ,
930
940
) )
931
941
return Scope . withScope ( ( scope ) => {
932
- const methodHandle = scope . manage ( this . getProp ( handle , SymbolIterator ) )
933
- const iteratorCallResult = this . callFunction ( methodHandle , handle )
942
+ const methodHandle = scope . manage ( this . getProp ( iterableHandle , SymbolIterator ) )
943
+ const iteratorCallResult = this . callFunction ( methodHandle , iterableHandle )
934
944
if ( iteratorCallResult . error ) {
935
945
return iteratorCallResult
936
946
}
0 commit comments