(source, key, defaultValue)
| 50 | * @return {*} The value of the requested key. |
| 51 | */ |
| 52 | var GetAdvancedValue = function (source, key, defaultValue) |
| 53 | { |
| 54 | var value = GetValue(source, key, null); |
| 55 | |
| 56 | if (value === null) |
| 57 | { |
| 58 | return defaultValue; |
| 59 | } |
| 60 | else if (Array.isArray(value)) |
| 61 | { |
| 62 | return MATH.RND.pick(value); |
| 63 | } |
| 64 | else if (typeof value === 'object') |
| 65 | { |
| 66 | if (value.hasOwnProperty('randInt')) |
| 67 | { |
| 68 | return MATH.RND.integerInRange(value.randInt[0], value.randInt[1]); |
| 69 | } |
| 70 | else if (value.hasOwnProperty('randFloat')) |
| 71 | { |
| 72 | return MATH.RND.realInRange(value.randFloat[0], value.randFloat[1]); |
| 73 | } |
| 74 | } |
| 75 | else if (typeof value === 'function') |
| 76 | { |
| 77 | return value(key); |
| 78 | } |
| 79 | |
| 80 | return value; |
| 81 | }; |
| 82 | |
| 83 | module.exports = GetAdvancedValue; |
no test coverage detected
searching dependent graphs…