# vdebugger

> A Front-End JavaScript Debugger

Latest version **0.1.19** (published 2024-02-20) · MIT license · 0 weekly downloads

## Install

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

## Health

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

Positive: has types; no vulnerabilities; high quality score.

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

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 0.1.19 |
| Published | 2024-02-20 |
| First published | 2022-09-13 |
| Weekly downloads | 0 |
| License | MIT |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 428 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| GitHub stars | 23 |
| Author | siubaak |
| Maintainers | siubaak |
| Keywords | vdebugger, debugger, debug, js, javascript, break, breakpoint |

## Links

- npm: https://www.npmjs.com/package/vdebugger
- Repository: https://github.com/wechatjs/vdebugger
- Homepage: https://github.com/wechatjs/vdebugger#readme
- Issues: https://github.com/wechatjs/vdebugger/issues
- npm.io page: https://npm.io/package/vdebugger

## Dependencies (3)

- [astring](https://npm.io/package/astring.md) ^1.8.6
- [meriyah](https://npm.io/package/meriyah.md) ^4.3.9
- [acorn-walk](https://npm.io/package/acorn-walk.md) ^8.3.2

## 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.1.19 (latest) — 2024-02-20
- 0.1.18 — 2024-02-20
- 0.1.17 — 2024-02-19
- 0.1.16 — 2024-02-19
- 0.1.15 — 2024-02-18
- 0.1.14 — 2023-10-19
- 0.1.13 — 2023-01-04
- 0.1.12 — 2023-01-03
- 0.1.11 — 2023-01-03
- 0.1.10 — 2022-12-26
- 0.1.9 — 2022-12-26
- 0.1.8 — 2022-12-26
- 0.1.7 — 2022-12-23
- 0.1.6 — 2022-12-15
- 0.1.5 — 2022-12-15
- … 5 more at https://npm.io/package/vdebugger/versions

## README

# vDebugger &middot; [![npm](https://img.shields.io/npm/v/vdebugger.svg?style=flat-square)](https://www.npmjs.com/package/vdebugger) [![github-actions](https://img.shields.io/github/actions/workflow/status/wechatjs/vdebugger/coverage.yml?style=flat-square)](https://github.com/wechatjs/vdebugger/actions/workflows/coverage.yml) [![coveralls](https://img.shields.io/coveralls/github/wechatjs/vdebugger.svg?style=flat-square)](https://coveralls.io/github/wechatjs/vdebugger)

**English | [简体中文](./README_CN.md)**

A Front-End JavaScript Breakpoint Debugger.

Make it possible to debug your JavaScript in browser, Node.js, JavaScriptCore or other JavaScript runtimes without any extra supports from host environments. [Try `vDebugger` on playground.](https://jsbin.com/jibezuvohe/edit?js,console)

## Installation

`vDebugger` requires ES2015 for [`Generator`](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Generator) support.

Install by NPM:

```bash
$ npm install vdebugger
```

```js
import vDebugger from 'vdebugger';
```

Or, import from CDN:

```html
<script src="https://unpkg.com/vdebugger@latest/dist/vdebugger.js"></script>
<!-- vDebugger will mount at global like window.vDebugger by default -->
```

## Getting Started

```js
import vDebugger from 'vdebugger';

const run = vDebugger.debug(`// here's line 1
let a = 1;
a = 2; // break at line 3 later
a = 3;
a = 4;
console.log(a); // output "4"
`, './test.js');
// the second argument is debuggerId for identifing the script,
// which normally is the script url

vDebugger.setBreakpoint('./test.js', 3); // break at line 3

run();

vDebugger.evaluate('console.log(a)'); // output "1"

vDebugger.resume('stepOver');

vDebugger.evaluate('console.log(a)'); // output "2"

vDebugger.resume(); // output "4"
```

## Pre-Transform

`vDebugger` needs code transform for break, while transforming at runtime by default causes performance loss, and therefore, `vDebugger` provides a method called `transform` for code pre-transform at compilation.

```js
/* ----- Compilation ----- */

// pre-transform at compilation, and pass the result to vDebugger.debug at runtime
import vDebugger from 'vdebugger';

const result = vDebugger.transform(`// here's line 1
let a = 1;
a = 2; // break at line 3 later
a = 3;
a = 4;
console.log(a); // output "4"
`, './test.js');
// the second argument is debuggerId for identifing the script,
// which normally is the script url
```

Pass the transformed `result` to `vDebugger.debug` at runtime.

```js
/* ----- Runtime ----- */

// except for passing the transformed result to vDebugger.debug,
// runtime debugging has no difference from which without pre-transform
import vDebugger from 'vdebugger';

const run = vDebugger.debug(result);
// the result contains debuggerId, so the second argument is optional

vDebugger.setBreakpoint('./test.js', 3); // break at line 3

run();

vDebugger.evaluate('console.log(a)'); // output "1"

vDebugger.resume('stepOver');

vDebugger.evaluate('console.log(a)'); // output "2"

vDebugger.resume(); // output "4"
```

## Development

```bash
$ npm start
```

## Testing

```bash
$ npm test
```

## Documentation

- [API Documentation](./docs/API.md)

## License

[MIT](./LICENSE)

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