watchpack
Advanced tools
Comparing version 2.1.1 to 2.2.0
@@ -305,10 +305,23 @@ /* | ||
getAggregated() { | ||
if (this.aggregateTimer) { | ||
clearTimeout(this.aggregateTimer); | ||
this.aggregateTimer = undefined; | ||
} | ||
const changes = this.aggregatedChanges; | ||
const removals = this.aggregatedRemovals; | ||
this.aggregatedChanges = new Set(); | ||
this.aggregatedRemovals = new Set(); | ||
return { changes, removals }; | ||
} | ||
_onChange(item, mtime, file, type) { | ||
file = file || item; | ||
if (this.paused) return; | ||
this.emit("change", file, mtime, type); | ||
if (this.aggregateTimer) clearTimeout(this.aggregateTimer); | ||
if (!this.paused) { | ||
this.emit("change", file, mtime, type); | ||
if (this.aggregateTimer) clearTimeout(this.aggregateTimer); | ||
this.aggregateTimer = setTimeout(this._onTimeout, this.aggregateTimeout); | ||
} | ||
this.aggregatedRemovals.delete(item); | ||
this.aggregatedChanges.add(item); | ||
this.aggregateTimer = setTimeout(this._onTimeout, this.aggregateTimeout); | ||
} | ||
@@ -318,8 +331,9 @@ | ||
file = file || item; | ||
if (this.paused) return; | ||
this.emit("remove", file, type); | ||
if (this.aggregateTimer) clearTimeout(this.aggregateTimer); | ||
if (!this.paused) { | ||
this.emit("remove", file, type); | ||
if (this.aggregateTimer) clearTimeout(this.aggregateTimer); | ||
this.aggregateTimer = setTimeout(this._onTimeout, this.aggregateTimeout); | ||
} | ||
this.aggregatedChanges.delete(item); | ||
this.aggregatedRemovals.add(item); | ||
this.aggregateTimer = setTimeout(this._onTimeout, this.aggregateTimeout); | ||
} | ||
@@ -326,0 +340,0 @@ |
{ | ||
"name": "watchpack", | ||
"version": "2.1.1", | ||
"version": "2.2.0", | ||
"description": "", | ||
@@ -5,0 +5,0 @@ "main": "./lib/watchpack.js", |
@@ -101,2 +101,4 @@ # watchpack | ||
// next "watch" call can reuse the watchers | ||
// The watcher will keep aggregating events | ||
// which can be received with getAggregated() | ||
@@ -107,2 +109,9 @@ // Watchpack.prototype.close() | ||
// Watchpack.prototype.getAggregated(): { changes: Set<string>, removals: Set<string> } | ||
const { changes, removals } = wp.getAggregated(); | ||
// returns the current aggregated info and removes that from the watcher | ||
// The next aggregated event won't include that info and will only emitted | ||
// when futher changes happen | ||
// Can also be used when paused. | ||
// Watchpack.prototype.getTimeInfoEntries() | ||
@@ -109,0 +118,0 @@ var fileTimes = wp.getTimeInfoEntries(); |
56056
1657
143