[Pkg-javascript-commits] [node-deps-sort] 05/79: include index and indexDeps when opts.index is true

Bastien Roucariès rouca at moszumanska.debian.org
Wed Sep 6 09:41:51 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 2ae900fad56e918153b7378d352d027728f1a3b8
Author: James Halliday <mail at substack.net>
Date:   Mon Jul 8 23:34:32 2013 -0700

    include index and indexDeps when opts.index is true
---
 index.js | 24 +++++++++++++++++++++---
 1 file changed, 21 insertions(+), 3 deletions(-)

diff --git a/index.js b/index.js
index cb4a9ad..003342b 100644
--- a/index.js
+++ b/index.js
@@ -10,9 +10,27 @@ module.exports = function (opts) {
     
     function end () {
         var tr = this;
-        rows.sort(cmp).forEach(function (row) {
-            tr.queue(row);
-        });
+        rows.sort(cmp);
+        
+        if (opts.index) {
+            var index = {};
+            rows.forEach(function (row, ix) {
+                row.index = ix;
+                index[row.id] = ix;
+            });
+            rows.forEach(function (row, ix) {
+                row.indexDeps = {};
+                Object.keys(row.deps).forEach(function (key) {
+                    row.indexDeps[key] = index[row.deps[key]];
+                });
+                tr.queue(row);
+            });
+        }
+        else {
+            rows.forEach(function (row) {
+                tr.queue(row);
+            });
+        }
         tr.queue(null);
     }
     

-- 
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