Giter Club home page Giter Club logo

jsdifflist's People

Contributors

ethanrbrown avatar

Watchers

 avatar  avatar

jsdifflist's Issues

Add ability to descend into analogous objects/arrays

What I would like to see is something like this:
Input:

jsdifff({
  a: [ 1, 2, 3 ],
  b: { "cool, spaces": { x: 1, y: 3, z: 5 }, foo: 'bar' },
}, {
  a: [ 1, 3, 3 ],
  b: { "cool, spaces": { x: 1, z: 3 } },
}).toString();

Output:

Property                Equality   Object A       Object B
----------------------  ---------  -------------  ---------------
a                       unequal    Array          Array
a[0]                    equal      1              1
a[1]                    unequal    2              3
a[2]                    equal      3              3
b                       unequal    Object         Object
b["cool, spaces"]       unequal    Object         Object
b["cool, spaces"].x     equal      1              1
b["cool, spaces"].y     unequal    3              undefined
b["cool, spaces"].z     unequal    5              3

Possibly indent subproperties? Could get long/messy, but something like this:

Property                   Equality   Object A      Object B
-------------------------  ---------  ------------  ------------
a                          unequal    Array         Array
   a[0]                    equal      1             1
   a[1]                    unequal    2             3
   a[2]                    equal      3             3
b                          unequal    Object        Object
   b["cool, spaces"]       unequal    Object        Object
   b["cool, spaces"].x     equal      1             1
   b["cool, spaces"].y     unequal    3             undefined
   b["cool, spaces"].z     unequal    5             3

Less "noisy" colors

Green for strictly equal values seems sensible at first blush, but it calls unnecessary attention to the strictly equal values, which are usually the least interesting. Suggest making strictly equal values appear in normal text color.

Add option to only show differing value (perhaps by equality type?)

It is usually uninteresting to see values that are strictly equal, and sometimes to see values that are conceptually/loosely equal. Perhaps something like this:
Input:

jsdiff([1, 2, 3], [1, 3, "3"], { hide: 'strict' });

Output:

Property                Equality   Object A       Object B
----------------------  ---------  -------------  ---------------
1                       unequal    2              3
2                       loose      3              "3"

(1 strictly equal value(s) omitted)

Input:

jsdiff([1, 2, 3], [1, 3, "3"], { hide: 'strict, loose' });

Output:

Property                Equality   Object A       Object B
----------------------  ---------  -------------  ---------------
1                       unequal    2              3

(1 strictly and 1 loosely equal value(s) omitted)

Truncate/wrap long strings

Currently long strings aren't capped, and it screws up the table generation. For example:


Property        Equality  Object A                                                                                                                                                    Object B                                                                                                                                  
--------------  --------  --------------------------------------------------------
----------------------------------------------------------------------------------
----------------  ----------------------------------------------------------------
----------------------------------------------------------------------------------
--------
userId          strict    ""                                                                                                                                                          ""                                                                                                                                        
depth           strict    3                                                                                                                                                           3                                                                                                                                         
name            strict    "Lorem ipsum dolor sit amet, consectetur adipiscing 
elit. Curabitur ac eros tortor. Aliquam nec ornare sem. Aliquam quis vestibulum 
leo. Nulla sed sodales arcu, a rutrum eros. Sed ut leo risus. Nullam et tortor 
fringilla turpis facilisis condimentum. Nam eu est dui. Integer a molestie mauris. 
Sed quis arcu quam. Quisque ullamcorper, massa in dignissim commodo, massa ipsum 
semper lacus, ac commodo enim metus in nisi. Nunc hendrerit augue nunc, at 
iaculis elit ullamcorper eu."

Would be better if it were truncated or had reasonable line breaks (or an option for both?).

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.