UNPKG

@adguard/agtree

Version:
36 lines (33 loc) 1.03 kB
/* * AGTree v4.1.1 (build date: Thu, 23 Apr 2026 09:15:37 GMT) * (c) 2026 Adguard Software Ltd. * Released under the MIT license * https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme */ import { MODIFIER_ASSIGN_OPERATOR, EMPTY, NEGATION_MARKER } from '../../utils/constants.js'; import { BaseGenerator } from '../base-generator.js'; /** * Generator for modifier nodes. */ class ModifierGenerator extends BaseGenerator { /** * Converts a modifier AST node to a string. * * @param modifier Modifier AST node to convert. * * @returns String representation of the modifier. */ static generate(modifier) { let result = EMPTY; if (modifier.exception) { result += NEGATION_MARKER; } result += modifier.name.value; if (modifier.value !== undefined) { result += MODIFIER_ASSIGN_OPERATOR; result += modifier.value.value; } return result; } } export { ModifierGenerator };