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