refactor: add has() and get() to MacrosParser (#4626)

01e388058781d438c0720c6272d6269fb3403ec4

Wolfsblvt <wolfsblvt@gmail.com>

Signed
1 files changed, +18 -0Ignore whitespace
public/scripts/macros.js+18 -0
@@ -57,6 +57,24 @@ export class MacrosParser {
5757 };
5858
5959 /**
60+ * Access a macro by its name.
61+ * @param {string} key Macro name (key)
62+ * @returns {string|MacroFunction|undefined} The macro value
63+ */
64+ static get(key) {
65+ return MacrosParser.#macros.get(key);
66+ }
67+
68+ /**
69+ * Checks if a macro is registered.
70+ * @param {string} key Macro name (key)
71+ * @returns {boolean} True if the macro is registered, false otherwise
72+ */
73+ static has(key) {
74+ return MacrosParser.#macros.has(key);
75+ }
76+
77+ /**
6078 * Registers a global macro that can be used anywhere where substitution is allowed.
6179 * @param {string} key Macro name (key)
6280 * @param {string|MacroFunction} value A string or a function that returns a string