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 "return" outside of function issue #5

Merged
merged 1 commit into from
Dec 17, 2019
Merged

Fix "return" outside of function issue #5

merged 1 commit into from
Dec 17, 2019

Conversation

sahariko
Copy link

@sahariko sahariko commented Dec 17, 2019

@limerickgds
Copy link

@ljharb 🤦‍♂️
image

index.js Outdated Show resolved Hide resolved
Copy link
Member

@ljharb ljharb left a comment

Choose a reason for hiding this comment

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

IIFEs are obsolete; that's never an acceptable solution.

I very explicitly chose to export the proper function, which will be much faster, rather than polluting a single function with all the logic of each case.

If I decide to change my perfectly valid node CJS module to avoid top-level return, I'll use another approach.

@sahariko
Copy link
Author

  1. It's not wrapped with an IIFE anymore.
  2. Why would it be faster? The module is cached, so the top-level checks are performed only once, and the if statement is practically the same as the separate if statements that were originally there.

If you don't want to introduce changes due to some philosophical that's another thing, but this change is perfectly viable.

@ljharb
Copy link
Member

ljharb commented Dec 17, 2019

(Let’s discuss on the is-map PR)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants