quickjs-emscripten-sync 1.3.0 → 1.5.1
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/README.md +60 -37
- package/dist/index.d.ts +29 -22
- package/dist/quickjs-emscripten-sync.mjs +842 -0
- package/dist/quickjs-emscripten-sync.umd.js +15 -15
- package/package.json +12 -21
- package/src/default.ts +2 -2
- package/src/index.test.ts +159 -65
- package/src/index.ts +67 -66
- package/src/marshal/custom.test.ts +50 -0
- package/src/marshal/custom.ts +36 -0
- package/src/marshal/function.test.ts +60 -72
- package/src/marshal/function.ts +15 -18
- package/src/marshal/index.test.ts +88 -84
- package/src/marshal/index.ts +16 -18
- package/src/marshal/json.test.ts +32 -38
- package/src/marshal/json.ts +5 -7
- package/src/marshal/object.test.ts +52 -79
- package/src/marshal/object.ts +8 -15
- package/src/marshal/primitive.test.ts +16 -21
- package/src/marshal/primitive.ts +11 -10
- package/src/marshal/promise.test.ts +21 -22
- package/src/marshal/promise.ts +6 -13
- package/src/marshal/properties.test.ts +21 -26
- package/src/marshal/properties.ts +15 -17
- package/src/unmarshal/custom.test.ts +50 -0
- package/src/unmarshal/custom.ts +31 -0
- package/src/unmarshal/function.test.ts +52 -74
- package/src/unmarshal/function.ts +13 -22
- package/src/unmarshal/index.test.ts +58 -50
- package/src/unmarshal/index.ts +12 -13
- package/src/unmarshal/object.test.ts +37 -43
- package/src/unmarshal/object.ts +16 -20
- package/src/unmarshal/primitive.test.ts +15 -15
- package/src/unmarshal/primitive.ts +11 -18
- package/src/unmarshal/promise.test.ts +13 -13
- package/src/unmarshal/promise.ts +10 -19
- package/src/unmarshal/properties.test.ts +8 -8
- package/src/unmarshal/properties.ts +44 -45
- package/src/util.test.ts +2 -7
- package/src/util.ts +3 -8
- package/src/vmmap.test.ts +72 -88
- package/src/vmmap.ts +26 -44
- package/src/vmutil.test.ts +73 -89
- package/src/vmutil.ts +24 -47
- package/src/wrapper.test.ts +108 -148
- package/src/wrapper.ts +59 -62
- package/dist/quickjs-emscripten-sync.es.js +0 -951
- package/src/marshal/symbol.test.ts +0 -24
- package/src/marshal/symbol.ts +0 -20
- package/src/unmarshal/symbol.test.ts +0 -25
- package/src/unmarshal/symbol.ts +0 -12
package/src/vmmap.test.ts
CHANGED
|
@@ -5,27 +5,24 @@ import VMMap from "./vmmap";
|
|
|
5
5
|
import { call } from "./vmutil";
|
|
6
6
|
|
|
7
7
|
test("init and dispose", async () => {
|
|
8
|
-
const
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
const map = new VMMap(vm);
|
|
8
|
+
const ctx = (await getQuickJS()).newContext();
|
|
9
|
+
const map = new VMMap(ctx);
|
|
12
10
|
map.dispose();
|
|
13
|
-
|
|
11
|
+
ctx.dispose();
|
|
14
12
|
});
|
|
15
13
|
|
|
16
14
|
test("get and set", async () => {
|
|
17
|
-
const
|
|
18
|
-
const vm = quickjs.createVm();
|
|
15
|
+
const ctx = (await getQuickJS()).newContext();
|
|
19
16
|
|
|
20
17
|
const target = {};
|
|
21
|
-
const handle =
|
|
18
|
+
const handle = ctx.newObject();
|
|
22
19
|
|
|
23
|
-
const map = new VMMap(
|
|
20
|
+
const map = new VMMap(ctx);
|
|
24
21
|
expect(map.get(target)).toBe(undefined);
|
|
25
22
|
expect(map.set(target, handle)).toBe(true);
|
|
26
23
|
expect(map.get(target)).toBe(handle);
|
|
27
24
|
// a new handle that points to the same value
|
|
28
|
-
const handle2 = call(
|
|
25
|
+
const handle2 = call(ctx, `a => a`, undefined, handle);
|
|
29
26
|
expect(map.set(target, handle2)).toBe(false);
|
|
30
27
|
|
|
31
28
|
handle2.dispose();
|
|
@@ -33,18 +30,17 @@ test("get and set", async () => {
|
|
|
33
30
|
expect(map.get(target)).toBe(undefined);
|
|
34
31
|
|
|
35
32
|
map.dispose();
|
|
36
|
-
|
|
33
|
+
ctx.dispose();
|
|
37
34
|
});
|
|
38
35
|
|
|
39
36
|
test("getByHandle", async () => {
|
|
40
|
-
const
|
|
41
|
-
const vm = quickjs.createVm();
|
|
37
|
+
const ctx = (await getQuickJS()).newContext();
|
|
42
38
|
|
|
43
39
|
const target = {};
|
|
44
|
-
const handle =
|
|
45
|
-
const handle2 =
|
|
40
|
+
const handle = ctx.newObject();
|
|
41
|
+
const handle2 = ctx.newObject();
|
|
46
42
|
|
|
47
|
-
const map = new VMMap(
|
|
43
|
+
const map = new VMMap(ctx);
|
|
48
44
|
expect(map.getByHandle(handle)).toBe(undefined);
|
|
49
45
|
map.set(target, handle);
|
|
50
46
|
expect(map.getByHandle(handle)).toBe(target);
|
|
@@ -54,18 +50,17 @@ test("getByHandle", async () => {
|
|
|
54
50
|
|
|
55
51
|
handle2.dispose();
|
|
56
52
|
map.dispose();
|
|
57
|
-
|
|
53
|
+
ctx.dispose();
|
|
58
54
|
});
|
|
59
55
|
|
|
60
56
|
test("keys", async () => {
|
|
61
|
-
const
|
|
62
|
-
const vm = quickjs.createVm();
|
|
57
|
+
const ctx = (await getQuickJS()).newContext();
|
|
63
58
|
|
|
64
59
|
const target = {};
|
|
65
|
-
const handle =
|
|
66
|
-
const handle2 =
|
|
60
|
+
const handle = ctx.newObject();
|
|
61
|
+
const handle2 = ctx.newObject();
|
|
67
62
|
|
|
68
|
-
const map = new VMMap(
|
|
63
|
+
const map = new VMMap(ctx);
|
|
69
64
|
expect(Array.from(map.keys())).toEqual([]);
|
|
70
65
|
map.set(target, handle);
|
|
71
66
|
expect(Array.from(map.keys())).toEqual([target]);
|
|
@@ -74,17 +69,16 @@ test("keys", async () => {
|
|
|
74
69
|
|
|
75
70
|
handle2.dispose();
|
|
76
71
|
map.dispose();
|
|
77
|
-
|
|
72
|
+
ctx.dispose();
|
|
78
73
|
});
|
|
79
74
|
|
|
80
75
|
test("delete", async () => {
|
|
81
|
-
const
|
|
82
|
-
const vm = quickjs.createVm();
|
|
76
|
+
const ctx = (await getQuickJS()).newContext();
|
|
83
77
|
|
|
84
78
|
const target = {};
|
|
85
|
-
const handle =
|
|
79
|
+
const handle = ctx.newObject();
|
|
86
80
|
|
|
87
|
-
const map = new VMMap(
|
|
81
|
+
const map = new VMMap(ctx);
|
|
88
82
|
map.set(target, handle);
|
|
89
83
|
expect(map.get(target)).toBe(handle);
|
|
90
84
|
map.delete({});
|
|
@@ -94,17 +88,16 @@ test("delete", async () => {
|
|
|
94
88
|
|
|
95
89
|
handle.dispose();
|
|
96
90
|
map.dispose();
|
|
97
|
-
|
|
91
|
+
ctx.dispose();
|
|
98
92
|
});
|
|
99
93
|
|
|
100
94
|
test("size", async () => {
|
|
101
|
-
const
|
|
102
|
-
const vm = quickjs.createVm();
|
|
95
|
+
const ctx = (await getQuickJS()).newContext();
|
|
103
96
|
|
|
104
97
|
const target = {};
|
|
105
|
-
const handle =
|
|
98
|
+
const handle = ctx.newObject();
|
|
106
99
|
|
|
107
|
-
const map = new VMMap(
|
|
100
|
+
const map = new VMMap(ctx);
|
|
108
101
|
expect(map.size).toBe(0);
|
|
109
102
|
map.set(target, handle);
|
|
110
103
|
expect(map.size).toBe(1);
|
|
@@ -112,17 +105,16 @@ test("size", async () => {
|
|
|
112
105
|
expect(map.size).toBe(1);
|
|
113
106
|
|
|
114
107
|
map.dispose();
|
|
115
|
-
|
|
108
|
+
ctx.dispose();
|
|
116
109
|
});
|
|
117
110
|
|
|
118
111
|
test("clear", async () => {
|
|
119
|
-
const
|
|
120
|
-
const vm = quickjs.createVm();
|
|
112
|
+
const ctx = (await getQuickJS()).newContext();
|
|
121
113
|
|
|
122
114
|
const target = {};
|
|
123
|
-
const handle =
|
|
115
|
+
const handle = ctx.newObject();
|
|
124
116
|
|
|
125
|
-
const map = new VMMap(
|
|
117
|
+
const map = new VMMap(ctx);
|
|
126
118
|
map.set(target, handle);
|
|
127
119
|
expect(map.size).toBe(1);
|
|
128
120
|
expect(map.get(target)).toBe(handle);
|
|
@@ -132,20 +124,19 @@ test("clear", async () => {
|
|
|
132
124
|
|
|
133
125
|
handle.dispose();
|
|
134
126
|
map.dispose();
|
|
135
|
-
|
|
127
|
+
ctx.dispose();
|
|
136
128
|
});
|
|
137
129
|
|
|
138
130
|
test("merge", async () => {
|
|
139
|
-
const
|
|
140
|
-
const vm = quickjs.createVm();
|
|
131
|
+
const ctx = (await getQuickJS()).newContext();
|
|
141
132
|
|
|
142
133
|
const target = {};
|
|
143
134
|
const target2 = {};
|
|
144
|
-
const handle =
|
|
145
|
-
const handle2 =
|
|
135
|
+
const handle = ctx.newObject();
|
|
136
|
+
const handle2 = ctx.newObject();
|
|
146
137
|
|
|
147
|
-
const map = new VMMap(
|
|
148
|
-
const map2 = new VMMap(
|
|
138
|
+
const map = new VMMap(ctx);
|
|
139
|
+
const map2 = new VMMap(ctx);
|
|
149
140
|
map.set(target, handle, target2, handle2);
|
|
150
141
|
expect(map.size).toBe(1);
|
|
151
142
|
expect(map.get(target)).toBe(handle);
|
|
@@ -159,19 +150,18 @@ test("merge", async () => {
|
|
|
159
150
|
map.clear();
|
|
160
151
|
map.dispose();
|
|
161
152
|
map2.dispose();
|
|
162
|
-
|
|
153
|
+
ctx.dispose();
|
|
163
154
|
});
|
|
164
155
|
|
|
165
156
|
test("iterator", async () => {
|
|
166
|
-
const
|
|
167
|
-
const vm = quickjs.createVm();
|
|
157
|
+
const ctx = (await getQuickJS()).newContext();
|
|
168
158
|
|
|
169
159
|
const target = {};
|
|
170
160
|
const target2 = {};
|
|
171
|
-
const handle =
|
|
172
|
-
const handle2 =
|
|
161
|
+
const handle = ctx.newObject();
|
|
162
|
+
const handle2 = ctx.newObject();
|
|
173
163
|
|
|
174
|
-
const map = new VMMap(
|
|
164
|
+
const map = new VMMap(ctx);
|
|
175
165
|
map.set(target, handle, target2, handle2);
|
|
176
166
|
|
|
177
167
|
const iter = map[Symbol.iterator]();
|
|
@@ -196,20 +186,19 @@ test("iterator", async () => {
|
|
|
196
186
|
expect(i).toBe(1);
|
|
197
187
|
|
|
198
188
|
map.dispose();
|
|
199
|
-
|
|
189
|
+
ctx.dispose();
|
|
200
190
|
});
|
|
201
191
|
|
|
202
192
|
test("get and set 2", async () => {
|
|
203
|
-
const
|
|
204
|
-
const vm = quickjs.createVm();
|
|
193
|
+
const ctx = (await getQuickJS()).newContext();
|
|
205
194
|
|
|
206
195
|
const target = {};
|
|
207
196
|
const target2 = {};
|
|
208
|
-
const handle =
|
|
209
|
-
const handle2 =
|
|
210
|
-
const handle3 = call(
|
|
197
|
+
const handle = ctx.newObject();
|
|
198
|
+
const handle2 = ctx.newObject();
|
|
199
|
+
const handle3 = call(ctx, `a => a`, undefined, handle);
|
|
211
200
|
|
|
212
|
-
const map = new VMMap(
|
|
201
|
+
const map = new VMMap(ctx);
|
|
213
202
|
|
|
214
203
|
map.set(target, handle, target2, handle2);
|
|
215
204
|
expect(map.get(target)).toBe(handle);
|
|
@@ -228,19 +217,18 @@ test("get and set 2", async () => {
|
|
|
228
217
|
expect(map.getByHandle(handle2)).toBe(undefined);
|
|
229
218
|
|
|
230
219
|
map.dispose();
|
|
231
|
-
|
|
220
|
+
ctx.dispose();
|
|
232
221
|
});
|
|
233
222
|
|
|
234
223
|
test("delete 2", async () => {
|
|
235
|
-
const
|
|
236
|
-
const vm = quickjs.createVm();
|
|
224
|
+
const ctx = (await getQuickJS()).newContext();
|
|
237
225
|
|
|
238
226
|
const target = {};
|
|
239
227
|
const target2 = {};
|
|
240
|
-
const handle =
|
|
241
|
-
const handle2 =
|
|
228
|
+
const handle = ctx.newObject();
|
|
229
|
+
const handle2 = ctx.newObject();
|
|
242
230
|
|
|
243
|
-
const map = new VMMap(
|
|
231
|
+
const map = new VMMap(ctx);
|
|
244
232
|
|
|
245
233
|
map.set(target, handle, target2, handle2);
|
|
246
234
|
expect(map.get(target)).toBe(handle);
|
|
@@ -258,19 +246,18 @@ test("delete 2", async () => {
|
|
|
258
246
|
handle.dispose();
|
|
259
247
|
handle2.dispose();
|
|
260
248
|
map.dispose();
|
|
261
|
-
|
|
249
|
+
ctx.dispose();
|
|
262
250
|
});
|
|
263
251
|
|
|
264
252
|
test("delete 3", async () => {
|
|
265
|
-
const
|
|
266
|
-
const vm = quickjs.createVm();
|
|
253
|
+
const ctx = (await getQuickJS()).newContext();
|
|
267
254
|
|
|
268
255
|
const target = {};
|
|
269
256
|
const target2 = {};
|
|
270
|
-
const handle =
|
|
271
|
-
const handle2 =
|
|
257
|
+
const handle = ctx.newObject();
|
|
258
|
+
const handle2 = ctx.newObject();
|
|
272
259
|
|
|
273
|
-
const map = new VMMap(
|
|
260
|
+
const map = new VMMap(ctx);
|
|
274
261
|
|
|
275
262
|
map.set(target, handle, target2, handle2);
|
|
276
263
|
expect(map.get(target)).toBe(handle);
|
|
@@ -288,19 +275,18 @@ test("delete 3", async () => {
|
|
|
288
275
|
handle.dispose();
|
|
289
276
|
handle2.dispose();
|
|
290
277
|
map.dispose();
|
|
291
|
-
|
|
278
|
+
ctx.dispose();
|
|
292
279
|
});
|
|
293
280
|
|
|
294
281
|
test("delete with dispose", async () => {
|
|
295
|
-
const
|
|
296
|
-
const vm = quickjs.createVm();
|
|
282
|
+
const ctx = (await getQuickJS()).newContext();
|
|
297
283
|
|
|
298
284
|
const target = {};
|
|
299
285
|
const target2 = {};
|
|
300
|
-
const handle =
|
|
301
|
-
const handle2 =
|
|
286
|
+
const handle = ctx.newObject();
|
|
287
|
+
const handle2 = ctx.newObject();
|
|
302
288
|
|
|
303
|
-
const map = new VMMap(
|
|
289
|
+
const map = new VMMap(ctx);
|
|
304
290
|
map.set(target, handle, target2, handle2);
|
|
305
291
|
map.delete(target, true);
|
|
306
292
|
|
|
@@ -308,19 +294,18 @@ test("delete with dispose", async () => {
|
|
|
308
294
|
expect(handle2.alive).toBe(false);
|
|
309
295
|
|
|
310
296
|
map.dispose();
|
|
311
|
-
|
|
297
|
+
ctx.dispose();
|
|
312
298
|
});
|
|
313
299
|
|
|
314
300
|
test("deleteByHandle", async () => {
|
|
315
|
-
const
|
|
316
|
-
const vm = quickjs.createVm();
|
|
301
|
+
const ctx = (await getQuickJS()).newContext();
|
|
317
302
|
|
|
318
303
|
const target = {};
|
|
319
304
|
const target2 = {};
|
|
320
|
-
const handle =
|
|
321
|
-
const handle2 =
|
|
305
|
+
const handle = ctx.newObject();
|
|
306
|
+
const handle2 = ctx.newObject();
|
|
322
307
|
|
|
323
|
-
const map = new VMMap(
|
|
308
|
+
const map = new VMMap(ctx);
|
|
324
309
|
map.set(target, handle, target2, handle2);
|
|
325
310
|
|
|
326
311
|
expect(map.getByHandle(handle)).toBe(target);
|
|
@@ -334,19 +319,18 @@ test("deleteByHandle", async () => {
|
|
|
334
319
|
handle.dispose();
|
|
335
320
|
handle2.dispose();
|
|
336
321
|
map.dispose();
|
|
337
|
-
|
|
322
|
+
ctx.dispose();
|
|
338
323
|
});
|
|
339
324
|
|
|
340
325
|
test("deleteByHandle with dispose", async () => {
|
|
341
|
-
const
|
|
342
|
-
const vm = quickjs.createVm();
|
|
326
|
+
const ctx = (await getQuickJS()).newContext();
|
|
343
327
|
|
|
344
328
|
const target = {};
|
|
345
329
|
const target2 = {};
|
|
346
|
-
const handle =
|
|
347
|
-
const handle2 =
|
|
330
|
+
const handle = ctx.newObject();
|
|
331
|
+
const handle2 = ctx.newObject();
|
|
348
332
|
|
|
349
|
-
const map = new VMMap(
|
|
333
|
+
const map = new VMMap(ctx);
|
|
350
334
|
map.set(target, handle, target2, handle2);
|
|
351
335
|
map.deleteByHandle(handle, true);
|
|
352
336
|
|
|
@@ -354,5 +338,5 @@ test("deleteByHandle with dispose", async () => {
|
|
|
354
338
|
expect(handle2.alive).toBe(false);
|
|
355
339
|
|
|
356
340
|
map.dispose();
|
|
357
|
-
|
|
341
|
+
ctx.dispose();
|
|
358
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();
|
|
@@ -42,14 +42,14 @@ export default class VMMap {
|
|
|
42
42
|
map2 = new WeakMap();
|
|
43
43
|
}
|
|
44
44
|
};
|
|
45
|
-
}`)
|
|
45
|
+
}`),
|
|
46
46
|
)
|
|
47
|
-
.consume(
|
|
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
|
|
|
@@ -59,12 +59,7 @@ export default class VMMap {
|
|
|
59
59
|
this._disposables.add(this._mapClear);
|
|
60
60
|
}
|
|
61
61
|
|
|
62
|
-
set(
|
|
63
|
-
key: any,
|
|
64
|
-
handle: QuickJSHandle,
|
|
65
|
-
key2?: any,
|
|
66
|
-
handle2?: QuickJSHandle
|
|
67
|
-
): boolean {
|
|
62
|
+
set(key: any, handle: QuickJSHandle, key2?: any, handle2?: QuickJSHandle): boolean {
|
|
68
63
|
if (!handle.alive || (handle2 && !handle2.alive)) return false;
|
|
69
64
|
|
|
70
65
|
const v = this.get(key) ?? this.get(key2);
|
|
@@ -84,14 +79,8 @@ export default class VMMap {
|
|
|
84
79
|
}
|
|
85
80
|
}
|
|
86
81
|
|
|
87
|
-
this.
|
|
88
|
-
this._call(
|
|
89
|
-
this._mapSet,
|
|
90
|
-
undefined,
|
|
91
|
-
handle,
|
|
92
|
-
c,
|
|
93
|
-
handle2 ?? this.vm.undefined
|
|
94
|
-
);
|
|
82
|
+
this.ctx.newNumber(counter).consume(c => {
|
|
83
|
+
this._call(this._mapSet, undefined, handle, c, handle2 ?? this.ctx.undefined);
|
|
95
84
|
});
|
|
96
85
|
|
|
97
86
|
return true;
|
|
@@ -103,7 +92,7 @@ export default class VMMap {
|
|
|
103
92
|
| [any, QuickJSHandle | undefined]
|
|
104
93
|
| [any, QuickJSHandle | undefined, any, QuickJSHandle | undefined]
|
|
105
94
|
>
|
|
106
|
-
| undefined
|
|
95
|
+
| undefined,
|
|
107
96
|
) {
|
|
108
97
|
if (!iteratable) return;
|
|
109
98
|
for (const iter of iteratable) {
|
|
@@ -131,9 +120,7 @@ export default class VMMap {
|
|
|
131
120
|
if (!handle.alive) {
|
|
132
121
|
return;
|
|
133
122
|
}
|
|
134
|
-
return this._counterMap.get(
|
|
135
|
-
this.vm.getNumber(this._call(this._mapGet, undefined, handle))
|
|
136
|
-
);
|
|
123
|
+
return this._counterMap.get(this.ctx.getNumber(this._call(this._mapGet, undefined, handle)));
|
|
137
124
|
}
|
|
138
125
|
|
|
139
126
|
has(key: any) {
|
|
@@ -157,7 +144,7 @@ export default class VMMap {
|
|
|
157
144
|
this._call(
|
|
158
145
|
this._mapDelete,
|
|
159
146
|
undefined,
|
|
160
|
-
...[handle, handle2].filter((h): h is QuickJSHandle => !!h?.alive)
|
|
147
|
+
...[handle, handle2].filter((h): h is QuickJSHandle => !!h?.alive),
|
|
161
148
|
);
|
|
162
149
|
|
|
163
150
|
this._map1.delete(key);
|
|
@@ -235,12 +222,11 @@ export default class VMMap {
|
|
|
235
222
|
return this._map1.size;
|
|
236
223
|
}
|
|
237
224
|
|
|
238
|
-
[Symbol.iterator](): Iterator<
|
|
239
|
-
[any, QuickJSHandle, any, QuickJSHandle | undefined]
|
|
240
|
-
> {
|
|
225
|
+
[Symbol.iterator](): Iterator<[any, QuickJSHandle, any, QuickJSHandle | undefined]> {
|
|
241
226
|
const keys = this._map1.keys();
|
|
242
227
|
return {
|
|
243
228
|
next: () => {
|
|
229
|
+
// eslint-disable-next-line no-constant-condition
|
|
244
230
|
while (true) {
|
|
245
231
|
const k1 = keys.next();
|
|
246
232
|
if (k1.done) return { value: undefined, done: true };
|
|
@@ -262,17 +248,13 @@ export default class VMMap {
|
|
|
262
248
|
}
|
|
263
249
|
}
|
|
264
250
|
|
|
265
|
-
_call(
|
|
266
|
-
|
|
267
|
-
|
|
268
|
-
...args: QuickJSHandle[]
|
|
269
|
-
) {
|
|
270
|
-
return this.vm.unwrapResult(
|
|
271
|
-
this.vm.callFunction(
|
|
251
|
+
_call(fn: QuickJSHandle, thisArg: QuickJSHandle | undefined, ...args: QuickJSHandle[]) {
|
|
252
|
+
return this.ctx.unwrapResult(
|
|
253
|
+
this.ctx.callFunction(
|
|
272
254
|
fn,
|
|
273
|
-
typeof thisArg === "undefined" ? this.
|
|
274
|
-
...args
|
|
275
|
-
)
|
|
255
|
+
typeof thisArg === "undefined" ? this.ctx.undefined : thisArg,
|
|
256
|
+
...args,
|
|
257
|
+
),
|
|
276
258
|
);
|
|
277
259
|
}
|
|
278
260
|
}
|