Skip to content

Instantly share code, notes, and snippets.

@gdoteof
Created August 30, 2017 20:01
Show Gist options
  • Save gdoteof/961898819e85af82e92896d8ce327c6e to your computer and use it in GitHub Desktop.
Save gdoteof/961898819e85af82e92896d8ce327c6e to your computer and use it in GitHub Desktop.
viewing large javascript objects
var fs = require('fs');
var exec = require('child_process').exec;
function inspect(object, filename) {
var html = "<script>var j = " + JSON.stringify(object) + "; console.log(j);</script> open console";
var tmpFile = (filename) ? filename : "/tmp/inspect.html";
fs.writeFileSync(tmpFile, html)
exec("open " + tmpFile);
}
module.exports = inspect;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment