Index: lib/filterClasses.js |
=================================================================== |
--- a/lib/filterClasses.js |
+++ b/lib/filterClasses.js |
@@ -138,23 +138,24 @@ |
else if (subscription == this._subscriptions) |
{ |
this._subscriptions = null; |
} |
} |
}, |
/** |
- * Serializes the filter to an array of strings for writing out on the disk. |
- * @param {string[]} buffer buffer to push the serialization results into |
+ * Generates serialized filter. |
Manish Jethani
2018/10/21 21:51:43
I like the previous comment, I think we could just
Jon Sonesen
2018/10/22 19:27:47
Acknowledged. Yeah I like that better
|
+ * @yields {string} |
*/ |
- serialize(buffer) |
+ *serialize() |
{ |
- buffer.push("[Filter]"); |
- buffer.push("text=" + this.text); |
+ let {text} = this; |
Manish Jethani
2018/10/21 21:52:55
Nit: I would leave a line after this just to be co
Jon Sonesen
2018/10/22 19:27:47
Yeah good catch
|
+ yield "[Filter]"; |
+ yield "text=" + text; |
}, |
toString() |
{ |
return this.text; |
} |
}; |
@@ -321,17 +322,17 @@ |
* @type {string} |
*/ |
reason: null, |
/** |
* See Filter.serialize() |
* @inheritdoc |
*/ |
- serialize(buffer) {} |
+ *serialize() {} |
}); |
/** |
* Class for comments |
* @param {string} text see {@link Filter Filter()} |
* @constructor |
* @augments Filter |
*/ |
@@ -343,17 +344,17 @@ |
CommentFilter.prototype = extend(Filter, { |
type: "comment", |
/** |
* See Filter.serialize() |
* @inheritdoc |
*/ |
- serialize(buffer) {} |
+ *serialize() {} |
}); |
/** |
* Abstract base class for filters that can get hits |
* @param {string} text |
* see {@link Filter Filter()} |
* @param {string} [domains] |
* Domains that the filter is restricted to separated by domainSeparator |
@@ -626,27 +627,29 @@ |
return !(sitekeys && sitekeys.length) && (!domains || domains.get("")); |
}, |
/** |
* See Filter.serialize() |
* @inheritdoc |
*/ |
- serialize(buffer) |
+ *serialize() |
{ |
- if (this._disabled || this._hitCount || this._lastHit) |
+ let {_disabled, _hitCount, _lastHit} = this; |
+ |
+ if (_disabled || _hitCount || _lastHit) |
{ |
- Filter.prototype.serialize.call(this, buffer); |
- if (this._disabled) |
- buffer.push("disabled=true"); |
- if (this._hitCount) |
- buffer.push("hitCount=" + this._hitCount); |
- if (this._lastHit) |
- buffer.push("lastHit=" + this._lastHit); |
+ yield* Filter.prototype.serialize.call(this); |
+ if (_disabled) |
+ yield "disabled=true"; |
+ if (_hitCount) |
+ yield "hitCount=" + _hitCount; |
+ if (_lastHit) |
+ yield "lastHit=" + _lastHit; |
} |
} |
}); |
/** |
* Abstract base class for RegExp-based filters |
* @param {string} text see {@link Filter Filter()} |
* @param {string} regexpSource |