[Pkg-javascript-commits] [node-deps-sort] 48/79: fix dedupe for deps of deps
Bastien Roucariès
rouca at moszumanska.debian.org
Wed Sep 6 09:41:56 UTC 2017
This is an automated email from the git hooks/post-receive script.
rouca pushed a commit to branch master
in repository node-deps-sort.
commit eaefb3a94f9293465c1ed491323be52b345df72d
Author: Maximilian Antoni <mail at maxantoni.de>
Date: Mon Aug 11 16:34:59 2014 +0200
fix dedupe for deps of deps
Make sure that all hashes for all rows are available before comparing
dependencies. Otherwise dependencies of dependencies might come later in
the stream and are not yet hashed.
---
index.js | 17 +++++++++++------
1 file changed, 11 insertions(+), 6 deletions(-)
diff --git a/index.js b/index.js
index 4243b57..8454f40 100644
--- a/index.js
+++ b/index.js
@@ -32,14 +32,19 @@ function sorter (rows, tr, opts) {
rows.forEach(function (row) {
var h = shasum(row.source);
sameDeps.add(row, h);
-
if (hashes[h]) {
- row.dedupe = hashes[h].id;
- row.sameDeps = sameDeps.cmp(row.deps, hashes[h].deps);
- deduped[row.id] = hashes[h].id;
+ hashes[h].push(row);
+ } else {
+ hashes[h] = [row];
}
- else {
- hashes[h] = row;
+ });
+ Object.keys(hashes).forEach(function (h) {
+ var rows = hashes[h];
+ while (rows.length > 1) {
+ var row = rows.pop();
+ row.dedupe = rows[0].id;
+ row.sameDeps = sameDeps.cmp(rows[0].deps, row.deps);
+ deduped[row.id] = rows[0].id;
}
});
}
--
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-deps-sort.git
More information about the Pkg-javascript-commits
mailing list