Created
April 28, 2015 17:14
-
-
Save pelonpelon/6457214290984428a3fc to your computer and use it in GitHub Desktop.
stringify.js - view objects as strings in the console
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
export default ( object, jsonIndent = 2 ) => | |
JSON.stringify( | |
object, ( key, value ) => | |
value instanceof Function | |
? value.toString() | |
: value, | |
jsonIndent | |
) | |
.replace( /\\n/g, '\n' ) | |
.replace( /\\r/g, '\r' ) | |
.replace( /\\t/g, '\t' ) | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment