# instrumentjs

> Add coverage instrumentation to JavaScript code

Latest version **0.0.3** (published 2015-05-02) · MIT license · 0 weekly downloads

## Install

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

## 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.0.3 |
| Published | 2015-05-02 |
| First published | 2015-05-02 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 0 |
| Author | Dylan Barrell |
| Maintainers | dylanb |
| Keywords | Coverage, Instrumentation, Instrument |

## Links

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

## Recent versions

- 0.0.3 (latest) — 2015-05-02
- 0.0.2 — 2015-05-02
- 0.0.1 — 2015-05-02

## README

# InstrumentJS

## Install

```
npm install instrumentjs
```

## Usage

```
var instrument = require('instrumentjs');
var javascriptSrc = 'your source code here';

var instrumentedSrc = instrument(javascriptSrc);
```

The return value from a call to the instrument function is the following structure:

```
{
	names: : {
		statement: String,
		expression: String,
		block: String,
		intro: String,
		extro: String
	},
	nodes: {
		'0': NodeInfo
		... (repeated for as many source code nodes as exist)
	},
	blockCounter: Integer,
	nodeCounter: Integer,
	source: String,
	instrumentedSource: String
}
```

Where the values of the items in the `names` structure are the function calls that will be called each time a statement, expression or block is executed and where intro and extro are the calls made wach time a function is entered or exited respectively.

You can use these values to create functions that will capture the instrumentation data as the instrumented javascript is executed.

For an example of how this is used, see the [gulp coverage](https://github.com/dylanb/gulp-coverage) module.

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