New Research: Supply Chain Attack on Axios Pulls Malicious Dependency from npm.Details →
Socket
Book a DemoSign in
Socket

node-peek

Package Overview
Dependencies
Maintainers
1
Versions
2
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

node-peek

REPL add-on for debugging and benchmarking Node applications.

latest
npmnpm
Version
0.1.1
Version published
Maintainers
1
Created
Source

node-peek

REPL add-on for debugging and benchmarking Node applications.

Build Status Coverage Status

Installation

npm install --save node-peek

Once installed, require node-peek on your main server file and run node {SERVER_FILE} --repl.

DISCLAIMER: node-peek creates a small Unix socket server on your running process to allow you to connect and debug live, as well as run and alter functions you choose to expose. Because this uses extra resources and could potentially be a security risk, all node-peek methods will default to noop and the socket server will not start without the --repl flag.

You can then use peek() to expose variables to the REPL if it's running.

Setup

const peek = require('node-peek');

/* Make variables accessible to REPL. */
peek('key', value);
peek({
  anotherKey: anotherValue
});

/* Console log to all REPLs */
peek.log(obj1, obj2);

/* Close REPL */
peek.close();

/* Change REPL prompt prefix. */
// Before: $ repl >
peek.setPrompt('my-own-repl');
// After: $ my-own-repl >

/* Define custom REPL commands, identical to built-in REPL API. */
peek.defineCommand('savestate', () => {
  fs.writeFile('/tmp/statefile.json', JSON.stringify(state), () => {
    this.outputStream.write('State saved!');
  });
});

Usage

$ ./node_modules/.bin/repl

Use like the normal Node REPL with additional helpers and custom commands.

$ repl > 2 + 2
$ 4
$
$ repl > .hdump
$ Heapdump written to /tmp/heap.1485844418719.heapsnapshot

Commands

  • .gc: Forces garbage collection.
  • .hdump: Forces a heapdump to the /tmp directory.
  • .hsize: Outputs the current heap stats in bytes.
  • .hcsv: Call once to begin reading intermittent benchmarking data into a CSV file, call again to stop.

Special Thanks to

FAQs

Package last updated on 03 Feb 2017

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