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

Merged
Show file tree
Hide file tree
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
1 change: 1 addition & 0 deletions CHANGES.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
- enh(nginx) improving highlighting of some sections [Josh Goebel][]
- fix(vim) variable names may not be zero length [Josh Goebel][]
- enh(sqf) Updated keywords to Arma 3 v2.02 (#3084) [R3voA3][]
- (chore) throttle deprecation messages (#3092) [Mihkel Eidast][]
- enh(c) Update keyword list for C11/C18 (#3010) [Josh Goebel][]

New Languages:
Expand Down
8 changes: 8 additions & 0 deletions src/lib/logger.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@ https://github.com/highlightjs/highlight.js/issues/2880#issuecomment-747275419

*/

/**
* @type {Record<string, boolean>}
*/
const seenDeprecations = {};

/**
* @param {string} message
*/
Expand Down Expand Up @@ -32,5 +37,8 @@ export const notice = (message) => {
* @param {string} message
*/
export const deprecated = (version, message) => {
if (seenDeprecations[`${version}/${message}`]) return;

console.log(`Deprecated as of ${version}. ${message}`);
seenDeprecations[`${version}/${message}`] = true;
};