Guest User

Untitled

a guest
Feb 20th, 2018
59
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.78 KB | None | 0 0
  1. function pp(object){
  2. switch ($type(object)){
  3. case 'object':
  4. object = $H(object);
  5.  
  6. var h = '{ ';
  7. object.each(function(value, key){
  8. h += '{key}: {value}, '.substitute({key:key, value: pp(value) })
  9. })
  10. h += ' }'
  11. // var h = '<table>';
  12. // object.each(function(value, key){
  13. // h += '<tr><th> {key} </th><td> {value} </td></tr>'.substitute({key:key, value: pp(value) })
  14. // })
  15. // h += '</table>'
  16. return h
  17.  
  18. break;
  19. case 'array':
  20. object = $A(object);
  21.  
  22. var h = '[';
  23. object.each(function(value, key){
  24. h += '{value}, '.substitute({value: pp(value) })
  25. })
  26. h += ']';
  27. return h
  28.  
  29. break;
  30. case false: return 'false'; break;
  31. case 'string':
  32. case 'number':
  33. case 'boolean':
  34. case 'date':
  35. default: return object.toString();
  36. }
  37.  
  38. };
Add Comment
Please, Sign In to add comment