Skip to content

Commit f7097d5

Browse files
committed
Added GetFastValue for when no config key nesting is ever required.
1 parent 5cef085 commit f7097d5

2 files changed

Lines changed: 22 additions & 0 deletions

File tree

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
// Source object
2+
// The key as a string, can only be 1 level deep (no periods), must exist at the top level of the source object
3+
// The default value to use if the key doesn't exist
4+
5+
var GetFastValue = function (source, key, defaultValue)
6+
{
7+
if (!source || typeof source === 'number')
8+
{
9+
return defaultValue;
10+
}
11+
else if (source.hasOwnProperty(key))
12+
{
13+
return source[key];
14+
}
15+
else
16+
{
17+
return defaultValue;
18+
}
19+
};
20+
21+
module.exports = GetFastValue;

v3/src/utils/object/index.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -5,6 +5,7 @@ module.exports = {
55
Clone: require('./Clone'),
66
Extend: require('./Extend'),
77
GetAdvancedValue: require('./GetAdvancedValue'),
8+
GetFastValue: require('./GetFastValue'),
89
GetMinMaxValue: require('./GetMinMaxValue'),
910
GetValue: require('./GetValue'),
1011
IsPlainObject: require('./IsPlainObject'),

0 commit comments

Comments
 (0)