| Index: lib/subscriptionClasses.js |
| =================================================================== |
| --- a/lib/subscriptionClasses.js |
| +++ b/lib/subscriptionClasses.js |
| @@ -122,43 +122,42 @@ |
| filterNotifier.emit("subscription.disabled", this, value, oldValue); |
| } |
| return this._disabled; |
| }, |
| /** |
| * Serializes the subscription to an array of strings for writing |
| * out on the disk. |
| - * @param {string[]} buffer buffer to push the serialization results into |
| + * @yields {string} |
| */ |
| - serialize(buffer) |
| + *serialize() |
| { |
| - buffer.push("[Subscription]"); |
| - buffer.push("url=" + this.url); |
| + yield "[Subscription]"; |
| + yield "url=" + this.url; |
| + |
| if (this.type) |
| - buffer.push("type=" + this.type); |
| + yield "type=" + this.type; |
| if (this._title) |
| - buffer.push("title=" + this._title); |
| + yield "title=" + this._title; |
| if (this._fixedTitle) |
| - buffer.push("fixedTitle=true"); |
| + yield "fixedTitle=true"; |
| if (this._disabled) |
| - buffer.push("disabled=true"); |
| + yield "disabled=true"; |
| }, |
| - serializeFilters(buffer) |
| + *serializeFilters() |
| { |
| for (let filter of this.filters) |
| - buffer.push(filter.text.replace(/\[/g, "\\[")); |
| + yield filter.text.replace(/\[/g, "\\["); |
| }, |
| toString() |
| { |
| - let buffer = []; |
| - this.serialize(buffer); |
| - return buffer.join("\n"); |
| + return [...this.serialize()].join("\n"); |
| } |
| }; |
| /** |
| * Cache for known filter subscriptions, maps URL to subscription objects. |
| * @type {Map.<string,Subscription>} |
| */ |
| Subscription.knownSubscriptions = new Map(); |
| @@ -276,29 +275,29 @@ |
| return false; |
| }, |
| /** |
| * See Subscription.serialize() |
| * @inheritdoc |
| */ |
| - serialize(buffer) |
| + *serialize() |
| { |
| - Subscription.prototype.serialize.call(this, buffer); |
| + yield* Subscription.prototype.serialize.call(this); |
| if (this.defaults && this.defaults.length) |
| { |
| - buffer.push("defaults=" + |
| + yield "defaults=" + |
| this.defaults.filter( |
| type => SpecialSubscription.defaultsMap.has(type) |
| ).join(" ") |
| - ); |
| + ; |
| } |
| if (this._lastDownload) |
| - buffer.push("lastDownload=" + this._lastDownload); |
| + yield "lastDownload=" + this._lastDownload; |
| } |
| }); |
| SpecialSubscription.defaultsMap = new Map([ |
| ["whitelist", WhitelistFilter], |
| ["blocking", BlockingFilter], |
| ["elemhide", ElemHideBase] |
| ]); |
| @@ -394,23 +393,23 @@ |
| } |
| return this._lastDownload; |
| }, |
| /** |
| * See Subscription.serialize() |
| * @inheritdoc |
| */ |
| - serialize(buffer) |
| + *serialize() |
| { |
| - Subscription.prototype.serialize.call(this, buffer); |
| + yield* Subscription.prototype.serialize.call(this); |
| if (this._homepage) |
| - buffer.push("homepage=" + this._homepage); |
| + yield "homepage=" + this._homepage; |
| if (this._lastDownload) |
| - buffer.push("lastDownload=" + this._lastDownload); |
| + yield "lastDownload=" + this._lastDownload; |
| } |
| }); |
| /** |
| * Class for filter subscriptions updated externally (by other extension) |
| * @param {string} url see {@link Subscription Subscription()} |
| * @param {string} [title] see {@link Subscription Subscription()} |
| * @constructor |
| @@ -422,19 +421,19 @@ |
| } |
| exports.ExternalSubscription = ExternalSubscription; |
| ExternalSubscription.prototype = extend(RegularSubscription, { |
| /** |
| * See Subscription.serialize() |
| * @inheritdoc |
| */ |
| - serialize(buffer) |
| + *serialize() |
| { |
| - throw new Error( |
| + yield new Error( |
| "Unexpected call, external subscriptions should not be serialized" |
| ); |
| } |
| }); |
| /** |
| * Class for filter subscriptions updated externally (by other extension) |
| * @param {string} url see {@link Subscription Subscription()} |
| @@ -547,31 +546,31 @@ |
| * @type {number} |
| */ |
| downloadCount: 0, |
| /** |
| * See Subscription.serialize() |
| * @inheritdoc |
| */ |
| - serialize(buffer) |
| + *serialize() |
| { |
| - RegularSubscription.prototype.serialize.call(this, buffer); |
| + yield* RegularSubscription.prototype.serialize.call(this); |
| if (this.downloadStatus) |
| - buffer.push("downloadStatus=" + this.downloadStatus); |
| + yield "downloadStatus=" + this.downloadStatus; |
| if (this.lastSuccess) |
| - buffer.push("lastSuccess=" + this.lastSuccess); |
| + yield "lastSuccess=" + this.lastSuccess; |
| if (this.lastCheck) |
| - buffer.push("lastCheck=" + this.lastCheck); |
| + yield "lastCheck=" + this.lastCheck; |
| if (this.expires) |
| - buffer.push("expires=" + this.expires); |
| + yield "expires=" + this.expires; |
| if (this.softExpiration) |
| - buffer.push("softExpiration=" + this.softExpiration); |
| + yield "softExpiration=" + this.softExpiration; |
| if (this.errors) |
| - buffer.push("errors=" + this.errors); |
| + yield "errors=" + this.errors; |
| if (this.version) |
| - buffer.push("version=" + this.version); |
| + yield "version=" + this.version; |
| if (this.requiredVersion) |
| - buffer.push("requiredVersion=" + this.requiredVersion); |
| + yield "requiredVersion=" + this.requiredVersion; |
| if (this.downloadCount) |
| - buffer.push("downloadCount=" + this.downloadCount); |
| + yield "downloadCount=" + this.downloadCount; |
| } |
| }); |