Commit 8f53bcc 1 parent e3d61dc commit 8f53bcc Copy full SHA for 8f53bcc
File tree 1 file changed +12
-6
lines changed
1 file changed +12
-6
lines changed Original file line number Diff line number Diff line change @@ -30,20 +30,26 @@ export function makeFakeVirtualObjectManager(cacheSize = 100) {
30
30
}
31
31
32
32
const valToSlot = new WeakMap ( ) ;
33
+ const slotToVal = new Map ( ) ;
33
34
34
35
function fakeConvertValToSlot ( val ) {
36
+ if ( ! valToSlot . has ( val ) ) {
37
+ const slot = `o+${ fakeAllocateExportID ( ) } ` ;
38
+ valToSlot . set ( val , slot ) ;
39
+ slotToVal . set ( slot , val ) ;
40
+ }
35
41
return valToSlot . get ( val ) ;
36
42
}
37
43
38
44
function fakeConvertSlotToVal ( slot ) {
39
45
const { type, virtual } = parseVatSlot ( slot ) ;
40
- assert (
41
- virtual ,
42
- 'fakeConvertSlotToVal only works with virtual object references' ,
43
- ) ;
44
46
assert . equal ( type , 'object' ) ;
45
- // eslint-disable-next-line no-use-before-define
46
- return makeVirtualObjectRepresentative ( slot ) ;
47
+ if ( virtual ) {
48
+ // eslint-disable-next-line no-use-before-define
49
+ return makeVirtualObjectRepresentative ( slot ) ;
50
+ } else {
51
+ return slotToVal . get ( slot ) ;
52
+ }
47
53
}
48
54
49
55
// eslint-disable-next-line no-use-before-define
You can’t perform that action at this time.
0 commit comments