MCPcopy Create free account
hub / github.com/codecombat/codecombat / combineAncestralObject

Function combineAncestralObject

app/core/utils.js:79–95  ·  view source on GitHub ↗
(obj, propertyName)

Source from the content-addressed store, hash-verified

77}
78
79const combineAncestralObject = function (obj, propertyName) {
80 const combined = {}
81 while (obj != null ? obj[propertyName] : undefined) {
82 for (const key in obj[propertyName]) {
83 const value = obj[propertyName][key]
84 if (combined[key]) { continue }
85 combined[key] = value
86 }
87 if (obj.__proto__) {
88 obj = obj.__proto__
89 } else {
90 // IE has no __proto__. TODO: does this even work? At most it doesn't crash.
91 obj = Object.getPrototypeOf(obj)
92 }
93 }
94 return combined
95}
96
97// Walk a key chain down to the value. Can optionally set newValue instead.
98// Same as in world_utils, but don't want mutual imports

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected