[Pkg-javascript-commits] [node-deps-sort] 26/79: reindent

Bastien Roucariès rouca at moszumanska.debian.org
Wed Sep 6 09:41:54 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 fd7adb96866c64e4967c587ff42c5ba4d8e50b76
Author: James Halliday <mail at substack.net>
Date:   Mon Jul 21 07:03:18 2014 -0700

    reindent
---
 index.js | 91 +++++++++++++++++++++++++++++++++-------------------------------
 1 file changed, 47 insertions(+), 44 deletions(-)

diff --git a/index.js b/index.js
index cf26e77..d0b1dae 100644
--- a/index.js
+++ b/index.js
@@ -20,54 +20,57 @@ module.exports = function (opts) {
     function end () {
         var tr = this;
         rows.sort(cmp);
-        
-        if (opts.index) {
-            var index = {};
-            var offset = 0;
-            rows.forEach(function (row, ix) {
-                if (has(expose, row.id)) {
-                    row.index = row.id;
-                    offset ++;
-                    if (expose[row.id] !== true) {
-                        index[expose[row.id]] = row.index;
-                    }
-                }
-                else {
-                    row.index = ix + 1 - offset;
+        sorter(rows, tr, opts);
+    }
+};
+
+function sorter (rows, tr, opts) {
+    if (opts.index) {
+        var index = {};
+        var offset = 0;
+        rows.forEach(function (row, ix) {
+            if (has(expose, row.id)) {
+                row.index = row.id;
+                offset ++;
+                if (expose[row.id] !== true) {
+                    index[expose[row.id]] = row.index;
                 }
-                index[row.id] = row.index;
-            });
-            rows.forEach(function (row) {
-                row.indexDeps = {};
-                Object.keys(row.deps).forEach(function (key) {
-                    row.indexDeps[key] = index[row.deps[key]];
-                });
-                tr.push(row);
+            }
+            else {
+                row.index = ix + 1 - offset;
+            }
+            index[row.id] = row.index;
+        });
+        rows.forEach(function (row) {
+            row.indexDeps = {};
+            Object.keys(row.deps).forEach(function (key) {
+                row.indexDeps[key] = index[row.deps[key]];
             });
-        }
-        else {
-            var dedupeIndex = 0, hashes = {}, hmap = {};
-            rows.forEach(function (row, ix) {
-                if (opts.dedupe) {
-                    var h = shasum(row.source);
-                    if (hashes[h] === true) {
-                        hashes[h] = ++ dedupeIndex;
-                        rows[hmap[h]].dedupe = hashes[h];
-                        row.dedupe = hashes[h];
-                    }
-                    else if (hashes[h]) {
-                        row.dedupe = hashes[h];
-                    }
-                    else {
-                        hashes[h] = true;
-                        hmap[h] = ix;
-                    }
+            tr.push(row);
+        });
+    }
+    else {
+        var dedupeIndex = 0, hashes = {}, hmap = {};
+        rows.forEach(function (row, ix) {
+            if (opts.dedupe) {
+                var h = shasum(row.source);
+                if (hashes[h] === true) {
+                    hashes[h] = ++ dedupeIndex;
+                    rows[hmap[h]].dedupe = hashes[h];
+                    row.dedupe = hashes[h];
                 }
-                tr.push(row);
-            });
-        }
-        tr.push(null);
+                else if (hashes[h]) {
+                    row.dedupe = hashes[h];
+                }
+                else {
+                    hashes[h] = true;
+                    hmap[h] = ix;
+                }
+            }
+            tr.push(row);
+        });
     }
+    tr.push(null);
 };
 
 function cmp (a, b) {

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