pouchdb-merge
Advanced tools
Comparing version 6.1.1 to 6.1.2
@@ -318,3 +318,3 @@ 'use strict'; | ||
var paths = rootToLeaf(tree); | ||
var maybeStem = {}; | ||
var stemmedRevs; | ||
@@ -327,11 +327,23 @@ var result; | ||
var stemmed = path.ids; | ||
var numStemmed = Math.max(0, stemmed.length - depth); | ||
var stemmedNode = { | ||
pos: path.pos + numStemmed, | ||
ids: pathToTree(stemmed, numStemmed) | ||
}; | ||
var node; | ||
if (stemmed.length > depth) { | ||
// only do the stemming work if we actually need to stem | ||
if (!stemmedRevs) { | ||
stemmedRevs = {}; // avoid allocating this object unnecessarily | ||
} | ||
var numStemmed = stemmed.length - depth; | ||
node = { | ||
pos: path.pos + numStemmed, | ||
ids: pathToTree(stemmed, numStemmed) | ||
}; | ||
for (var s = 0; s < numStemmed; s++) { | ||
var rev = (path.pos + s) + '-' + stemmed[s].id; | ||
maybeStem[rev] = true; | ||
for (var s = 0; s < numStemmed; s++) { | ||
var rev = (path.pos + s) + '-' + stemmed[s].id; | ||
stemmedRevs[rev] = true; | ||
} | ||
} else { // no need to actually stem | ||
node = { | ||
pos: path.pos, | ||
ids: pathToTree(stemmed, 0) | ||
}; | ||
} | ||
@@ -342,16 +354,19 @@ | ||
if (result) { | ||
result = doMerge(result, stemmedNode, true).tree; | ||
result = doMerge(result, node, true).tree; | ||
} else { | ||
result = [stemmedNode]; | ||
result = [node]; | ||
} | ||
} | ||
traverseRevTree(result, function (isLeaf, pos, revHash) { | ||
// some revisions may have been removed in a branch but not in another | ||
delete maybeStem[pos + '-' + revHash]; | ||
}); | ||
// this is memory-heavy per Chrome profiler, avoid unless we actually stemmed | ||
if (stemmedRevs) { | ||
traverseRevTree(result, function (isLeaf, pos, revHash) { | ||
// some revisions may have been removed in a branch but not in another | ||
delete stemmedRevs[pos + '-' + revHash]; | ||
}); | ||
} | ||
return { | ||
tree: result, | ||
revs: Object.keys(maybeStem) | ||
revs: stemmedRevs ? Object.keys(stemmedRevs) : [] | ||
}; | ||
@@ -358,0 +373,0 @@ } |
{ | ||
"name": "pouchdb-merge", | ||
"version": "6.1.1", | ||
"version": "6.1.2", | ||
"description": "PouchDB's document merge algorithm.", | ||
@@ -10,8 +10,9 @@ "main": "./lib/index.js", | ||
"repository": "https://github.com/pouchdb/pouchdb", | ||
"jsnext:main": "./src/index.js", | ||
"jsnext:main": "./lib/index.es.js", | ||
"dependencies": {}, | ||
"files": [ | ||
"lib", | ||
"src" | ||
], | ||
"dependencies": {} | ||
"dist", | ||
"tonic-example.js" | ||
] | ||
} |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
Major refactor
Supply chain riskPackage has recently undergone a major refactor. It may be unstable or indicate significant internal changes. Use caution when updating to versions that include significant changes.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
39150
5