3.0.1 • Published 4 years ago

agg-watcher v3.0.1

Weekly downloads
3
License
ISC
Repository
github
Last release
4 years ago

agg-watcher

Aggregates add, change and unlink file events that happen while some async action is in progress.

API

aggregate(eventEmitter, callback, [setup])

Where:

  • eventEmitter - is anything which emits add, change and unlink events with optional Stat object as event payload
  • callback - will be called with minimal set of changes that describe what happened since last call. This function can return a Promise to delay subsequent calls until completition
  • setup - will be called just after initialization. This function can return a Promise to delay callback calls until completition

Example

const { aggregate } = require('agg-watcher')

aggregate(chokidar, async ({ added, changed, unlinked }) => {
  // this fn won't be called again previous invocation completes

  const all = [...added, ...changed, ...unlinked]
  for (const [path, maybeStat] of all) {
    console.log(path, maybeStat && maybeStat.mtime)
  }

  await doSomethingAsync(added, changed, unlinked)
})
3.0.1

4 years ago

3.0.0

5 years ago

2.0.0

8 years ago

1.0.0

8 years ago