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

Give meaningful displayNames to decorated functions #60

Closed

Conversation

wbinnssmith
Copy link
Contributor

This:

  • Names decorated functions simply "memoized" in the case the input function is anonymous
  • Names decorated functions "memoized(foo)" in the case the input function has a name of "foo"
  • Names decorated functions "memoized(foo)" in the case the input function has a displayName of "foo", despite having a name of "bar".

It also gives a name to the default export of memoize-one of "memoizeOne", as it was previously "index" in every case but the minified version, where it was the empty string and will continue to be.

Upside: Makes for debugging these decorated functions much easier in debugging tools and stack traces.

Downside: more checks and more names add to the size of the compiled output.

Test Plan: yarn test. Import the main entry from a repl and confirm the export is named memoizeOne.

This:
* Names decorated functions simply "memoized" in the case the input function is anonymous
* Names decorated functions "memoized(foo)" in the case the input function has a `name` of "foo"
* Names decorated functions "memoized(foo)" in the case the input function has a `displayName` of "foo", despite having a `name` of "bar".

It also gives a name to the default export of `memoize-one` of "memoizeOne", as it was previously "index" in every case but the minified version, where it was the empty string and will continue to be.

Upside: Makes for debugging these decorated functions much easier in debugging tools and stack traces.

Downside: more checks and more names add to the size of the compiled output.

Test Plan: `yarn test`. Import the `main` entry from a repl and confirm the export is named `memoizeOne`.
@wbinnssmith wbinnssmith changed the title Give meaningful names to decorated functions Give meaningful displayNames to decorated functions Apr 3, 2019
@wbinnssmith
Copy link
Contributor Author

wbinnssmith commented Apr 3, 2019

I should have mentioned that this only applies a displayName to the decorated functions, and does not modify a function's name (which isn't writable anyway). displayName isn't a language thing either, it's just something debugging tools seem to have agreed to prefer as a friendlier name over name if it exists.

@alexreardon
Copy link
Owner

alexreardon commented Oct 20, 2021

I'll track this here: #54. Also, see #124 for a discussion about why I haven't added this for now

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.

2 participants