Skip to content

Commit aba27c0

Browse files
committed
make it more readable
1 parent 084d7f2 commit aba27c0

File tree

1 file changed

+9
-12
lines changed

1 file changed

+9
-12
lines changed

packages/vm/src/edge-vm.ts

Lines changed: 9 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -130,9 +130,15 @@ function patchInstanceOf(
130130
// @ts-ignore
131131
ctx[Symbol.for(`node:${item}`)] = eval(item)
132132

133-
const shouldPatchPrototype = patchedPrototypes.has(item)
133+
const patchPrototype = !patchedPrototypes.has(item)
134+
? ''
135+
: `Object.assign(globalThis.${item}.prototype, {
136+
get constructor() {
137+
return proxy;
138+
}
139+
})`
134140

135-
return runInContext(
141+
runInContext(
136142
`
137143
(() => {
138144
const proxy = new Proxy(${item}, {
@@ -163,16 +169,7 @@ function patchInstanceOf(
163169
})
164170
165171
globalThis.${item} = proxy;
166-
167-
${
168-
!shouldPatchPrototype
169-
? ''
170-
: `Object.assign(globalThis.${item}.prototype, {
171-
get constructor() {
172-
return proxy;
173-
}
174-
})`
175-
}
172+
${patchPrototype}
176173
})()
177174
`,
178175
ctx,

0 commit comments

Comments
 (0)