Skip to content

Instantly share code, notes, and snippets.

@dbainbridge
Created April 3, 2012 00:48
Show Gist options
  • Star 3 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dbainbridge/2288365 to your computer and use it in GitHub Desktop.
Save dbainbridge/2288365 to your computer and use it in GitHub Desktop.
node-inspector full string output fix
// Replace refToObject in node-inspector's lib/sessions.js file to get rid of the 80 character limit on strings outputted from the console or tool tip.
// The Scope Variables panel will still show maximum of 80 characters along with the "(length: x)" suffix
function refToObject(ref) {
var desc = '',
name,
kids = ref.properties ? ref.properties.length : false;
switch (ref.type) {
case 'object':
name = /#<an?\s(\w+)>/.exec(ref.text);
if (name && name.length > 1) {
desc = name[1];
if (desc === 'Array') {
desc += '[' + (ref.properties.length - 1) + ']';
}
else if (desc === 'Buffer') {
desc += '[' + (ref.properties.length - 4) + ']';
}
}
else {
desc = ref.className || 'Object';
}
break;
case 'function':
desc = ref.text || 'function()';
break;
case 'string': // Add special case for string
desc = ref.value || ''; // use 'value' instead of 'text' which is not truncated and is also part of the payload
break;
default:
desc = ref.text || '';
break;
}
if (desc.length > 1000) { // increased length from 100 to show longer strings mainly
desc = desc.substring(0, 1000) + '\u2026';
}
return wrapperObject(ref.type, desc, kids, 0, 0, ref.handle);
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment