UNPKG

@adguard/agtree

Version:
32 lines (29 loc) 948 B
/* * AGTree v3.4.3 (build date: Thu, 11 Dec 2025 13:43:19 GMT) * (c) 2025 Adguard Software Ltd. * Released under the MIT license * https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme */ import { SEMICOLON, SPACE, CLOSE_SQUARE_BRACKET, OPEN_SQUARE_BRACKET } from '../../utils/constants.js'; import { BaseGenerator } from '../base-generator.js'; import { AgentGenerator } from './agent-generator.js'; /** * Generator for agent comment rules. */ class AgentCommentGenerator extends BaseGenerator { /** * Converts an adblock agent AST to a string. * * @param ast Agent rule AST * @returns Raw string */ static generate(ast) { let result = OPEN_SQUARE_BRACKET; result += ast.children .map(AgentGenerator.generate) .join(SEMICOLON + SPACE); result += CLOSE_SQUARE_BRACKET; return result; } } export { AgentCommentGenerator };