# scoped

> command line tool exposing lexical-scope

Latest version **3.0.2** (published 2015-03-23) · MIT license · 0 weekly downloads

## Install

```sh
npm install scoped
pnpm add scoped
yarn add scoped
bun add scoped
```

Provides the command `scoped`.

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 3.0.2 |
| Published | 2015-03-23 |
| First published | 2013-05-25 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 6 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 6 |
| Author | Chris Dickinson |
| Maintainers | chrisdickinson |
| Keywords | detect, scopes |

## Links

- npm: https://www.npmjs.com/package/scoped
- Repository: https://github.com/chrisdickinson/scoped
- Issues: https://github.com/chrisdickinson/scoped/issues
- npm.io page: https://npm.io/package/scoped

## Dependencies (6)

- [falafel](https://npm.io/package/falafel.md) ^1.0.1
- [process](https://npm.io/package/process.md) ~0.5.1
- [optimist](https://npm.io/package/optimist.md) ~0.3.5
- [ansicolors](https://npm.io/package/ansicolors.md) ~0.2.1
- [concat-stream](https://npm.io/package/concat-stream.md) ~1.0.0
- [cssauron-falafel](https://npm.io/package/cssauron-falafel.md) 1.2.1

## Recent versions

- 3.0.2 (latest) — 2015-03-23
- 3.0.1 — 2015-03-23
- 3.0.0 — 2015-03-23
- 2.1.2 — 2014-03-28
- 2.1.1 — 2014-03-28
- 2.1.0 — 2013-12-19
- 2.0.0 — 2013-12-18
- 1.2.0 — 2013-12-17
- 1.1.2 — 2013-07-26
- 1.1.1 — 2013-07-26
- 1.1.0 — 2013-07-26
- 1.0.0 — 2013-07-25
- 0.0.4 — 2013-07-15
- 0.0.3 — 2013-05-26
- 0.0.2 — 2013-05-25
- … 1 more at https://npm.io/package/scoped/versions

## README

# scoped

scoped is a command line tool to help you reason about your javascript.

scoped is also a library that will give you all of the scope information about
a given `falafel`-generated AST! (it even works with `let`!)

```javascript
var scoped = require('scoped')
  , falafel = require('falafel')

falafel('<some javascript>', scoped(function(scope) {
    scope.vars                          // vars declared in this scope
    scope.vars[0].name                  // the name of the var
    scope.vars[0].nodes                 // a list of nodes + kinds of use
    scope.vars[0].nodes[0].kind         // "implicit", "explicit", or "declare"
    scope.vars[0].nodes[0].node         // the esprima AST node.

    scope.children                      // the list of child scopes of this node
    scope.children[0]                   // as an array.

    scope.uses                          // the list of variables that this scope
                                        // "uses" from parent scopes. at top level,
                                        // these are globals.
}))

// you can also tell scoped to ignore certain globals:
falafel('<some javascript>', scoped(['Math', 'module'], function(scope) {

}))

```

it notifies you of globals -- both explicit (created by assigning) and implicit
(use without definition) -- and, when given a position in the file, will let you know
what variables are in scope at that point.

![example scoped output](http://cl.ly/image/0G2M2R0Z093N/scoped.png)

# usage

### scoped path/to/file.js

outputs only global usage/leakage information, with line and column numbers.

### scoped path/to/file.js --position=line[,column]

outputs scope chain, with usage/definition for each scope. `position` is
in the form `LINE,COLUMN`. `,COLUMN` may be omitted, if so, it is assumed
to be `1`. Both `line` and `column` are assumed to be 1-indexed (like most
editors).

* Green `+` signs indicate scope definitions -- i.e., a new variable was created
  in this scope.

* Purple `*` signs indicate use of a variable from a containing scope.

* If the function is named, it will use that to describe the function.

# installation

`npm install -g scoped`

# license

MIT

---
_Source: https://npm.io/package/scoped · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
