@adguard/agtree
Version:
Tool set for working with adblock filter lists
40 lines (37 loc) • 1.21 kB
JavaScript
/*
* 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 { NEGATION_MARKER, EMPTY } from '../../utils/constants.js';
/**
* Utility class for generating string representations of list items.
*/
class ListItemsGenerator {
/**
* Generates a string representation of a list item.
*
* @param item List item to generate.
* @template T Type of the list item.
*
* @returns String representation of the list item.
*/
static generateListItem = (item) => {
return `${item.exception ? NEGATION_MARKER : EMPTY}${item.value}`;
};
/**
* Generates a string representation of a list of items.
*
* @param items List of items to generate.
* @param separator Separator character.
* @template T Type of the list items.
*
* @returns String representation of the list of items.
*/
static generate = (items, separator) => {
return items.map(ListItemsGenerator.generateListItem)
.join(separator);
};
}
export { ListItemsGenerator };