-
Notifications
You must be signed in to change notification settings - Fork 39
Open
Description
the havePathInCommon function of chapter 5 uses lodash intersection which will always return false.
data-oriented-programming/src/chapter05/paths-in-common.js
Lines 1 to 4 in 07bf95b
| function havePathInCommon(diff1, diff2) { | |
| return !_.isEmpty(_.intersection(informationPaths(diff1), | |
| informationPaths(diff2))); | |
| } |
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.
Metadata
Metadata
Assignees
Labels
No labels