[Pkg-javascript-commits] [node-lexical-scope] 29/83: add function arguments to local scope

Bastien Roucariès rouca at moszumanska.debian.org
Fri Dec 15 09:45:48 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 c6aa63fd81f034476d445a5f8ebeea545d5066dc
Author: James Halliday <mail at substack.net>
Date:   Sat Mar 30 00:23:23 2013 -0700

    add function arguments to local scope
---
 index.js | 11 +++++++++--
 1 file changed, 9 insertions(+), 2 deletions(-)

diff --git a/index.js b/index.js
index 0e9fadf..d292293 100644
--- a/index.js
+++ b/index.js
@@ -1,4 +1,5 @@
 var astw = require('astw');
+var deparse = require('escodegen').generate;
 
 module.exports = function (src) {
     var locals = {};
@@ -17,9 +18,15 @@ module.exports = function (src) {
                 locals[id][d.id.name] = d;
             }
         }
-        else if (node.type === 'FunctionDeclaration') {
+        else if (isFunction(node)) {
             var id = getScope(node.parent);
-            locals[id][node.id.name] = node;
+            if (node.id) locals[id][node.id.name] = node;
+            var nid = node.params.length && getScope(node);
+            if (nid && !locals[nid]) locals[nid] = {};
+            for (var i = 0; i < node.params.length; i++) {
+                var p = node.params[i];
+                locals[nid][p.name] = p;
+            }
         }
     });
     

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