[Pkg-javascript-commits] [node-shell-quote] 100/137: use array-{filter, map, reduce}

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 97a2fc9c92917343a33662b3705860e4f2044730
Author: James Halliday <mail at substack.net>
Date:   Tue Dec 24 16:57:51 2013 -0800

    use array-{filter,map,reduce}
---
 index.js     |  5 +++--
 lib/shim.js  | 25 -------------------------
 package.json |  5 ++++-
 3 files changed, 7 insertions(+), 28 deletions(-)

diff --git a/index.js b/index.js
index 00c9fd3..8560426 100644
--- a/index.js
+++ b/index.js
@@ -1,6 +1,7 @@
 var json = typeof JSON !== undefined ? JSON : require('jsonify');
-var shim = require('./lib/shim');
-var map = shim.map, filter = shim.filter, reduce = shim.reduce;
+var map = require('array-map');
+var filter = require('array-filter');
+var reduce = require('array-reduce');
 
 exports.quote = function (xs) {
     return map(xs, function (s) {
diff --git a/lib/shim.js b/lib/shim.js
deleted file mode 100644
index d15e826..0000000
--- a/lib/shim.js
+++ /dev/null
@@ -1,25 +0,0 @@
-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;
-};
diff --git a/package.json b/package.json
index 111da61..83b0e9c 100644
--- a/package.json
+++ b/package.json
@@ -43,6 +43,9 @@
   },
   "license": "MIT",
   "dependencies": {
-    "jsonify": "0.0.0"
+    "jsonify": "~0.0.0",
+    "array-filter": "~0.0.0",
+    "array-reduce": "~0.0.0",
+    "array-map": "~0.0.0"
   }
 }

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