| Server IP : 68.183.124.220 / Your IP : 216.73.217.137 Web Server : Apache/2.4.18 (Ubuntu) System : Linux Sandbox-A 4.4.0-210-generic #242-Ubuntu SMP Fri Apr 16 09:57:56 UTC 2021 x86_64 User : gavin ( 1000) PHP Version : 7.0.33-0ubuntu0.16.04.16 Disable Function : pcntl_alarm,pcntl_fork,pcntl_waitpid,pcntl_wait,pcntl_wifexited,pcntl_wifstopped,pcntl_wifsignaled,pcntl_wifcontinued,pcntl_wexitstatus,pcntl_wtermsig,pcntl_wstopsig,pcntl_signal,pcntl_signal_dispatch,pcntl_get_last_error,pcntl_strerror,pcntl_sigprocmask,pcntl_sigwaitinfo,pcntl_sigtimedwait,pcntl_exec,pcntl_getpriority,pcntl_setpriority, MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : ON | Sudo : ON | Pkexec : ON Directory : /home/gavin/workspace/happymandarin/node_modules/v8-debug/ |
Upload File : |
[](https://travis-ci.org/node-inspector/v8-debug)
[](https://ci.appveyor.com/project/3y3/v8-debug-145/branch/master)
[](http://badge.fury.io/js/v8-debug)
# v8-debug
Provides extending API for [node](http://github.com/ry/node) internal debugger protocol (based on [v8 debugger protocol](https://code.google.com/p/v8/wiki/DebuggerProtocol))
This is a part of [node-inspector](http://github.com/node-inspector/node-inspector).
## Installation
```
npm install v8-debug
```
## API
### registerCommand(name, callback)
Registers new debug processor command, like `lookup`.
`callback` accepts two arguments - **request** and **response**.
You need to modify `response.body` if you want to return something to caller.
```js
debug.registerCommand('_lookup', function(request, response) {
var test = request.attributes;
//do someting here
//and modify response
response.body = {
test: test
};
});
```
### registerEvent(eventName)
This is a shortcut for:
```js
debug.registerCommand('someEvent', debug.commandToEvent);
```
### execCommand(commandName, attributes)
Calls debug processor command like 'lookup'.
`attributes` will be passed to `registerCommand.callback` as `request.attributes`.
`attributes` needs to be valid JSON object.
```js
debug.registerCommand('_lookup', function(request, response) {
var test = request.attributes;
//do someting here
//and modify response
response.body = {
test: test
};
});
debug.execCommand('_lookup', { attr: 'test' });
```
### emitEvent(eventName, attributes)
This is a semantic alias for `execCommand`
```js
debug.emitEvent('myEvent', { attr: 'test' });
```
### commandToEvent(request, response)
`response` object has a different structure for commands and events.
By default `registerCommand.callback` receives command's response.
This is a small converter.
```js
debug.registerCommand('someEvent1', function(request, response) {
debug.commandToEvent(request, response);
});
debug.registerCommand('someEvent2', debug.commandToEvent);
```
Use `debug.registerEvent` instead of this.
### runInDebugContext(script)
(alias `get`)
Evaluates string or function (will be stringifyed) in debug context.
```js
var MakeMirror = debug.get('MakeMirror');
var mirror = MakeMirror({ test: 1 });
```
### getFromFrame(index, value)
Tries to receive a `value` from targeted frame scopes
```js
function a(options) {
//...
b();
}
function b() {
// There is no info about `options` object
var options = debug.getFromFrame(1, 'options');
}
```
### enableWebkitProtocol()
Enables experimental usage of WebKit protocol
### registerAgentCommand(command, parameters, callback)
Experimental method for registering WebKit protocol handlers
## Usage
Simple console.log checking
```js
var debug = require('v8-debug');
debug.registerEvent('console.log');
console.log = (function(fn) {
return function() {
debug.emitEvent('console.log', {message: arguments[0]} /*, userdata*/);
return fn.apply(console, arguments);
}
} (console.log));
```
For more experience see [protocol documentation](https://github.com/buggerjs/bugger-v8-client/blob/master/PROTOCOL.md)