<commit_before>Escope ([escope](http://github.com/estools/escope)) is
[ECMAScript](http://www.ecma-international.org/publications/standards/Ecma-262.htm)
scope analyzer extracted from [esmangle project](http://github.com/estools/esmangle).

[![Build Status](https://travis-ci.org/estools/escope.png?branch=master)](https://travis-ci.org/estools/escope)

### Example

    var escope = require('escope');
    var esprima = require('esprima');
    var estraverse = require('estraverse');
    
    var ast = esprima.parse(code);
    var scopeManager = escope.analyze(ast);
    
    var currentScope = scopeManager.acquire(ast);   // global scope

    estraverse.traverse(ast, {
        enter: function(node, parent) {
            if (/Function/.test(node.type)) {
                currentScope = scopeManager.acquire(node);  // get current function scope
            }
            
            // do stuff
        },
        leave: function(node, parent) {
            // do stuff
            
            if (/Function/.test(node.type)) {
                currentScope = currentScope.upper;  // set to parent scope
            }
        }
    });

### Document

Generated JSDoc is [here](http://estools.github.io/escope/).

### Demos and Tools

Demonstration is [here](http://mazurov.github.io/escope-demo/) by [<NAME>](https://github.com/mazurov) (twitter: [@mazurov](http://twitter.com/mazurov)). [issue](https://github.com/estools/escope/issues/14)<commit_msg>fixed the example so that currentScope is changed so that the current node isn't included in the currentScope when doing stuff<commit_after>Escope ([escope](http://github.com/estools/escope)) is
[ECMAScript](http://www.ecma-international.org/publications/standards/Ecma-262.htm)
scope analyzer extracted from [esmangle project](http://github.com/estools/esmangle).

[![Build Status](https://travis-ci.org/estools/escope.png?branch=master)](https://travis-ci.org/estools/escope)

### Example

    var escope = require('escope');
    var esprima = require('esprima');
    var estraverse = require('estraverse');
    
    var ast = esprima.parse(code);
    var scopeManager = escope.analyze(ast);
    
    var currentScope = scopeManager.acquire(ast);   // global scope

    estraverse.traverse(ast, {
        enter: function(node, parent) {
            // do stuff
            
            if (/Function/.test(node.type)) {
                currentScope = scopeManager.acquire(node);  // get current function scope
            }
        },
        leave: function(node, parent) {
            if (/Function/.test(node.type)) {
                currentScope = currentScope.upper;  // set to parent scope
            }
            
            // do stuff
        }
    });

### Document

Generated JSDoc is [here](http://estools.github.io/escope/).

### Demos and Tools

Demonstration is [here](http://mazurov.github.io/escope-demo/) by [<NAME>](https://github.com/mazurov) (twitter: [@mazurov](http://twitter.com/mazurov)). [issue](https://github.com/estools/escope/issues/14)
{'fraction_non_alphanumeric': 0.1508748761967646, 'fraction_numerical': 0.003301419610432486, 'mean_word_length': 2.6462093862815883, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 8, 'lorem ipsum': 0, 'www.': 2, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5667657', 'n_tokens_mistral': 955, 'n_tokens_neox': 932, 'n_words': 171}