Chore: new way to attach description

This commit is contained in:
SukkaW
2025-07-21 15:57:35 +08:00
parent de1f817eec
commit 3a7f15ca6c
10 changed files with 74 additions and 71 deletions

View File

@@ -9,6 +9,7 @@ import { merge as mergeCidr } from 'fast-cidr-tools';
import { createRetrieKeywordFilter as createKeywordFilter } from 'foxts/retrie';
import path from 'node:path';
import { SurgeMitmSgmodule } from '../writing-strategy/surge';
import { appendArrayInPlace } from 'foxts/append-array-in-place';
/**
* Holds the universal rule data (domain, ip, url-regex, etc. etc.)
@@ -86,6 +87,21 @@ export class FileOutput {
return this;
}
appendDescription(description: string | string[], ...rest: string[]) {
this.description ??= [];
if (typeof description === 'string') {
this.description.push(description);
} else {
appendArrayInPlace(this.description, description);
}
if (rest.length) {
appendArrayInPlace(this.description, rest);
}
return this;
}
protected date = new Date();
withDate(date: Date) {
this.date = date;