Skip to content

Instantly share code, notes, and snippets.

@eric
Created November 16, 2010 09:52
Show Gist options
  • Save eric/701638 to your computer and use it in GitHub Desktop.
Save eric/701638 to your computer and use it in GitHub Desktop.
window.printSource = (object, depth) ->
depth ?= 1
indent = new Array(depth + 1).join(' ')
entries = []
for all key, value of object
entries.push "\"#{key}\": #{value}"
if object.__proto__?
for all key, value of object.__proto__
entries.push "\"#{key}\": #{value}"
if entries.length > 0
"{\n#{indent}#{entries.join(",\n#{indent}")}\n}"
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment