@adguard/agtree
Version:
Tool set for working with adblock filter lists
66 lines (63 loc) • 2.42 kB
JavaScript
/*
* 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 { 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 };