[Pkg-javascript-commits] [node-lexical-scope] 08/83: docs

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 5144d62ec2f5e57aa82db7362bace473a1c84726
Author: James Halliday <mail at substack.net>
Date:   Sun Feb 17 15:01:48 2013 +1000

    docs
---
 readme.markdown | 91 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 91 insertions(+)

diff --git a/readme.markdown b/readme.markdown
new file mode 100644
index 0000000..956051b
--- /dev/null
+++ b/readme.markdown
@@ -0,0 +1,91 @@
+# lexical-scope
+
+detect global and local lexical identifiers from javascript source code
+
+# example
+
+``` js
+var detect = require('lexical-scope');
+var fs = require('fs');
+var src = fs.readFileSync(__dirname + '/src.js');
+
+var scope = detect(src);
+console.dir(scope);
+```
+
+input:
+
+```
+var x = 5;
+var y = 3, z = 2;
+
+w.foo();
+w = 2;
+
+RAWR=444;
+RAWR.foo();
+
+BLARG=3;
+
+foo(function () {
+    var BAR = 3;
+    process.nextTick(function (ZZZZZZZZZZZZ) {
+        console.log('beep boop');
+        var xyz = 4;
+        x += 10;
+        x.zzzzzz;
+        ZZZ=6;
+    });
+    function doom () {
+    }
+    ZZZ.foo();
+
+});
+
+console.log(xyz);
+```
+
+output:
+
+```
+$ node example/detect.js
+{ locals: 
+   { '': [ 'x', 'y', 'z' ],
+     'body.7.arguments.0': [ 'BAR', 'doom' ],
+     'body.7.arguments.0.body.1.arguments.0': [ 'xyz' ],
+     'body.7.arguments.0.body.2': [] },
+  globals: 
+   { implicit: [ 'w', 'foo', 'process', 'console', 'xyz' ],
+     exported: [ 'w', 'RAWR', 'BLARG', 'ZZZ' ] } }
+```
+
+# methods
+
+``` js
+var detect = require('lexical-scope')
+```
+
+## var scope = detect(src)
+
+Return a `scope` structure from a javascript source string `src`.
+
+`scope.locals` maps scope name keys to an array of local variable names declared
+with `var`. The key name `''` refers to the top-level scope.
+
+`scope.globals.implicit` contains the global variable names that are expected to
+already exist in the environment by the script.
+
+`scope.globals.explicit` contains the global variable names that are exported by
+the script.
+
+# install
+
+With [npm](https://npmjs.org) do:
+
+```
+npm install lexical-scope
+```
+
+# license
+
+MIT

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