Skip to content

Commit

Permalink
do native Proxy check before usage to prevent race conditions
Browse files Browse the repository at this point in the history
  • Loading branch information
snapwich committed Jul 26, 2019
1 parent f5bbc2d commit db11565
Showing 1 changed file with 5 additions and 3 deletions.
8 changes: 5 additions & 3 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -4,10 +4,12 @@ create.QUEUE = 4;

var packageName = "fun-hooks";

var hasProxy = !!(typeof Proxy === "function" && Proxy.revocable);
function hasProxy() {
return !!(typeof Proxy === "function" && Proxy.revocable);
}

var defaults = Object.freeze({
useProxy: hasProxy,
useProxy: true,
ready: 0
});

Expand Down Expand Up @@ -275,7 +277,7 @@ function create(config) {
postReady.push(setTrap);
}

if (config.useProxy) {
if (config.useProxy && hasProxy()) {
hookedFn = new Proxy(fn, handlers);
} else {
hookedFn = function() {
Expand Down

0 comments on commit db11565

Please sign in to comment.