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
add special comparison for BigNumber values
  • Loading branch information
SebastianG committed Feb 9, 2019
commit 1f4461d3af9a5c043dad597a3e4f0b86c4ae4050
9 changes: 8 additions & 1 deletion lib/index.coffee
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
BigNumber = require 'bignumber.js'

{ SequenceMatcher } = require 'difflib'
{ extendedTypeOf } = require './util'
{ colorize } = require './colorize'
Expand Down Expand Up @@ -157,7 +159,12 @@ diffWithScore = (obj1, obj2, options = {}) ->
return arrayDiff(obj1, obj2, options)

if !options.keysOnly
if obj1 != obj2
if options.bigNumberSupport and BigNumber.isBigNumber(obj1) and BigNumber.isBigNumber(obj2)
if !obj1.isEqualTo(obj2)
[0, { __old: obj1, __new: obj2 }]
else
[100, undefined]
else if obj1 != obj2
[0, { __old: obj1, __new: obj2 }]
else
[100, undefined]
Expand Down