# code-context

> Parse a string of javascript to determine the context for functions, variables and comments based on the code that follows.

Latest version **0.5.3** (published 2015-08-01) · MIT license · 0 weekly downloads

## Install

```sh
npm install code-context
pnpm add code-context
yarn add code-context
bun add code-context
```

## Health

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

Positive: no vulnerabilities.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.5.3 |
| Published | 2015-08-01 |
| First published | 2014-08-09 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Node | >=0.10.0 |
| Dependencies | 1 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 9 |
| Author | Jon Schlinkert |
| Maintainers | jonschlinkert, doowb |
| Keywords | code, comment, context, declaration, docs, documentation, expression, extract, function, javascript, js, method, parse, property, prototype, statement |

## Links

- npm: https://www.npmjs.com/package/code-context
- Repository: https://github.com/jonschlinkert/code-context
- Issues: https://github.com/jonschlinkert/code-context/issues
- npm.io page: https://npm.io/package/code-context

## Dependencies (1)

- [parse-code-context](https://npm.io/package/parse-code-context.md) ^0.1.3

## Alternatives

- [@mapbox/jsonlint-lines-primitives](https://npm.io/package/@mapbox/jsonlint-lines-primitives.md) — 5.3M weekly downloads
- [reftools](https://npm.io/package/reftools.md) — 3.5M weekly downloads
- [@hey-api/openapi-ts](https://npm.io/package/@hey-api/openapi-ts.md) — 3.5M weekly downloads
- [@mapbox/geojson-rewind](https://npm.io/package/@mapbox/geojson-rewind.md) — 2.4M weekly downloads
- [turbo-stream](https://npm.io/package/turbo-stream.md) — 1.7M weekly downloads

## Recent versions

- 0.5.3 (latest) — 2015-08-01
- 0.5.2 — 2015-08-01
- 0.5.1 — 2015-05-25
- 0.5.0 — 2015-03-11
- 0.4.1 — 2015-02-13
- 0.4.0 — 2015-02-13
- 0.3.0 — 2014-11-19
- 0.2.3 — 2014-09-24
- 0.2.2 — 2014-09-24
- 0.2.1 — 2014-08-25
- 0.2.0 — 2014-08-25
- 0.1.1 — 2014-08-09
- 0.1.0 — 2014-08-09

## README

# code-context [![NPM version](https://badge.fury.io/js/code-context.svg)](http://badge.fury.io/js/code-context)  [![Build Status](https://travis-ci.org/jonschlinkert/code-context.svg)](https://travis-ci.org/jonschlinkert/code-context)

> Parse a string of javascript to determine the context for functions, variables and comments based on the code that follows.

**Currently supports:**

* code comments
* function statements
* function expressions
* prototype methods
* prototype properties
* methods
* properties
* declarations

## Install

Install with [npm](https://www.npmjs.com/)

```sh
$ npm i code-context --save
```

## Usage

```js
var parseContext = require('code-context');
```

Given the following code in `my-app.js`:

```js
/**
 * My app
 */
var app = function(str) {
  return str
};
```

Pass `my-app.js` as a string:

```js
var str = fs.readFileSync('my-app.js', 'utf8');
var context = parseContext(str);
```

Results in:

```js
[{
  type: 'comment',
  begin: 1,
  end: 3
},
{
  begin: 4,
  type: 'function',
  name: 'app',
  string: 'app()',
  original: 'var app = function(str) {'
}]
```

## Related projects

* [extract-comments](https://github.com/jonschlinkert/extract-comments): Extract code comments from string or from a glob of files.
* [parse-code-context](https://github.com/jonschlinkert/parse-code-context): Parse code context in a single line of javascript, for functions, variable declarations, methods, prototype… [more](https://github.com/jonschlinkert/parse-code-context)
* [parse-comments](https://github.com/jonschlinkert/parse-comments): Parse code comments from JavaScript or any language that uses the same format.

## Running tests

Install dev dependencies:

```sh
$ npm i -d && npm test
```

## Contributing

Pull requests and stars are always welcome. For bugs and feature requests, [please create an issue](https://github.com/jonschlinkert/code-context/issues/new)

## Authors

**Jon Schlinkert**

+ [github/jonschlinkert](https://github.com/jonschlinkert)
+ [twitter/jonschlinkert](http://twitter.com/jonschlinkert)

## License

Copyright © 2015 Jon Schlinkert
Released under the MIT license.

***

_This file was generated by [verb-cli](https://github.com/assemble/verb-cli) on August 01, 2015._

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