Skip to content

Commit

Permalink
fix(tame-metering): remove .prototype via bind if necessary
Browse files Browse the repository at this point in the history
This gets closer to working under lockdown().
  • Loading branch information
michaelfig committed Feb 20, 2020
1 parent beac518 commit a77c7e3
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions packages/tame-metering/src/tame.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ export function tameMetering() {
const {
defineProperty,
entries,
getOwnPropertyDescriptor,
getOwnPropertyDescriptors,
getPrototypeOf,
setPrototypeOf,
Expand Down Expand Up @@ -132,6 +133,10 @@ export function tameMetering() {
globalMeter = savedMeter;
}
};
if (!getOwnPropertyDescriptor(target, 'prototype')) {
// Remove the .prototype by binding the function.
wrapper = wrapper.bind();
}
defineProperty(wrapper, 'name', { value: target.name });
} else {
// The function wrapper must not have construct behaviour.
Expand Down

0 comments on commit a77c7e3

Please sign in to comment.