mirror of
https://github.com/SukkaW/Surge.git
synced 2026-01-29 01:51:52 +08:00
Feat: include my_reject in adguardhome
This commit is contained in:
@@ -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() {
|
||||
|
||||
Reference in New Issue
Block a user