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

(chore) throttle deprecation messages #3092

Conversation

mihkeleidast
Copy link
Contributor

@mihkeleidast mihkeleidast commented Mar 29, 2021

Resolves #3069.

Changes

I've added a simple object map to keep track of already logged deprecations so they would not be logged multiple times.

I've manually tested that the following code now only logs one deprecation message:

function highlight(code) {
  return hljs.highlight("java", code, false);
}

highlight(code);
highlight(code);
highlight(code);

Checklist

  • Added markup tests, or they don't apply here because... does not change markup. could not find any existing logger tests so did not add any either.
  • Updated the changelog at CHANGES.md

@mihkeleidast
Copy link
Contributor Author

Looks like depd has limited or no browser support - what would be recommended to use here instead? util-deprecate looks popular but that does not have per-callsite logging.

src/highlight.js Outdated Show resolved Hide resolved
@mihkeleidast mihkeleidast force-pushed the feature/throttle-deprecation-messages branch from 7141c7e to e554470 Compare March 30, 2021 16:46
@mihkeleidast mihkeleidast marked this pull request as ready for review March 30, 2021 16:50
Copy link
Member

@joshgoebel joshgoebel left a comment

Choose a reason for hiding this comment

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

Exactly. I'll test later but this looks pretty good.

@joshgoebel
Copy link
Member

@mihkeleidast Thanks so much!

@joshgoebel joshgoebel merged commit ac40b10 into highlightjs:main Apr 1, 2021
NullVoxPopuli pushed a commit to NullVoxPopuli/highlight.js that referenced this pull request Apr 3, 2021
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.

(chore) Throttle logging of deprecation messages
2 participants