fru9ia
Last Updated: February 25, 2016
·
366
· blainesch

PRY.js - Easy server side debugging.

*Download on Github*

Similar to the ruby library, this javascript prototype mimics a few of the necessary debugging tools that Pry provides.

Throw a snippet into your code and node will halt your current thread and allow you to view variables, objects, and functions. It will also let you modify and create new things on the fly.

pry = require('pryjs');

function fizzBuzz() {
  var i, output;
  for (i = 1; i < 101; i++) {
    output = '';
    pry(function(p) { return eval(p); });
    if (!(i % 3)) output += 'Fizz';
    if (!(i % 5)) output += 'Buzz';
    console.log(output || i);
  }
};

fizzBuzz();

This simple example allows you to jump right into the middle of a loop inside a simple Fizz Buzz code snippet to help you debug it when something goes wrong.

*Download on Github*

Example