MCPcopy
hub / github.com/phaserjs/phaser / GetValue

Function GetValue

src/utils/object/GetValue.js:43–110  ·  view source on GitHub ↗
(source, key, defaultValue, altSource)

Source from the content-addressed store, hash-verified

41 * @return {*} The value of the requested key.
42 */
43var GetValue = function (source, key, defaultValue, altSource)
44{
45 if ((!source && !altSource) || typeof source === 'number')
46 {
47 return defaultValue;
48 }
49 else if (source && source.hasOwnProperty(key))
50 {
51 return source[key];
52 }
53 else if (altSource && altSource.hasOwnProperty(key))
54 {
55 return altSource[key];
56 }
57 else if (key.indexOf('.') !== -1)
58 {
59 var keys = key.split('.');
60 var parentA = source;
61 var parentB = altSource;
62 var valueA = defaultValue;
63 var valueB = defaultValue;
64 var valueAFound = true;
65 var valueBFound = true;
66
67 // Use for loop here so we can break early
68 for (var i = 0; i < keys.length; i++)
69 {
70 if (parentA && parentA.hasOwnProperty(keys[i]))
71 {
72 // Yes parentA has a key property, let's carry on down
73 valueA = parentA[keys[i]];
74 parentA = parentA[keys[i]];
75 }
76 else
77 {
78 valueAFound = false;
79 }
80
81 if (parentB && parentB.hasOwnProperty(keys[i]))
82 {
83 // Yes parentB has a key property, let's carry on down
84 valueB = parentB[keys[i]];
85 parentB = parentB[keys[i]];
86 }
87 else
88 {
89 valueBFound = false;
90 }
91 }
92
93 if (valueAFound)
94 {
95 return valueA;
96 }
97 else if (valueBFound)
98 {
99 return valueB;
100 }

Callers 15

Settings.jsFile · 0.85
SceneManager.jsFile · 0.85
RangeFunction · 0.85
GetAdvancedValueFunction · 0.85
GetMinMaxValueFunction · 0.85
TweenBuilderFunction · 0.85
GetTargetsFunction · 0.85
StaggerBuilderFunction · 0.85
TweenChainBuilderFunction · 0.85
NumberTweenBuilderFunction · 0.85
Config.jsFile · 0.85
TimeStep.jsFile · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…