Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
return new Promise(function (resolve, reject) {
if (Array.isArray(docsOrIds)) {
docsOrIds = docsOrIds.map(toId)
} else {
docsOrIds = docsOrIds && [toId(docsOrIds)]
}
if (docsOrIds && docsOrIds.filter(Boolean).length !== docsOrIds.length) {
return Promise.reject(errors.NOT_AN_OBJECT)
}
var replication = state.db.replicate.from(remote, {
doc_ids: docsOrIds
})
/* istanbul ignore next */
replication.catch(function () {
// handled trough 'error' event
})
replication.on('complete', function () {
resolve(pulledObjects)
})
replication.on('error', reject)
return new Promise(function (resolve, reject) {
if (Array.isArray(docsOrIds)) {
docsOrIds = docsOrIds.map(toId)
} else {
docsOrIds = docsOrIds && [toId(docsOrIds)]
}
if (docsOrIds && docsOrIds.filter(Boolean).length !== docsOrIds.length) {
return Promise.reject(errors.NOT_AN_OBJECT)
}
var replication = state.db.replicate.to(remote, {
create_target: true,
doc_ids: docsOrIds,
include_docs: true
})
/* istanbul ignore next */
replication.catch(function () {
// handled trough 'error' event
})
replication.on('complete', function () {
resolve(pushedObjects)
})
HTMLVideo.prototype.resumeAd = method(function resumeAd() {
var self = this;
var video = this.video;
if (!this.__private__.hasPlayed) {
return LiePromise.reject(new Error('The ad has not been started yet.'));
}
if (!this.video.paused) {
return LiePromise.resolve(this);
}
return new LiePromise(function callPlay(resolve) {
once(video, HTML_MEDIA_EVENTS.PLAY, function onplay() {
resolve(self);
self.emit(VPAID_EVENTS.AdPlaying);
});
return video.play();
});
}, true);
HTMLVideo.prototype.startAd = method(function startAd() {
var self = this;
var video = this.video;
if (this.__private__.hasPlayed) {
return LiePromise.reject(new Error('The ad has already been started.'));
}
return new LiePromise(function callPlay(resolve) {
once(video, HTML_MEDIA_EVENTS.PLAYING, function onplaying() {
resolve(self);
self.emit(VPAID_EVENTS.AdStarted);
});
return video.play();
});
}, true);
return function callImplementation(/*...args*/) {
if (!this.video) {
if (promiseify) { return LiePromise.reject(getError()); } else { throw getError(); }
}
return implementation.apply(this, arguments);
};
}
module.exports = function updateOne (state, idOrDoc, change, prefix) {
var doc
if (typeof idOrDoc === 'string' && !change) {
return Promise.reject(PouchDBErrors.NOT_AN_OBJECT)
}
return findOne(state, idOrDoc, prefix)
.then(function (doc) {
if (!change) {
return assign(doc, idOrDoc, {_id: doc._id, _rev: doc._rev, hoodie: doc.hoodie})
}
return changeObject(state, change, doc)
})
.then(function (_doc) {
doc = _doc
return put(state, addTimestamps(doc))
})
function update (state, prefix, objectsOrIds, change) {
if (typeof objectsOrIds !== 'object' && !change) {
return Promise.reject(
new Error('Must provide change')
)
}
return Array.isArray(objectsOrIds)
? updateMany(state, objectsOrIds, change, prefix)
: updateOne(state, objectsOrIds, change, prefix)
}
function updateAll (state, prefix, changedProperties) {
var type = typeof changedProperties
var docs
if (type !== 'object' && type !== 'function') {
return Promise.reject(new Error('Must provide object or function'))
}
var options = {
include_docs: true
}
if (prefix) {
options.startkey = prefix
options.endkey = prefix + '\uffff'
}
return state.db.allDocs(options)
.then(function (res) {
docs = res.rows
.filter(isntDesignDoc)
function addOne (state, doc, prefix) {
if (typeof doc !== 'object') {
return Promise.reject(PouchDBErrors.NOT_AN_OBJECT)
}
doc = clone(doc)
if (!doc._id) {
doc._id = uuid()
}
if (prefix) {
doc._id = prefix + doc._id
}
delete doc.hoodie
return validate(state, doc)
return function callMethod() {
var self = this;
var player = this.__private__.player;
if (!this.ready) {
return LiePromise.reject(getNotReadyError());
}
return player[method].apply(player, arguments).then(function() {
return self;
});
};
}