@adguard/agtree
Version:
Tool set for working with adblock filter lists
60 lines (57 loc) • 2.37 kB
JavaScript
/*
* AGTree v3.2.2 (build date: Tue, 08 Jul 2025 13:39:47 GMT)
* (c) 2025 Adguard Software Ltd.
* Released under the MIT license
* https://github.com/AdguardTeam/tsurlfilter/tree/master/packages/agtree#readme
*/
import { NotImplementedError } from '../../errors/not-implemented-error.js';
/**
* @file Base class for converters
*
* TS doesn't support abstract static methods, so we should use
* a workaround and extend this class instead of implementing it
*/
/* eslint-disable jsdoc/require-returns-check */
/* eslint-disable @typescript-eslint/no-unused-vars */
/**
* Basic class for rule converters
*/
class BaseConverter {
/**
* Converts some data to AdGuard format
*
* @param data Data to convert
* @returns An object which follows the {@link ConversionResult} interface. Its `result` property contains
* the converted node, and its `isConverted` flag indicates whether the original node was converted.
* If the node was not converted, the result will contain the original node with the same object reference
* @throws If the data is invalid or incompatible
*/
static convertToAdg(data) {
throw new NotImplementedError();
}
/**
* Converts some data to Adblock Plus format
*
* @param data Data to convert
* @returns An object which follows the {@link ConversionResult} interface. Its `result` property contains
* the converted node, and its `isConverted` flag indicates whether the original node was converted.
* If the node was not converted, the result will contain the original node with the same object reference
* @throws If the data is invalid or incompatible
*/
static convertToAbp(data) {
throw new NotImplementedError();
}
/**
* Converts some data to uBlock Origin format
*
* @param data Data to convert
* @returns An object which follows the {@link ConversionResult} interface. Its `result` property contains
* the converted node, and its `isConverted` flag indicates whether the original node was converted.
* If the node was not converted, the result will contain the original node with the same object reference
* @throws If the data is invalid or incompatible
*/
static convertToUbo(data) {
throw new NotImplementedError();
}
}
export { BaseConverter };