Skip to content

Commit

Permalink
Merge pull request cayasso#62 from will123195/patch-2
Browse files Browse the repository at this point in the history
Fix circular dependency
  • Loading branch information
cayasso authored Mar 16, 2018
2 parents cb8f124 + 70b1e51 commit e5b6281
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/filter.js
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,12 @@

const Emitter = require('eventemitter3')
const dbg = require('debug')
const { events } = require('./')

const events = {
i: 'insert',
u: 'update',
d: 'delete'
}

function regex(pattern) {
pattern = pattern || '*'
Expand All @@ -21,7 +26,9 @@ module.exports = (ns, oplog) => {
if (!re.test(doc.ns) || filter.ignore) return
debug('incoming data %j', doc)
filter.emit('op', doc)
filter.emit(events[doc.op], doc)
if (events[doc.op]) {
filter.emit(events[doc.op], doc)
}
}

function destroy() {
Expand Down

0 comments on commit e5b6281

Please sign in to comment.