From 62602d58d69d4a8183c444cb5508c74c32548ce6 Mon Sep 17 00:00:00 2001 From: ptMuta Date: Sat, 4 Aug 2018 02:10:27 +0300 Subject: [PATCH 1/2] Added value not false check when assigning root for package --- src/tuple.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/tuple.js b/src/tuple.js index 7f47789..943844d 100644 --- a/src/tuple.js +++ b/src/tuple.js @@ -29,7 +29,7 @@ export { tuple }; // object, there's no reliable way to get the global object across all JS // environments without using the `Function` constructor, so instead we // use the global `Array` constructor as a shared namespace. -const root = globalKey in Array +const root = globalKey in Array && Array[globalKey] ? Array[globalKey] : def(Array, globalKey, new UniversalWeakMap, false); From 2c3b14e811a0924168bbaed51aa5daae7cbdf0f8 Mon Sep 17 00:00:00 2001 From: ptMuta Date: Sat, 4 Aug 2018 15:33:38 +0300 Subject: [PATCH 2/2] A more elegant fix as suggested by @benjamn --- src/tuple.js | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/tuple.js b/src/tuple.js index 943844d..70eeced 100644 --- a/src/tuple.js +++ b/src/tuple.js @@ -29,9 +29,7 @@ export { tuple }; // object, there's no reliable way to get the global object across all JS // environments without using the `Function` constructor, so instead we // use the global `Array` constructor as a shared namespace. -const root = globalKey in Array && Array[globalKey] - ? Array[globalKey] - : def(Array, globalKey, new UniversalWeakMap, false); +const root = Array[globalKey] || def(Array, globalKey, new UniversalWeakMap, false); function intern(array) { let node = root;