lexical-scope

WebJar for lexical-scope

Лицензия

Лицензия

MIT
Группа

Группа

org.webjars.npm
Идентификатор

Идентификатор

lexical-scope
Последняя версия

Последняя версия

1.2.0
Дата

Дата

Тип

Тип

jar
Описание

Описание

lexical-scope
WebJar for lexical-scope
Ссылка на сайт

Ссылка на сайт

http://webjars.org
Система контроля версий

Система контроля версий

https://github.com/substack/lexical-scope

Скачать lexical-scope

Как подключить последнюю версию

<!-- https://jarcasting.com/artifacts/org.webjars.npm/lexical-scope/ -->
<dependency>
    <groupId>org.webjars.npm</groupId>
    <artifactId>lexical-scope</artifactId>
    <version>1.2.0</version>
</dependency>
// https://jarcasting.com/artifacts/org.webjars.npm/lexical-scope/
implementation 'org.webjars.npm:lexical-scope:1.2.0'
// https://jarcasting.com/artifacts/org.webjars.npm/lexical-scope/
implementation ("org.webjars.npm:lexical-scope:1.2.0")
'org.webjars.npm:lexical-scope:jar:1.2.0'
<dependency org="org.webjars.npm" name="lexical-scope" rev="1.2.0">
  <artifact name="lexical-scope" type="jar" />
</dependency>
@Grapes(
@Grab(group='org.webjars.npm', module='lexical-scope', version='1.2.0')
)
libraryDependencies += "org.webjars.npm" % "lexical-scope" % "1.2.0"
[org.webjars.npm/lexical-scope "1.2.0"]

Зависимости

compile (1)

Идентификатор библиотеки Тип Версия
org.webjars.npm : astw jar [2.0.0,3)

Модули Проекта

Данный проект не имеет модулей.

lexical-scope

detect global and local lexical identifiers from javascript source code

browser support

build status

example

var detect = require('lexical-scope');
var fs = require('fs');
var src = fs.readFileSync(__dirname + '/src.js');

var scope = detect(src);
console.log(JSON.stringify(scope,null,2));

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.expression.body.7.arguments.0": [
      "BAR",
      "doom"
    ],
    "body.7.expression.body.7.arguments.0.body.body.1.expression.body.1.arguments.0": [
      "xyz",
      "ZZZZZZZZZZZZ"
    ],
    "body.7.expression.body.7.arguments.0.body.body.2": []
  },
  "globals": {
    "implicit": [
      "w",
      "foo",
      "process",
      "console",
      "xyz"
    ],
    "implicitProperties": {
      "w": [
        "foo"
      ],
      "foo": [
        "()"
      ],
      "process": [
        "nextTick"
      ],
      "console": [
        "log"
      ],
      "xyz": [
        "*"
      ]
    },
    "exported": [
      "w",
      "RAWR",
      "BLARG",
      "ZZZ"
    ]
  }
}

live demo

If you are using a modern browser, you can go to http://lexical-scope.forbeslindesay.co.uk/ for a live demo.

methods

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.

scope.globals.implicitProperties contains the properties of global variable names that have been used. There are two special implicit property names:

  • "()" - when an implicit variable has been called
  • "*" - when an implicit variable has been used in a context that is not a property and not a call

install

With npm do:

npm install lexical-scope

license

MIT

Версии библиотеки

Версия
1.2.0
1.1.1