[Pkg-javascript-commits] [node-lexical-scope] 14/83: shim .indexOf for <es5

Bastien Roucariès rouca at moszumanska.debian.org
Fri Dec 15 09:45:46 UTC 2017


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

rouca pushed a commit to branch master
in repository node-lexical-scope.

commit b104eb8a7f1e701c322b0ed3291b9701e11e65d5
Author: James Halliday <mail at substack.net>
Date:   Mon Feb 18 15:16:49 2013 +1000

    shim .indexOf for <es5
---
 index.js     | 10 +++++++++-
 package.json |  2 +-
 2 files changed, 10 insertions(+), 2 deletions(-)

diff --git a/index.js b/index.js
index 6cf2073..dc0754b 100644
--- a/index.js
+++ b/index.js
@@ -119,7 +119,7 @@ function keyOf (node) {
             kv.top.push.apply(kv.top, nkeys);
         }
     }
-    var ix = kv.values.indexOf(node);
+    var ix = indexOf(kv.values, node);
     var res = [];
     if (kv.top[ix]) res.push(kv.top[ix]);
     if (kv.keys[ix]) res.push(kv.keys[ix]);
@@ -138,3 +138,11 @@ var objectKeys = Object.keys || function (obj) {
     for (var key in obj) keys.push(key);
     return keys;
 };
+
+function indexOf (xs, x) {
+    if (xs.indexOf) return xs.indexOf(x);
+    for (var i = 0; i < xs.length; i++) {
+        if (x === xs[i]) return i;
+    }
+    return -1;
+}
diff --git a/package.json b/package.json
index 9e80113..cfb4763 100644
--- a/package.json
+++ b/package.json
@@ -1,6 +1,6 @@
 {
     "name": "lexical-scope",
-    "version": "0.0.1",
+    "version": "0.0.2",
     "description": "detect global and local lexical identifiers from javascript source code",
     "main": "index.js",
     "dependencies": {

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



More information about the Pkg-javascript-commits mailing list