Index: lib/subscriptionClasses.js |
=================================================================== |
--- a/lib/subscriptionClasses.js |
+++ b/lib/subscriptionClasses.js |
@@ -12,15 +12,46 @@ |
* GNU General Public License for more details. |
* |
* You should have received a copy of the GNU General Public License |
* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>. |
*/ |
"use strict"; |
-const compiled = require("compiled"); |
-for (let cls of [ |
- "Subscription", "SpecialSubscription", "DownloadableSubscription" |
-]) |
-{ |
- exports[cls] = compiled[cls]; |
-} |
+const {Subscription, SpecialSubscription, DownloadableSubscription} = |
+ require("compiled"); |
+const {ArrayLike} = require("coreUtils"); |
Wladimir Palant
2017/05/01 14:47:25
This is left-over from a previous iteration, I alr
|
+ |
+/** |
+ * This property allows iterating over the list of filters. It will delete |
+ * references automatically at the end of the current loop iteration. If you |
+ * need persistent references or element access by position you should use |
+ * Subscription.filterAt() instead. |
+ * @type {Iterable} |
+ */ |
+Object.defineProperty(Subscription.prototype, "filters", { |
+ enumerable: true, |
+ get() |
+ { |
+ return { |
+ [Symbol.iterator]: function*() |
+ { |
+ for (let i = 0, l = this.filterCount; i < l; i++) |
+ { |
+ let filter = this.filterAt(i); |
+ try |
+ { |
+ yield filter; |
+ } |
+ finally |
+ { |
+ filter.delete(); |
+ } |
+ } |
+ }.bind(this) |
+ }; |
+ } |
+}); |
+ |
+exports.Subscription = Subscription; |
+exports.SpecialSubscription = SpecialSubscription; |
+exports.DownloadableSubscription = DownloadableSubscription; |