@@ -28,10 +28,10 @@ const Decontextified = new host.WeakMap();
28
28
global . VMError = class VMError extends Error {
29
29
constructor ( message , code ) {
30
30
super ( message ) ;
31
-
31
+
32
32
this . name = 'VMError' ;
33
33
this . code = code ;
34
-
34
+
35
35
ERROR_CST ( this , this . constructor ) ;
36
36
}
37
37
}
@@ -42,10 +42,10 @@ global.VMError = class VMError extends Error {
42
42
43
43
const Decontextify = {
44
44
proxies : new host . WeakMap ( ) ,
45
-
45
+
46
46
arguments : function ( args ) {
47
47
if ( ! host . Array . isArray ( args ) ) return new host . Array ( ) ;
48
-
48
+
49
49
let arr = new host . Array ( ) ;
50
50
for ( let i = 0 , l = args . length ; i < l ; i ++ ) arr [ i ] = Decontextify . value ( args [ i ] ) ;
51
51
return arr ;
@@ -57,7 +57,7 @@ const Decontextify = {
57
57
if ( key === 'isVMProxy' ) return true ;
58
58
if ( key === 'constructor' ) return klass ;
59
59
if ( key === '__proto__' ) return klass . prototype ;
60
-
60
+
61
61
try {
62
62
return Decontextify . value ( instance [ key ] ) ;
63
63
} catch ( e ) {
@@ -74,7 +74,7 @@ const Decontextify = {
74
74
apply : ( target , context , args ) => {
75
75
try {
76
76
context = Contextify . value ( context ) ;
77
-
77
+
78
78
// Set context of all arguments to vm's context.
79
79
return Decontextify . value ( fnc . apply ( context , Contextify . arguments ( args ) ) ) ;
80
80
} catch ( e ) {
@@ -94,7 +94,7 @@ const Decontextify = {
94
94
if ( mock && key in mock ) return mock [ key ] ;
95
95
if ( key === 'constructor' ) return host . Function ;
96
96
if ( key === '__proto__' ) return host . Function . prototype ;
97
-
97
+
98
98
try {
99
99
return Decontextify . value ( fnc [ key ] , deepTraps ) ;
100
100
} catch ( e ) {
@@ -105,7 +105,7 @@ const Decontextify = {
105
105
return host . Function . prototype ;
106
106
}
107
107
} , traps ) , deepTraps ) ;
108
-
108
+
109
109
return self ;
110
110
} ,
111
111
object : function ( object , traps , deepTraps , mock ) {
@@ -116,7 +116,7 @@ const Decontextify = {
116
116
if ( mock && key in mock ) return mock [ key ] ;
117
117
if ( key === 'constructor' ) return host . Object ;
118
118
if ( key === '__proto__' ) return host . Object . prototype ;
119
-
119
+
120
120
try {
121
121
return Decontextify . value ( object [ key ] , deepTraps ) ;
122
122
} catch ( e ) {
@@ -137,10 +137,10 @@ const Decontextify = {
137
137
} catch ( e ) {
138
138
throw Decontextify . value ( e ) ;
139
139
}
140
-
140
+
141
141
// Following code prevents V8 to throw
142
142
// TypeError: 'getOwnPropertyDescriptor' on proxy: trap reported non-configurability for property '<prop>' which is either non-existant or configurable in the proxy target
143
-
143
+
144
144
if ( ! def ) {
145
145
return undefined ;
146
146
} else if ( def . get || def . set ) {
@@ -187,7 +187,7 @@ const Decontextify = {
187
187
throw new host . Error ( OPNA ) ;
188
188
}
189
189
} , traps ) ) ;
190
-
190
+
191
191
Decontextify . proxies . set ( object , proxy ) ;
192
192
Decontextified . set ( proxy , object ) ;
193
193
return proxy ;
@@ -200,7 +200,7 @@ const Decontextify = {
200
200
// Decontextified proxy already exists, reuse
201
201
return Decontextify . proxies . get ( value ) ;
202
202
}
203
-
203
+
204
204
switch ( typeof value ) {
205
205
case 'object' :
206
206
if ( value === null ) {
@@ -227,10 +227,10 @@ const Decontextify = {
227
227
}
228
228
case 'function' :
229
229
return Decontextify . function ( value , traps , deepTraps , mock ) ;
230
-
230
+
231
231
case 'undefined' :
232
232
return undefined ;
233
-
233
+
234
234
default : // string, number, boolean, symbol
235
235
return value ;
236
236
}
@@ -243,10 +243,10 @@ const Decontextify = {
243
243
244
244
const Contextify = {
245
245
proxies : new host . WeakMap ( ) ,
246
-
246
+
247
247
arguments : function ( args ) {
248
248
if ( ! host . Array . isArray ( args ) ) return new Array ( ) ;
249
-
249
+
250
250
let arr = new Array ( ) ;
251
251
for ( let i = 0 , l = args . length ; i < l ; i ++ ) arr [ i ] = Contextify . value ( args [ i ] ) ;
252
252
return arr ;
@@ -306,7 +306,7 @@ const Contextify = {
306
306
return Function . prototype ;
307
307
}
308
308
} , traps ) , deepTraps ) ;
309
-
309
+
310
310
return self ;
311
311
} ,
312
312
object : function ( object , traps , deepTraps , mock ) {
@@ -338,7 +338,7 @@ const Contextify = {
338
338
} catch ( e ) {
339
339
throw Contextify . value ( e ) ;
340
340
}
341
-
341
+
342
342
// Following code prevents V8 to throw
343
343
// TypeError: 'getOwnPropertyDescriptor' on proxy: trap reported non-configurability for property '<prop>' which is either non-existant or configurable in the proxy target
344
344
@@ -401,7 +401,7 @@ const Contextify = {
401
401
// Contextified proxy already exists, reuse
402
402
return Contextify . proxies . get ( value ) ;
403
403
}
404
-
404
+
405
405
switch ( typeof value ) {
406
406
case 'object' :
407
407
if ( value === null ) {
@@ -429,10 +429,10 @@ const Contextify = {
429
429
}
430
430
case 'function' :
431
431
return Contextify . function ( value , traps , deepTraps , mock ) ;
432
-
432
+
433
433
case 'undefined' :
434
434
return undefined ;
435
-
435
+
436
436
default : // string, number, boolean, symbol
437
437
return value ;
438
438
}
0 commit comments