@klasa/event-iterator
Advanced tools
Comparing version 0.0.7 to 0.0.8
@@ -19,2 +19,6 @@ /// <reference types="node" /> | ||
idle?: number; | ||
/** | ||
* The limit of events that pass the filter to iterate. | ||
*/ | ||
limit?: number; | ||
} | ||
@@ -38,3 +42,3 @@ /** | ||
*/ | ||
constructor(emitter: EventEmitter, event: string, limit: number, options?: EventIteratorOptions<V>); | ||
constructor(emitter: EventEmitter, event: string, options?: EventIteratorOptions<V>); | ||
/** | ||
@@ -41,0 +45,0 @@ * Whether or not the EventIterator has ended. |
@@ -15,3 +15,3 @@ "use strict"; | ||
}; | ||
var _ended, _idle, _queue, _collected, _limit; | ||
var _ended, _idle, _queue, _passed, _limit; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
@@ -30,4 +30,4 @@ exports.EventIterator = void 0; | ||
*/ | ||
constructor(emitter, event, limit, options = {}) { | ||
var _a; | ||
constructor(emitter, event, options = {}) { | ||
var _a, _b; | ||
this.emitter = emitter; | ||
@@ -48,5 +48,5 @@ this.event = event; | ||
/** | ||
* The amount of collected values. | ||
* The amount of events that have passed the filter. | ||
*/ | ||
_collected.set(this, 0); | ||
_passed.set(this, 0); | ||
/** | ||
@@ -56,5 +56,5 @@ * The limit before ending the EventIterator. | ||
_limit.set(this, void 0); | ||
__classPrivateFieldSet(this, _limit, limit); | ||
__classPrivateFieldSet(this, _limit, (_a = options.limit) !== null && _a !== void 0 ? _a : Infinity); | ||
__classPrivateFieldSet(this, _idle, options.idle); | ||
this.filter = (_a = options.filter) !== null && _a !== void 0 ? _a : (() => true); | ||
this.filter = (_b = options.filter) !== null && _b !== void 0 ? _b : (() => true); | ||
this.push = this.push.bind(this); | ||
@@ -93,3 +93,3 @@ const maxListeners = this.emitter.getMaxListeners(); | ||
return this.next(); | ||
if (__classPrivateFieldSet(this, _collected, +__classPrivateFieldGet(this, _collected) + 1) >= __classPrivateFieldGet(this, _limit)) | ||
if (__classPrivateFieldSet(this, _passed, +__classPrivateFieldGet(this, _passed) + 1) >= __classPrivateFieldGet(this, _limit)) | ||
this.end(); | ||
@@ -132,3 +132,3 @@ return { done: false, value }; | ||
*/ | ||
[(_ended = new WeakMap(), _idle = new WeakMap(), _queue = new WeakMap(), _collected = new WeakMap(), _limit = new WeakMap(), Symbol.asyncIterator)]() { | ||
[(_ended = new WeakMap(), _idle = new WeakMap(), _queue = new WeakMap(), _passed = new WeakMap(), _limit = new WeakMap(), Symbol.asyncIterator)]() { | ||
return this; | ||
@@ -135,0 +135,0 @@ } |
{ | ||
"name": "@klasa/event-iterator", | ||
"version": "0.0.7", | ||
"version": "0.0.8", | ||
"description": "Turns event emitter events into async iterators.", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
Sorry, the diff of this file is not supported yet
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
12408
207