@@ -4,11 +4,10 @@ const { diff } = require('just-diff')
4
4
5
5
const j = ( obj , replacer = null ) => JSON . stringify ( obj , replacer , 2 )
6
6
7
- const jsonDiff = ( s1 , s2 , DELETE ) => {
8
- // DELETE is a special string that will be the value of updated if it exists
9
- // but should be deleted
10
-
11
- const ops = diff ( s1 , s2 ) . map ( ( { op, path, value } ) => {
7
+ // DELETE is a special string that will be the value of updated if it exists
8
+ // but should be deleted
9
+ const jsonDiff = ( s1 , s2 , DELETE ) => diff ( s1 , s2 )
10
+ . map ( ( { op, path, value } ) => {
12
11
// there could be cases where a whole object is reported
13
12
// as missing and the expected value does not need to show
14
13
// special DELETED values so filter those out here
@@ -26,13 +25,9 @@ const jsonDiff = (s1, s2, DELETE) => {
26
25
} else if ( op === 'add' && value !== DELETE ) {
27
26
return AD
28
27
}
29
- } ) . filter ( Boolean ) . sort ( ( a , b ) => a . localeCompare ( b ) )
30
-
31
- if ( ! ops . length ) {
32
- return true
33
- }
34
-
35
- return ops . join ( '\n' )
36
- }
28
+ } )
29
+ . filter ( Boolean )
30
+ . sort ( ( a , b ) => a . localeCompare ( b ) )
31
+ . join ( '\n' )
37
32
38
33
module . exports = jsonDiff
0 commit comments