Z
Z
Zendor182020-12-30 10:28:49
JavaScript
Zendor18, 2020-12-30 10:28:49

How to keep the order of elements in an array in a snapshot?

The task is to fix the files on the ftp server and, accordingly. changes, emit the corresponding event (change/delete/rename, etc.).
Every few seconds I take a snapshot of the file structure on the ftp server. And then I compare the changes using this deep-diff lib . The problem is to keep the order of the original elements in the array. Otherwise, for example, when adding a new file, the order will change and the comparison of the two objects will be incorrect. So far, I see two possible solutions:
1# Store indexes and names somewhere and manually set files by indexes.
2# Take an object from the state, find the same name in the snapshot and compare each object like this.
Is there any better option?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
R
RidgeA, 2020-12-30
@Zendor18

can be sorted before reconciliation

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question