data-oriented-programming
data-oriented-programming copied to clipboard
havePathsInCommon will always return false for nested objects
the havePathInCommon function of chapter 5 uses lodash intersection which will always return false.
https://github.com/viebel/data-oriented-programming/blob/07bf95b4f4bedeb5cd9cdaa04e59b96efdf2727b/src/chapter05/paths-in-common.js#L1-L4
havePathInCommon uses informationPaths which returns an array of the paths, where each path is an array with keys as values of the array.
A return value example of informationPaths would be:
[
['library', 'catalog', 'authorsById', '1', 'name'] ,
['library', 'userManagement', 'userssById', '1', 'name']
]
but lodash's intersection will not deeply check this nested array, so if the above path was compared with
[
['library', 'catalog', 'authorsById', '1', 'name'] ,
]
It will return false because arrays are reference type.