Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix SyntaxError: Illegal return statement #4

Merged
merged 1 commit into from
Dec 17, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 6 additions & 6 deletions index.js
Original file line number Diff line number Diff line change
Expand Up @@ -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 (!$Map) {
// eslint-disable-next-line no-unused-vars
module.exports = function isMap(x) {
exported = function isMap(x) {
// `Map` is not present in this environment.
return false;
};
return;
}

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

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Even if you were to get rid of these returns, this is not it; you need to convert the rest of the file into else bodies.

}

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