Skip to content

Instantly share code, notes, and snippets.

@subtleGradient
Created October 16, 2008 01:34
Show Gist options
  • Select an option

  • Save subtleGradient/17051 to your computer and use it in GitHub Desktop.

Select an option

Save subtleGradient/17051 to your computer and use it in GitHub Desktop.
function pp(object){
switch ($type(object)){
case 'object':
object = $H(object);
var h = '{ ';
object.each(function(value, key){
h += '{key}: {value}, '.substitute({key:key, value: pp(value) })
})
h += ' }'
// var h = '<table>';
// object.each(function(value, key){
// h += '<tr><th> {key} </th><td> {value} </td></tr>'.substitute({key:key, value: pp(value) })
// })
// h += '</table>'
return h
break;
case 'array':
object = $A(object);
var h = '[';
object.each(function(value, key){
h += '{value}, '.substitute({value: pp(value) })
})
h += ']';
return h
break;
case false: return 'false'; break;
case 'string':
case 'number':
case 'boolean':
case 'date':
default: return object.toString();
}
};
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment