From 4f9eeee8bc83d33a20a4adfbc9313fb2c4c49078 Mon Sep 17 00:00:00 2001 From: Jordan Harband Date: Tue, 17 Dec 2019 11:18:16 -0800 Subject: [PATCH] [Refactor] avoid top-level return, because babel and webpack are broken Closes #5. Closes #4. Closes #3. Closes https://github.com/inspect-js/node-deep-equal/issues/78. Closes https://github.com/es-shims/Promise.allSettled/issues/7. Closes https://github.com/airbnb/js-shims/issues/12. Relates to https://github.com/inspect-js/is-map/pull/3, https://github.com/inspect-js/is-map/pull/4, https://github.com/inspect-js/is-map/pull/5 Addresses https://github.com/storybookjs/storybook/issues/9154. --- index.js | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/index.js b/index.js index f095fb9..c9ca677 100644 --- a/index.js +++ b/index.js @@ -3,27 +3,27 @@ var $Map = typeof Map === 'function' && Map.prototype ? Map : null; var $Set = typeof Set === 'function' && Set.prototype ? Set : null; +var exported; + if (!$Set) { // eslint-disable-next-line no-unused-vars - module.exports = function isSet(x) { + exported = function isSet(x) { // `Set` is not present in this environment. return false; }; - return; } var $mapHas = $Map ? Map.prototype.has : null; var $setHas = $Set ? Set.prototype.has : null; -if (!$setHas) { +if (!exported && !$setHas) { // eslint-disable-next-line no-unused-vars - module.exports = function isSet(x) { + exported = function isSet(x) { // `Set` does not have a `has` method return false; }; - return; } -module.exports = function isSet(x) { +module.exports = exported || function isSet(x) { if (!x || typeof x !== 'object') { return false; }