Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Could support object array item move? #33

Open
bakso opened this issue Nov 21, 2023 · 4 comments
Open

Could support object array item move? #33

bakso opened this issue Nov 21, 2023 · 4 comments

Comments

@bakso
Copy link

bakso commented Nov 21, 2023

Every item has an uuid, like

[{ id: 1 }, { id: 2 }, { id: 3 } ]

if move item idx.3 to idx.2 ,then looks like:

[{ id: 1 }, { id: 3 }, { id: 2 } ]

diff should produce

[ [ 1, { p: 0 } ], [ 2, { d: 0 } ] ]

and:

{ 
  a: [{ id: 1 }, { id: 2 }, { id: 3 }],
  b: [{ id: 4 }]
}

move a.idx2 to b, just like:

{
  a: [{ id: 1 }, { id: 3 }],
  b: [{ id: 2 }, { id: 4 }]
}

diff should produce

[ [ 'a', 1, { p: 0 } ], [ 'b', 0, { d: 0 } ] ]
@curran
Copy link
Collaborator

curran commented Nov 21, 2023

Awesome! Would you be able to add a failing unit test? That would help immensely in implementing this.

@bakso
Copy link
Author

bakso commented Nov 22, 2023

Awesome! Would you be able to add a failing unit test? That would help immensely in implementing this.

I think first diff api should support a parameters to specifiy which key is uuid, am i right?

@bakso
Copy link
Author

bakso commented Nov 23, 2023

just like https://github.com/benjamine/jsondiffpatch which support objectHash function parameter

@curran
Copy link
Collaborator

curran commented Nov 25, 2023

I suppose that API definition could come from the unit test. I like test-driven development, where first we show what we want to invocation to look like, then build support for that test.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants