1 |
|
2 |
|
3 |
|
4 |
|
5 |
|
6 | module.exports = modifyObjectInPlace = (oldObject, newObject, cachedObject) ->
|
7 |
|
8 | for key in Object.keys(oldObject) when key[0] isnt '$'
|
9 | localChange = cachedObject and not cachedObject[key]?
|
10 | delete oldObject[key] unless newObject[key]? or localChange
|
11 |
|
12 | for key in Object.keys(newObject) when key[0] isnt '$'
|
13 | if angular.isObject(oldObject[key]) and angular.isObject(newObject[key])
|
14 | modifyObjectInPlace(oldObject[key], newObject[key], cachedObject?[key])
|
15 | else
|
16 | localChanges = cachedObject and not angular.equals(oldObject[key], cachedObject[key])
|
17 | unless angular.equals(oldObject[key], newObject[key]) or localChanges
|
18 | oldObject[key] = newObject[key]
|
19 |
|
20 | oldObject.length = newObject.length if newObject.length?
|
21 |
|