(src, target, opts, callback)
| 10393 | |
| 10394 | class Sync extends EE { |
| 10395 | constructor(src, target, opts, callback) { |
| 10396 | super(); |
| 10397 | this.canceled = false; |
| 10398 | |
| 10399 | const optsPush = opts.push ? Object.assign({}, opts, opts.push) : opts; |
| 10400 | const optsPull = opts.pull ? Object.assign({}, opts, opts.pull) : opts; |
| 10401 | |
| 10402 | this.push = replicateWrapper(src, target, optsPush); |
| 10403 | this.pull = replicateWrapper(target, src, optsPull); |
| 10404 | |
| 10405 | this.pushPaused = true; |
| 10406 | this.pullPaused = true; |
| 10407 | |
| 10408 | const pullChange = (change) => { |
| 10409 | this.emit('change', { |
| 10410 | direction: 'pull', |
| 10411 | change |
| 10412 | }); |
| 10413 | }; |
| 10414 | const pushChange = (change) => { |
| 10415 | this.emit('change', { |
| 10416 | direction: 'push', |
| 10417 | change |
| 10418 | }); |
| 10419 | }; |
| 10420 | const pushDenied = (doc) => { |
| 10421 | this.emit('denied', { |
| 10422 | direction: 'push', |
| 10423 | doc |
| 10424 | }); |
| 10425 | }; |
| 10426 | const pullDenied = (doc) => { |
| 10427 | this.emit('denied', { |
| 10428 | direction: 'pull', |
| 10429 | doc |
| 10430 | }); |
| 10431 | }; |
| 10432 | const pushPaused = () => { |
| 10433 | this.pushPaused = true; |
| 10434 | /* istanbul ignore if */ |
| 10435 | if (this.pullPaused) { |
| 10436 | this.emit('paused'); |
| 10437 | } |
| 10438 | }; |
| 10439 | const pullPaused = () => { |
| 10440 | this.pullPaused = true; |
| 10441 | /* istanbul ignore if */ |
| 10442 | if (this.pushPaused) { |
| 10443 | this.emit('paused'); |
| 10444 | } |
| 10445 | }; |
| 10446 | const pushActive = () => { |
| 10447 | this.pushPaused = false; |
| 10448 | /* istanbul ignore if */ |
| 10449 | if (this.pullPaused) { |
| 10450 | this.emit('active', { |
| 10451 | direction: 'push' |
| 10452 | }); |
no test coverage detected