[Pkg-javascript-commits] [node-deps-sort] 20/79: expose string

Bastien Roucariès rouca at moszumanska.debian.org
Wed Sep 6 09:41:53 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 0f6096b1c032933cf07c4bf4e002846e303a579c
Author: James Halliday <mail at substack.net>
Date:   Mon Jul 21 05:31:16 2014 -0700

    expose string
---
 index.js       | 17 ++++++++++++-----
 test/expose.js |  2 +-
 2 files changed, 13 insertions(+), 6 deletions(-)

diff --git a/index.js b/index.js
index a0a38c5..f5fa01e 100644
--- a/index.js
+++ b/index.js
@@ -24,9 +24,12 @@ module.exports = function (opts) {
             var index = {};
             var offset = 0;
             rows.forEach(function (row, ix) {
-                if (expose[row.id]) {
+                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;
@@ -48,8 +51,12 @@ module.exports = function (opts) {
         }
         tr.push(null);
     }
-    
-    function cmp (a, b) {
-        return a.id + a.hash < b.id + b.hash ? -1 : 1;
-    }
 };
+
+function cmp (a, b) {
+    return a.id + a.hash < b.id + b.hash ? -1 : 1;
+}
+
+function has (obj, key) {
+    return Object.prototype.hasOwnProperty.call(obj, key);
+}
diff --git a/test/expose.js b/test/expose.js
index 1d29728..6d0cece 100644
--- a/test/expose.js
+++ b/test/expose.js
@@ -2,7 +2,7 @@ var sort = require('../');
 var test = require('tape');
 var through = require('through2');
 
-test('expose', function (t) {
+test('expose true', function (t) {
     t.plan(1);
     var s = sort({ index: true, expose: [ '/foo.js', '/bar.js' ] });
     var rows = [];

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