forked from phaserjs/phaser
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathGetFastValue.js
More file actions
41 lines (37 loc) · 1015 Bytes
/
Copy pathGetFastValue.js
File metadata and controls
41 lines (37 loc) · 1015 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
/**
* @author Richard Davey <rich@photonstorm.com>
* @copyright 2018 Photon Storm Ltd.
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
// Source object
// The key as a string, can only be 1 level deep (no periods), must exist at the top level of the source object
// The default value to use if the key doesn't exist
/**
* [description]
*
* @function Phaser.Utils.Object.GetFastValue
* @since 3.0.0
*
* @param {object} source - [description]
* @param {string} key - [description]
* @param {*} [defaultValue] - [description]
*
* @return {*} [description]
*/
var GetFastValue = function (source, key, defaultValue)
{
var t = typeof(source);
if (!source || t === 'number' || t === 'string')
{
return defaultValue;
}
else if (source.hasOwnProperty(key) && source[key] !== undefined)
{
return source[key];
}
else
{
return defaultValue;
}
};
module.exports = GetFastValue;