MCPcopy Create free account
hub / github.com/apache/pouchdb / constructor

Method constructor

lib/index.js:10400–10582  ·  view source on GitHub ↗
(src, target, opts, callback)

Source from the content-addressed store, hash-verified

10398
10399class 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 });

Callers 1

_setupMethod · 0.45

Calls 3

cancelMethod · 0.95
replicateWrapperFunction · 0.70
removeListenerMethod · 0.45

Tested by

no test coverage detected