quickjs-emscripten-sync 1.1.0 → 1.4.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +2 -2
- package/README.md +59 -49
- package/dist/index.d.ts +121 -26
- package/dist/quickjs-emscripten-sync.es.js +962 -0
- package/dist/quickjs-emscripten-sync.umd.js +64 -0
- package/package.json +28 -40
- package/src/default.ts +2 -2
- package/src/index.test.ts +371 -69
- package/src/index.ts +135 -72
- package/src/marshal/function.test.ts +70 -61
- package/src/marshal/function.ts +10 -9
- package/src/marshal/index.test.ts +135 -62
- package/src/marshal/index.ts +33 -16
- package/src/marshal/json.test.ts +94 -0
- package/src/marshal/json.ts +16 -0
- package/src/marshal/object.test.ts +65 -58
- package/src/marshal/object.ts +6 -5
- package/src/marshal/primitive.test.ts +23 -17
- package/src/marshal/primitive.ts +10 -9
- package/src/marshal/promise.test.ts +86 -0
- package/src/marshal/promise.ts +26 -0
- package/src/marshal/properties.test.ts +23 -19
- package/src/marshal/properties.ts +11 -10
- package/src/marshal/symbol.test.ts +9 -7
- package/src/marshal/symbol.ts +5 -4
- package/src/unmarshal/function.test.ts +70 -61
- package/src/unmarshal/function.ts +39 -30
- package/src/unmarshal/index.test.ts +101 -100
- package/src/unmarshal/index.ts +13 -9
- package/src/unmarshal/object.test.ts +45 -41
- package/src/unmarshal/object.ts +14 -13
- package/src/unmarshal/primitive.test.ts +20 -15
- package/src/unmarshal/primitive.ts +10 -10
- package/src/unmarshal/promise.test.ts +44 -0
- package/src/unmarshal/promise.ts +38 -0
- package/src/unmarshal/properties.test.ts +10 -8
- package/src/unmarshal/properties.ts +47 -42
- package/src/unmarshal/symbol.test.ts +9 -7
- package/src/unmarshal/symbol.ts +4 -4
- package/src/util.test.ts +23 -5
- package/src/util.ts +15 -0
- package/src/vmmap.test.ts +88 -82
- package/src/vmmap.ts +21 -17
- package/src/vmutil.test.ts +159 -53
- package/src/vmutil.ts +91 -19
- package/src/wrapper.test.ts +151 -115
- package/src/wrapper.ts +69 -48
- package/dist/default.d.ts +0 -4
- package/dist/index.js +0 -8
- package/dist/marshal/function.d.ts +0 -2
- package/dist/marshal/index.d.ts +0 -11
- package/dist/marshal/object.d.ts +0 -2
- package/dist/marshal/primitive.d.ts +0 -2
- package/dist/marshal/properties.d.ts +0 -2
- package/dist/marshal/symbol.d.ts +0 -2
- package/dist/quickjs-emscripten-sync.cjs.development.js +0 -1289
- package/dist/quickjs-emscripten-sync.cjs.development.js.map +0 -1
- package/dist/quickjs-emscripten-sync.cjs.production.min.js +0 -2
- package/dist/quickjs-emscripten-sync.cjs.production.min.js.map +0 -1
- package/dist/quickjs-emscripten-sync.esm.js +0 -1272
- package/dist/quickjs-emscripten-sync.esm.js.map +0 -1
- package/dist/unmarshal/function.d.ts +0 -2
- package/dist/unmarshal/index.d.ts +0 -9
- package/dist/unmarshal/object.d.ts +0 -2
- package/dist/unmarshal/primitive.d.ts +0 -2
- package/dist/unmarshal/properties.d.ts +0 -2
- package/dist/unmarshal/symbol.d.ts +0 -2
- package/dist/util.d.ts +0 -7
- package/dist/vmmap.d.ts +0 -35
- package/dist/vmutil.d.ts +0 -7
- package/dist/wrapper.d.ts +0 -11
package/src/util.ts
CHANGED
|
@@ -51,3 +51,18 @@ export function walkObject(
|
|
|
51
51
|
export function complexity(value: any, max?: number): number {
|
|
52
52
|
return walkObject(value, max ? (_, set) => set.size < max : undefined).size;
|
|
53
53
|
}
|
|
54
|
+
|
|
55
|
+
export function newDeferred<T = unknown>() {
|
|
56
|
+
let res: (v: T | PromiseLike<T>) => void = () => {};
|
|
57
|
+
let rej: (v: T | PromiseLike<T>) => void = () => {};
|
|
58
|
+
const promise = new Promise<T>((resolve, reject) => {
|
|
59
|
+
res = resolve;
|
|
60
|
+
rej = reject;
|
|
61
|
+
});
|
|
62
|
+
|
|
63
|
+
return {
|
|
64
|
+
promise,
|
|
65
|
+
resolve: res,
|
|
66
|
+
reject: rej,
|
|
67
|
+
};
|
|
68
|
+
}
|
package/src/vmmap.test.ts
CHANGED
|
@@ -1,29 +1,28 @@
|
|
|
1
1
|
import { getQuickJS } from "quickjs-emscripten";
|
|
2
|
+
import { expect, test } from "vitest";
|
|
3
|
+
|
|
2
4
|
import VMMap from "./vmmap";
|
|
3
5
|
import { call } from "./vmutil";
|
|
4
6
|
|
|
5
7
|
test("init and dispose", async () => {
|
|
6
|
-
const
|
|
7
|
-
const
|
|
8
|
-
|
|
9
|
-
const map = new VMMap(vm);
|
|
8
|
+
const ctx = (await getQuickJS()).newContext();
|
|
9
|
+
const map = new VMMap(ctx);
|
|
10
10
|
map.dispose();
|
|
11
|
-
|
|
11
|
+
ctx.dispose();
|
|
12
12
|
});
|
|
13
13
|
|
|
14
14
|
test("get and set", async () => {
|
|
15
|
-
const
|
|
16
|
-
const vm = quickjs.createVm();
|
|
15
|
+
const ctx = (await getQuickJS()).newContext();
|
|
17
16
|
|
|
18
17
|
const target = {};
|
|
19
|
-
const handle =
|
|
18
|
+
const handle = ctx.newObject();
|
|
20
19
|
|
|
21
|
-
const map = new VMMap(
|
|
20
|
+
const map = new VMMap(ctx);
|
|
22
21
|
expect(map.get(target)).toBe(undefined);
|
|
23
22
|
expect(map.set(target, handle)).toBe(true);
|
|
24
23
|
expect(map.get(target)).toBe(handle);
|
|
25
24
|
// a new handle that points to the same value
|
|
26
|
-
const handle2 = call(
|
|
25
|
+
const handle2 = call(ctx, `a => a`, undefined, handle);
|
|
27
26
|
expect(map.set(target, handle2)).toBe(false);
|
|
28
27
|
|
|
29
28
|
handle2.dispose();
|
|
@@ -31,18 +30,17 @@ test("get and set", async () => {
|
|
|
31
30
|
expect(map.get(target)).toBe(undefined);
|
|
32
31
|
|
|
33
32
|
map.dispose();
|
|
34
|
-
|
|
33
|
+
ctx.dispose();
|
|
35
34
|
});
|
|
36
35
|
|
|
37
36
|
test("getByHandle", async () => {
|
|
38
|
-
const
|
|
39
|
-
const vm = quickjs.createVm();
|
|
37
|
+
const ctx = (await getQuickJS()).newContext();
|
|
40
38
|
|
|
41
39
|
const target = {};
|
|
42
|
-
const handle =
|
|
43
|
-
const handle2 =
|
|
40
|
+
const handle = ctx.newObject();
|
|
41
|
+
const handle2 = ctx.newObject();
|
|
44
42
|
|
|
45
|
-
const map = new VMMap(
|
|
43
|
+
const map = new VMMap(ctx);
|
|
46
44
|
expect(map.getByHandle(handle)).toBe(undefined);
|
|
47
45
|
map.set(target, handle);
|
|
48
46
|
expect(map.getByHandle(handle)).toBe(target);
|
|
@@ -52,17 +50,35 @@ test("getByHandle", async () => {
|
|
|
52
50
|
|
|
53
51
|
handle2.dispose();
|
|
54
52
|
map.dispose();
|
|
55
|
-
|
|
53
|
+
ctx.dispose();
|
|
54
|
+
});
|
|
55
|
+
|
|
56
|
+
test("keys", async () => {
|
|
57
|
+
const ctx = (await getQuickJS()).newContext();
|
|
58
|
+
|
|
59
|
+
const target = {};
|
|
60
|
+
const handle = ctx.newObject();
|
|
61
|
+
const handle2 = ctx.newObject();
|
|
62
|
+
|
|
63
|
+
const map = new VMMap(ctx);
|
|
64
|
+
expect(Array.from(map.keys())).toEqual([]);
|
|
65
|
+
map.set(target, handle);
|
|
66
|
+
expect(Array.from(map.keys())).toEqual([target]);
|
|
67
|
+
handle.dispose();
|
|
68
|
+
expect(Array.from(map.keys())).toEqual([target]);
|
|
69
|
+
|
|
70
|
+
handle2.dispose();
|
|
71
|
+
map.dispose();
|
|
72
|
+
ctx.dispose();
|
|
56
73
|
});
|
|
57
74
|
|
|
58
75
|
test("delete", async () => {
|
|
59
|
-
const
|
|
60
|
-
const vm = quickjs.createVm();
|
|
76
|
+
const ctx = (await getQuickJS()).newContext();
|
|
61
77
|
|
|
62
78
|
const target = {};
|
|
63
|
-
const handle =
|
|
79
|
+
const handle = ctx.newObject();
|
|
64
80
|
|
|
65
|
-
const map = new VMMap(
|
|
81
|
+
const map = new VMMap(ctx);
|
|
66
82
|
map.set(target, handle);
|
|
67
83
|
expect(map.get(target)).toBe(handle);
|
|
68
84
|
map.delete({});
|
|
@@ -72,17 +88,16 @@ test("delete", async () => {
|
|
|
72
88
|
|
|
73
89
|
handle.dispose();
|
|
74
90
|
map.dispose();
|
|
75
|
-
|
|
91
|
+
ctx.dispose();
|
|
76
92
|
});
|
|
77
93
|
|
|
78
94
|
test("size", async () => {
|
|
79
|
-
const
|
|
80
|
-
const vm = quickjs.createVm();
|
|
95
|
+
const ctx = (await getQuickJS()).newContext();
|
|
81
96
|
|
|
82
97
|
const target = {};
|
|
83
|
-
const handle =
|
|
98
|
+
const handle = ctx.newObject();
|
|
84
99
|
|
|
85
|
-
const map = new VMMap(
|
|
100
|
+
const map = new VMMap(ctx);
|
|
86
101
|
expect(map.size).toBe(0);
|
|
87
102
|
map.set(target, handle);
|
|
88
103
|
expect(map.size).toBe(1);
|
|
@@ -90,17 +105,16 @@ test("size", async () => {
|
|
|
90
105
|
expect(map.size).toBe(1);
|
|
91
106
|
|
|
92
107
|
map.dispose();
|
|
93
|
-
|
|
108
|
+
ctx.dispose();
|
|
94
109
|
});
|
|
95
110
|
|
|
96
111
|
test("clear", async () => {
|
|
97
|
-
const
|
|
98
|
-
const vm = quickjs.createVm();
|
|
112
|
+
const ctx = (await getQuickJS()).newContext();
|
|
99
113
|
|
|
100
114
|
const target = {};
|
|
101
|
-
const handle =
|
|
115
|
+
const handle = ctx.newObject();
|
|
102
116
|
|
|
103
|
-
const map = new VMMap(
|
|
117
|
+
const map = new VMMap(ctx);
|
|
104
118
|
map.set(target, handle);
|
|
105
119
|
expect(map.size).toBe(1);
|
|
106
120
|
expect(map.get(target)).toBe(handle);
|
|
@@ -110,20 +124,19 @@ test("clear", async () => {
|
|
|
110
124
|
|
|
111
125
|
handle.dispose();
|
|
112
126
|
map.dispose();
|
|
113
|
-
|
|
127
|
+
ctx.dispose();
|
|
114
128
|
});
|
|
115
129
|
|
|
116
130
|
test("merge", async () => {
|
|
117
|
-
const
|
|
118
|
-
const vm = quickjs.createVm();
|
|
131
|
+
const ctx = (await getQuickJS()).newContext();
|
|
119
132
|
|
|
120
133
|
const target = {};
|
|
121
134
|
const target2 = {};
|
|
122
|
-
const handle =
|
|
123
|
-
const handle2 =
|
|
135
|
+
const handle = ctx.newObject();
|
|
136
|
+
const handle2 = ctx.newObject();
|
|
124
137
|
|
|
125
|
-
const map = new VMMap(
|
|
126
|
-
const map2 = new VMMap(
|
|
138
|
+
const map = new VMMap(ctx);
|
|
139
|
+
const map2 = new VMMap(ctx);
|
|
127
140
|
map.set(target, handle, target2, handle2);
|
|
128
141
|
expect(map.size).toBe(1);
|
|
129
142
|
expect(map.get(target)).toBe(handle);
|
|
@@ -137,19 +150,18 @@ test("merge", async () => {
|
|
|
137
150
|
map.clear();
|
|
138
151
|
map.dispose();
|
|
139
152
|
map2.dispose();
|
|
140
|
-
|
|
153
|
+
ctx.dispose();
|
|
141
154
|
});
|
|
142
155
|
|
|
143
156
|
test("iterator", async () => {
|
|
144
|
-
const
|
|
145
|
-
const vm = quickjs.createVm();
|
|
157
|
+
const ctx = (await getQuickJS()).newContext();
|
|
146
158
|
|
|
147
159
|
const target = {};
|
|
148
160
|
const target2 = {};
|
|
149
|
-
const handle =
|
|
150
|
-
const handle2 =
|
|
161
|
+
const handle = ctx.newObject();
|
|
162
|
+
const handle2 = ctx.newObject();
|
|
151
163
|
|
|
152
|
-
const map = new VMMap(
|
|
164
|
+
const map = new VMMap(ctx);
|
|
153
165
|
map.set(target, handle, target2, handle2);
|
|
154
166
|
|
|
155
167
|
const iter = map[Symbol.iterator]();
|
|
@@ -174,20 +186,19 @@ test("iterator", async () => {
|
|
|
174
186
|
expect(i).toBe(1);
|
|
175
187
|
|
|
176
188
|
map.dispose();
|
|
177
|
-
|
|
189
|
+
ctx.dispose();
|
|
178
190
|
});
|
|
179
191
|
|
|
180
192
|
test("get and set 2", async () => {
|
|
181
|
-
const
|
|
182
|
-
const vm = quickjs.createVm();
|
|
193
|
+
const ctx = (await getQuickJS()).newContext();
|
|
183
194
|
|
|
184
195
|
const target = {};
|
|
185
196
|
const target2 = {};
|
|
186
|
-
const handle =
|
|
187
|
-
const handle2 =
|
|
188
|
-
const handle3 = call(
|
|
197
|
+
const handle = ctx.newObject();
|
|
198
|
+
const handle2 = ctx.newObject();
|
|
199
|
+
const handle3 = call(ctx, `a => a`, undefined, handle);
|
|
189
200
|
|
|
190
|
-
const map = new VMMap(
|
|
201
|
+
const map = new VMMap(ctx);
|
|
191
202
|
|
|
192
203
|
map.set(target, handle, target2, handle2);
|
|
193
204
|
expect(map.get(target)).toBe(handle);
|
|
@@ -206,19 +217,18 @@ test("get and set 2", async () => {
|
|
|
206
217
|
expect(map.getByHandle(handle2)).toBe(undefined);
|
|
207
218
|
|
|
208
219
|
map.dispose();
|
|
209
|
-
|
|
220
|
+
ctx.dispose();
|
|
210
221
|
});
|
|
211
222
|
|
|
212
223
|
test("delete 2", async () => {
|
|
213
|
-
const
|
|
214
|
-
const vm = quickjs.createVm();
|
|
224
|
+
const ctx = (await getQuickJS()).newContext();
|
|
215
225
|
|
|
216
226
|
const target = {};
|
|
217
227
|
const target2 = {};
|
|
218
|
-
const handle =
|
|
219
|
-
const handle2 =
|
|
228
|
+
const handle = ctx.newObject();
|
|
229
|
+
const handle2 = ctx.newObject();
|
|
220
230
|
|
|
221
|
-
const map = new VMMap(
|
|
231
|
+
const map = new VMMap(ctx);
|
|
222
232
|
|
|
223
233
|
map.set(target, handle, target2, handle2);
|
|
224
234
|
expect(map.get(target)).toBe(handle);
|
|
@@ -236,19 +246,18 @@ test("delete 2", async () => {
|
|
|
236
246
|
handle.dispose();
|
|
237
247
|
handle2.dispose();
|
|
238
248
|
map.dispose();
|
|
239
|
-
|
|
249
|
+
ctx.dispose();
|
|
240
250
|
});
|
|
241
251
|
|
|
242
252
|
test("delete 3", async () => {
|
|
243
|
-
const
|
|
244
|
-
const vm = quickjs.createVm();
|
|
253
|
+
const ctx = (await getQuickJS()).newContext();
|
|
245
254
|
|
|
246
255
|
const target = {};
|
|
247
256
|
const target2 = {};
|
|
248
|
-
const handle =
|
|
249
|
-
const handle2 =
|
|
257
|
+
const handle = ctx.newObject();
|
|
258
|
+
const handle2 = ctx.newObject();
|
|
250
259
|
|
|
251
|
-
const map = new VMMap(
|
|
260
|
+
const map = new VMMap(ctx);
|
|
252
261
|
|
|
253
262
|
map.set(target, handle, target2, handle2);
|
|
254
263
|
expect(map.get(target)).toBe(handle);
|
|
@@ -266,19 +275,18 @@ test("delete 3", async () => {
|
|
|
266
275
|
handle.dispose();
|
|
267
276
|
handle2.dispose();
|
|
268
277
|
map.dispose();
|
|
269
|
-
|
|
278
|
+
ctx.dispose();
|
|
270
279
|
});
|
|
271
280
|
|
|
272
281
|
test("delete with dispose", async () => {
|
|
273
|
-
const
|
|
274
|
-
const vm = quickjs.createVm();
|
|
282
|
+
const ctx = (await getQuickJS()).newContext();
|
|
275
283
|
|
|
276
284
|
const target = {};
|
|
277
285
|
const target2 = {};
|
|
278
|
-
const handle =
|
|
279
|
-
const handle2 =
|
|
286
|
+
const handle = ctx.newObject();
|
|
287
|
+
const handle2 = ctx.newObject();
|
|
280
288
|
|
|
281
|
-
const map = new VMMap(
|
|
289
|
+
const map = new VMMap(ctx);
|
|
282
290
|
map.set(target, handle, target2, handle2);
|
|
283
291
|
map.delete(target, true);
|
|
284
292
|
|
|
@@ -286,19 +294,18 @@ test("delete with dispose", async () => {
|
|
|
286
294
|
expect(handle2.alive).toBe(false);
|
|
287
295
|
|
|
288
296
|
map.dispose();
|
|
289
|
-
|
|
297
|
+
ctx.dispose();
|
|
290
298
|
});
|
|
291
299
|
|
|
292
300
|
test("deleteByHandle", async () => {
|
|
293
|
-
const
|
|
294
|
-
const vm = quickjs.createVm();
|
|
301
|
+
const ctx = (await getQuickJS()).newContext();
|
|
295
302
|
|
|
296
303
|
const target = {};
|
|
297
304
|
const target2 = {};
|
|
298
|
-
const handle =
|
|
299
|
-
const handle2 =
|
|
305
|
+
const handle = ctx.newObject();
|
|
306
|
+
const handle2 = ctx.newObject();
|
|
300
307
|
|
|
301
|
-
const map = new VMMap(
|
|
308
|
+
const map = new VMMap(ctx);
|
|
302
309
|
map.set(target, handle, target2, handle2);
|
|
303
310
|
|
|
304
311
|
expect(map.getByHandle(handle)).toBe(target);
|
|
@@ -312,19 +319,18 @@ test("deleteByHandle", async () => {
|
|
|
312
319
|
handle.dispose();
|
|
313
320
|
handle2.dispose();
|
|
314
321
|
map.dispose();
|
|
315
|
-
|
|
322
|
+
ctx.dispose();
|
|
316
323
|
});
|
|
317
324
|
|
|
318
325
|
test("deleteByHandle with dispose", async () => {
|
|
319
|
-
const
|
|
320
|
-
const vm = quickjs.createVm();
|
|
326
|
+
const ctx = (await getQuickJS()).newContext();
|
|
321
327
|
|
|
322
328
|
const target = {};
|
|
323
329
|
const target2 = {};
|
|
324
|
-
const handle =
|
|
325
|
-
const handle2 =
|
|
330
|
+
const handle = ctx.newObject();
|
|
331
|
+
const handle2 = ctx.newObject();
|
|
326
332
|
|
|
327
|
-
const map = new VMMap(
|
|
333
|
+
const map = new VMMap(ctx);
|
|
328
334
|
map.set(target, handle, target2, handle2);
|
|
329
335
|
map.deleteByHandle(handle, true);
|
|
330
336
|
|
|
@@ -332,5 +338,5 @@ test("deleteByHandle with dispose", async () => {
|
|
|
332
338
|
expect(handle2.alive).toBe(false);
|
|
333
339
|
|
|
334
340
|
map.dispose();
|
|
335
|
-
|
|
341
|
+
ctx.dispose();
|
|
336
342
|
});
|
package/src/vmmap.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import type { QuickJSContext, QuickJSHandle } from "quickjs-emscripten";
|
|
2
2
|
|
|
3
3
|
export default class VMMap {
|
|
4
|
-
|
|
4
|
+
ctx: QuickJSContext;
|
|
5
5
|
_map1: Map<any, number> = new Map();
|
|
6
6
|
_map2: Map<any, number> = new Map();
|
|
7
7
|
_map3: Map<number, QuickJSHandle> = new Map();
|
|
@@ -14,12 +14,12 @@ export default class VMMap {
|
|
|
14
14
|
_mapClear: QuickJSHandle;
|
|
15
15
|
_counter = 0;
|
|
16
16
|
|
|
17
|
-
constructor(
|
|
18
|
-
this.
|
|
17
|
+
constructor(ctx: QuickJSContext) {
|
|
18
|
+
this.ctx = ctx;
|
|
19
19
|
|
|
20
|
-
const result =
|
|
20
|
+
const result = ctx
|
|
21
21
|
.unwrapResult(
|
|
22
|
-
|
|
22
|
+
ctx.evalCode(`() => {
|
|
23
23
|
const mapSym = new Map();
|
|
24
24
|
let map = new WeakMap();
|
|
25
25
|
let map2 = new WeakMap();
|
|
@@ -44,12 +44,12 @@ export default class VMMap {
|
|
|
44
44
|
};
|
|
45
45
|
}`)
|
|
46
46
|
)
|
|
47
|
-
.consume(fn => this._call(fn, undefined));
|
|
47
|
+
.consume((fn) => this._call(fn, undefined));
|
|
48
48
|
|
|
49
|
-
this._mapGet =
|
|
50
|
-
this._mapSet =
|
|
51
|
-
this._mapDelete =
|
|
52
|
-
this._mapClear =
|
|
49
|
+
this._mapGet = ctx.getProp(result, "get");
|
|
50
|
+
this._mapSet = ctx.getProp(result, "set");
|
|
51
|
+
this._mapDelete = ctx.getProp(result, "delete");
|
|
52
|
+
this._mapClear = ctx.getProp(result, "clear");
|
|
53
53
|
|
|
54
54
|
result.dispose();
|
|
55
55
|
|
|
@@ -84,13 +84,13 @@ export default class VMMap {
|
|
|
84
84
|
}
|
|
85
85
|
}
|
|
86
86
|
|
|
87
|
-
this.
|
|
87
|
+
this.ctx.newNumber(counter).consume((c) => {
|
|
88
88
|
this._call(
|
|
89
89
|
this._mapSet,
|
|
90
90
|
undefined,
|
|
91
91
|
handle,
|
|
92
92
|
c,
|
|
93
|
-
handle2 ?? this.
|
|
93
|
+
handle2 ?? this.ctx.undefined
|
|
94
94
|
);
|
|
95
95
|
});
|
|
96
96
|
|
|
@@ -132,7 +132,7 @@ export default class VMMap {
|
|
|
132
132
|
return;
|
|
133
133
|
}
|
|
134
134
|
return this._counterMap.get(
|
|
135
|
-
this.
|
|
135
|
+
this.ctx.getNumber(this._call(this._mapGet, undefined, handle))
|
|
136
136
|
);
|
|
137
137
|
}
|
|
138
138
|
|
|
@@ -144,6 +144,10 @@ export default class VMMap {
|
|
|
144
144
|
return typeof this.getByHandle(handle) !== "undefined";
|
|
145
145
|
}
|
|
146
146
|
|
|
147
|
+
keys() {
|
|
148
|
+
return this._map1.keys();
|
|
149
|
+
}
|
|
150
|
+
|
|
147
151
|
delete(key: any, dispose?: boolean) {
|
|
148
152
|
const num = this._map1.get(key) ?? this._map2.get(key);
|
|
149
153
|
if (typeof num === "undefined") return;
|
|
@@ -263,10 +267,10 @@ export default class VMMap {
|
|
|
263
267
|
thisArg: QuickJSHandle | undefined,
|
|
264
268
|
...args: QuickJSHandle[]
|
|
265
269
|
) {
|
|
266
|
-
return this.
|
|
267
|
-
this.
|
|
270
|
+
return this.ctx.unwrapResult(
|
|
271
|
+
this.ctx.callFunction(
|
|
268
272
|
fn,
|
|
269
|
-
typeof thisArg === "undefined" ? this.
|
|
273
|
+
typeof thisArg === "undefined" ? this.ctx.undefined : thisArg,
|
|
270
274
|
...args
|
|
271
275
|
)
|
|
272
276
|
);
|