Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 5 additions & 10 deletions packages/node_modules/pouchdb-core/src/adapter.js
Original file line number Diff line number Diff line change
Expand Up @@ -40,10 +40,6 @@ import {
* A generic pouch adapter
*/

function compare(left, right) {
return left < right ? -1 : left > right ? 1 : 0;
}

// Wrapper for functions that call the bulkdocs api with a single doc,
// if the first result is an error, return an error
function yankError(callback, docId) {
Expand Down Expand Up @@ -78,13 +74,12 @@ function cleanDocs(docs) {

// compare two docs, first by _id then by _rev
function compareByIdThenRev(a, b) {
var idCompare = compare(a._id, b._id);
if (idCompare !== 0) {
return idCompare;
if (a._id === b._id) {
const aStart = a._revisions ? a._revisions.start : 0;
const bStart = b._revisions ? b._revisions.start : 0;
return aStart - bStart;
}
var aStart = a._revisions ? a._revisions.start : 0;
var bStart = b._revisions ? b._revisions.start : 0;
return compare(aStart, bStart);
return a._id < b._id ? -1 : 1;
}

// for every node in a revision tree computes its distance from the closest
Expand Down