| 49 | * https://github.com/crubier/react-graph-vis/commit/68bf2e27b2046d6c0bb8b334c2cf974d23443264 |
| 50 | */ |
| 51 | const diff = (current, next, field = "id") => { |
| 52 | const nextIds = new Set(next.map((item) => item[field])); |
| 53 | const removed = current.filter((item) => !nextIds.has(item[field])); |
| 54 | const unchanged = intersectionWith(next, current, isEqual); |
| 55 | const updated = differenceWith( |
| 56 | intersectionWith(next, current, (a, b) => a[field] === b[field]), |
| 57 | unchanged, |
| 58 | isEqual |
| 59 | ); |
| 60 | const added = differenceWith( |
| 61 | differenceWith(next, current, isEqual), |
| 62 | updated, |
| 63 | isEqual |
| 64 | ); |
| 65 | return { |
| 66 | removed, |
| 67 | unchanged, |
| 68 | updated, |
| 69 | added, |
| 70 | }; |
| 71 | }; |
| 72 | const defaultOptions = { |
| 73 | physics: { |
| 74 | stabilization: false, |