Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

v8-debug

Package Overview
Dependencies
Maintainers
2
Versions
36
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

v8-debug

v8 debugger extending API

  • 0.7.6
  • Source
  • npm
  • Socket score

Version published
Weekly downloads
773
decreased by-2.52%
Maintainers
2
Weekly downloads
 
Created
Source

Build Status Build status npm version

v8-debug

Provides extending API for node internal debugger protocol (based on v8 debugger protocol)

This is a part of 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.

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:

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.

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

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.

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.

var MakeMirror = debug.get('MakeMirror');
var mirror = MakeMirror({ test: 1 });

getFromFrame(index, value)

Tries to receive a value from targeted frame scopes

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

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

Keywords

FAQs

Package last updated on 08 May 2016

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc