Skip to content

Commit

Permalink
[Refactor] avoid top-level return, because babel and webpack are broken
Browse files Browse the repository at this point in the history
  • Loading branch information
ljharb committed Dec 17, 2019
1 parent e4bda71 commit 90bbc73
Showing 1 changed file with 5 additions and 5 deletions.
10 changes: 5 additions & 5 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@
var $WeakMap = typeof WeakMap === 'function' && WeakMap.prototype ? WeakMap : null;
var $WeakSet = typeof WeakSet === 'function' && WeakSet.prototype ? WeakSet : null;

var exported;

if (!$WeakMap) {
// eslint-disable-next-line no-unused-vars
module.exports = function isWeakSet(x) {
exported = function isWeakSet(x) {
// `WeakSet` is not present in this environment.
return false;
};
return;
}

var $mapHas = $WeakMap ? $WeakMap.prototype.has : null;
var $setHas = $WeakSet ? $WeakSet.prototype.has : null;
if (!$setHas) {
if (!exported && !$setHas) {
// eslint-disable-next-line no-unused-vars
module.exports = function isWeakSet(x) {
// `WeakSet` does not have a `has` method
return false;
};
return;
}

module.exports = function isWeakSet(x) {
module.exports = exported || function isWeakSet(x) {
if (!x || typeof x !== 'object') {
return false;
}
Expand Down

0 comments on commit 90bbc73

Please sign in to comment.