zenpoint

Zenpoint, the debugging helper for zen fellas!

Usage no npm install needed!

<script type="module">
  import zenpoint from 'https://cdn.skypack.dev/zenpoint';
</script>

README

Zenpoint

An open window into your running nodejs code.

This module creates a very convenient REPL session served through the telnet protocol.

Usage example

Place a zenpoint in your code

function mycode(var1, var2, var3) {
    require('zenpoint')({
        listen: 1976,
        inspectDepth: 0,
        persist: false,
        context: {
            var1,
            var2,
            var3,
        },
    });

    // ... do some unrelated work here
    return 42;
}

mycode('zenpoint', 'the debugging helper', 'for zen fellas');

Telnet the Zenpoint server

$ telnet localhost 1976
Trying ::1...
Connected to localhost.
Escape character is '^]'.
πŸ€πŸ§˜πŸ Welcome to the Zenpoint πŸ₯‘πŸ¦πŸ¦
πŸ›πŸžπŸœπŸπŸ¦—βžž mycode (repl:2:17)
πŸ›πŸžπŸœπŸπŸ¦—βžž repl:1:1
πŸ›πŸžπŸœπŸπŸ¦—βžž ContextifyScript.Script.runInThisContext (vm.js:50:33)
πŸ›πŸžπŸœπŸπŸ¦—βžž REPLServer.defaultEval (repl.js:240:29)
πŸ›πŸžπŸœπŸπŸ¦—βžž bound (domain.js:301:14)
πŸ›πŸžπŸœπŸπŸ¦—βžž REPLServer.runBound [as eval] (domain.js:314:12)
πŸ›πŸžπŸœπŸπŸ¦—βžž REPLServer.onLine (repl.js:468:10)
πŸ›πŸžπŸœπŸπŸ¦—βžž emitOne (events.js:121:20)
┏━┫zenuser@zenhost:~/src/zenpoint#mycode@node-v8.11.2β”ƒπŸ™ˆπŸ™‰πŸ™Šβ”£β”
β”—>β”«this
{ console: [Getter],
  global: [Circular],
  process: [Object],
  Buffer: [Object],
  clearImmediate: [Function],
  clearInterval: [Function],
  clearTimeout: [Function],
  setImmediate: [Object],
  setInterval: [Function],
  setTimeout: [Object],
  module: [Object],
  require: [Object],
  mycode: [Function: mycode],
  d: [Function],
  inspectOptions: [Object],
  log: [Function],
  cr: [Function: cr],
  stack: 'πŸ›πŸžπŸœπŸπŸ¦—βžž mycode (repl:2:17)\r\nπŸ›πŸžπŸœπŸπŸ¦—βžž repl:1:1\r\nπŸ›πŸžπŸœπŸπŸ¦—βžž ContextifyScript.Script.runInThisContext (vm.js:50:33)\r\nπŸ›πŸžπŸœπŸπŸ¦—βžž REPLServer.defaultEval (repl.js:240:29)\r\nπŸ›πŸžπŸœπŸπŸ¦—βžž bound (domain.js:301:14)\r\nπŸ›πŸžπŸœπŸπŸ¦—βžž REPLServer.runBound [as eval] (domain.js:314:12)\r\nπŸ›πŸžπŸœπŸπŸ¦—βžž REPLServer.onLine (repl.js:468:10)\r\nπŸ›πŸžπŸœπŸπŸ¦—βžž emitOne (events.js:121:20)\r\nπŸ›πŸžπŸœπŸπŸ¦—βžž REPLServer.emit (events.js:211:7)',
  var1: 'zenpoint',
  var2: 'the debugging helper',
  var3: 'for zen fellas',
  frozen: [Object] }
┏━┫zenuser@zenhost:~/src/zenpoint#mycode@node-v8.11.2β”ƒπŸ™ˆπŸ™‰πŸ™Šβ”£β”
β”—>β”«

What's in the session

console.log() -> log()

console.log cannot be used because its output goes right to the process' stdout. Instead use the log() function

log('this is this', this);

inspect depth

The depth of the inspection usd by log() can be tuned with the d() function

d(4);

context, frozen and current

The state of the context is frozen at the initialization of the server and can be accessed through the frozen object.

log('frozen state', frozen);
log('current state', {var1, var2, var3});