Skip to content

Commit

Permalink
WIP
Browse files Browse the repository at this point in the history
  • Loading branch information
taratatach committed Oct 17, 2024
1 parent 12ad2b4 commit 8151f6a
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions core/local/chokidar/analysis.js
Original file line number Diff line number Diff line change
Expand Up @@ -72,7 +72,7 @@ module.exports = function analysis(

class LocalChangeMap {
/*::
changes: LocalChange[]
changes: Set<LocalChange>
changesByInode: Map<number, LocalChange>
changesByPath: Map<string, LocalChange>
*/
Expand All @@ -82,7 +82,7 @@ class LocalChangeMap {
}

_clear() {
this.changes = []
this.changes = new Set()
this.changesByInode = new Map()
this.changesByPath = new Map()
}
Expand All @@ -108,25 +108,25 @@ class LocalChangeMap {
if (typeof toReplace.ino === 'number') {
this.changesByInode.set(toReplace.ino, c)
} else {
const index = this.changes.indexOf(toReplace)
this.changes.splice(index, 1, c)
this.changes.delete(toReplace)
this.changes.add(c)
}
} else {
this.changesByPath.set(c.path.normalize(), c)

if (typeof c.ino === 'number') {
this.changesByInode.set(c.ino, c)
} else {
this.changes.push(c)
this.changes.add(c)
}
}
}

flush() /*: LocalChange[] */ {
const changes = this.changes
for (let a of this.changesByInode.values()) changes.push(a)
for (let a of this.changesByInode.values()) changes.add(a)
this._clear()
return changes
return Array.from(changes)
}
}

Expand Down Expand Up @@ -157,7 +157,7 @@ function analyseEvents(

log.trace('Analyze events...')

for (let e /*: LocalEvent */ of events) {
for (const e /*: LocalEvent */ of events) {
if (process.env.DEBUG) log.trace({ currentEvent: e, path: e.path })
try {
// chokidar make mistakes
Expand Down

0 comments on commit 8151f6a

Please sign in to comment.