[Pkg-javascript-commits] [node-shell-quote] 99/137: separate shim file to get the coverage up

Bastien Roucariès rouca at moszumanska.debian.org
Fri Aug 25 19:19:43 UTC 2017


This is an automated email from the git hooks/post-receive script.

rouca pushed a commit to branch master
in repository node-shell-quote.

commit e29a2167319913af3f26603bc33938bb9be1d74d
Author: James Halliday <mail at substack.net>
Date:   Tue Dec 24 12:42:03 2013 -0800

    separate shim file to get the coverage up
---
 index.js    | 28 ++--------------------------
 lib/shim.js | 25 +++++++++++++++++++++++++
 2 files changed, 27 insertions(+), 26 deletions(-)

diff --git a/index.js b/index.js
index ae4c8ee..00c9fd3 100644
--- a/index.js
+++ b/index.js
@@ -1,4 +1,6 @@
 var json = typeof JSON !== undefined ? JSON : require('jsonify');
+var shim = require('./lib/shim');
+var map = shim.map, filter = shim.filter, reduce = shim.reduce;
 
 exports.quote = function (xs) {
     return map(xs, function (s) {
@@ -176,29 +178,3 @@ function parse (s, env) {
         else return pre + r;
     }
 };
-
-function filter (xs, f) {
-    if (xs.filter) return xs.filter(f);
-    var res = [];
-    for (var i = 0; i < xs.length; i++) {
-        if (f(xs[i], i)) res.push(xs[i]);
-    }
-    return res;
-}
-
-function map (xs, f) {
-    if (xs.map) return xs.map(f);
-    var res = [];
-    for (var i = 0; i < xs.length; i++) {
-        res.push(f(xs[i], i));
-    }
-    return res;
-}
-
-function reduce (xs, f, acc) {
-    if (xs.reduce) return xs.reduce(f, acc);
-    for (var i = 0; i < xs.length; i++) {
-        acc = f(acc, xs[i], i);
-    }
-    return acc;
-}
diff --git a/lib/shim.js b/lib/shim.js
new file mode 100644
index 0000000..d15e826
--- /dev/null
+++ b/lib/shim.js
@@ -0,0 +1,25 @@
+exports.filter = function (xs, f) {
+    if (xs.filter) return xs.filter(f);
+    var res = [];
+    for (var i = 0; i < xs.length; i++) {
+        if (f(xs[i], i)) res.push(xs[i]);
+    }
+    return res;
+};
+
+exports.map = function (xs, f) {
+    if (xs.map) return xs.map(f);
+    var res = [];
+    for (var i = 0; i < xs.length; i++) {
+        res.push(f(xs[i], i));
+    }
+    return res;
+};
+
+exports.reduce = function (xs, f, acc) {
+    if (xs.reduce) return xs.reduce(f, acc);
+    for (var i = 0; i < xs.length; i++) {
+        acc = f(acc, xs[i], i);
+    }
+    return acc;
+};

-- 
Alioth's /usr/local/bin/git-commit-notice on /srv/git.debian.org/git/pkg-javascript/node-shell-quote.git



More information about the Pkg-javascript-commits mailing list