Feat: include my_reject in adguardhome

This commit is contained in:
SukkaW
2025-01-07 23:17:38 +08:00
parent e43ba55357
commit 4e9e206ec0
3 changed files with 21 additions and 18 deletions

View File

@@ -36,7 +36,7 @@ export abstract class RuleOutput<TPreprocessed = unknown> {
protected otherRules: string[] = [];
protected abstract type: 'domainset' | 'non_ip' | 'ip';
private pendingPromise: Promise<void> | null = null;
private pendingPromise: Promise<any> | null = null;
static readonly jsonToLines = (json: unknown): string[] => stringify(json).split('\n');
@@ -201,8 +201,13 @@ export abstract class RuleOutput<TPreprocessed = unknown> {
}
}
addFromRuleset(source: AsyncIterable<string> | Iterable<string>) {
this.pendingPromise = (this.pendingPromise ||= Promise.resolve()).then(() => this.addFromRulesetPromise(source));
addFromRuleset(source: AsyncIterable<string> | Iterable<string> | Promise<Iterable<string>>) {
if (this.pendingPromise) {
this.pendingPromise = this.pendingPromise.then(() => source);
} else {
this.pendingPromise = Promise.resolve(source);
}
this.pendingPromise = this.pendingPromise.then((source) => this.addFromRulesetPromise(source));
return this;
}
@@ -247,6 +252,7 @@ export abstract class RuleOutput<TPreprocessed = unknown> {
async done() {
await this.pendingPromise;
this.pendingPromise = null;
return this;
}
private guardPendingPromise() {