Skip to content

Instantly share code, notes, and snippets.

@yamaya
Created April 19, 2012 15:27
Show Gist options
  • Save yamaya/2421687 to your computer and use it in GitHub Desktop.
Save yamaya/2421687 to your computer and use it in GitHub Desktop.
"p" function likes ruby
p = (thing)->
stringnize = (obj)->
switch typeof_(obj)
when 'Null'
return 'nil'
when 'Object'
return "{#{(":#{k} => #{stringnize(v)}" for k, v of obj).join(', ')}}"
when 'Array'
return "[#{(stringnize(e) for e in obj).join(', ')}]"
else
return "#{obj}"
console.log(stringnize(thing))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment