Skip to content
Open
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Prev Previous commit
Next Next commit
Function JSONbig.stringify() will only be called if bigNumberSupport …
…is active, otherwise JSON.stringify() will still be used to ensure the tool will work as before when keeping bigNumberSupport deactivated
  • Loading branch information
SebastianG committed Feb 9, 2019
commit 2703cef76682b6f96d8c4227462c46933523ef84
6 changes: 4 additions & 2 deletions lib/colorize.coffee
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,8 @@ subcolorizeToCallback = (key, diff, output, color, indent, options) ->
output(' ', subindent + '...')
else
unless op in [' ', '~', '+', '-']
throw new Error("Unexpected op '#{op}' in #{JSONbig.stringify(diff, null, 2)}")
stringifiedJSON = if options.bigNumberSupport then JSONbig.stringify(diff, null, 2) else JSON.stringify(diff, null, 2)
throw new Error("Unexpected op '#{op}' in #{stringifiedJSON}")
op = ' ' if op is '~'
subcolorizeToCallback('', subvalue, output, op, subindent, options)
else
Expand All @@ -53,7 +54,8 @@ subcolorizeToCallback = (key, diff, output, color, indent, options) ->

else
if diff == 0 or diff
output(color, indent + prefix + JSONbig.stringify(diff))
stringifiedJSON = if options.bigNumberSupport then JSONbig.stringify(diff, null, 2) else JSON.stringify(diff, null, 2)
output(color, indent + prefix + stringifiedJSON)



Expand Down