()
| 29 | * @return {object} The extended object. |
| 30 | */ |
| 31 | var Extend = function () |
| 32 | { |
| 33 | var options, name, src, copy, copyIsArray, clone, |
| 34 | target = arguments[0] || {}, |
| 35 | i = 1, |
| 36 | length = arguments.length, |
| 37 | deep = false; |
| 38 | |
| 39 | // Handle a deep copy situation |
| 40 | if (typeof target === 'boolean') |
| 41 | { |
| 42 | deep = target; |
| 43 | target = arguments[1] || {}; |
| 44 | |
| 45 | // skip the boolean and the target |
| 46 | i = 2; |
| 47 | } |
| 48 | |
| 49 | // extend Phaser if only one argument is passed |
| 50 | if (length === i) |
| 51 | { |
| 52 | target = this; |
| 53 | --i; |
| 54 | } |
| 55 | |
| 56 | for (; i < length; i++) |
| 57 | { |
| 58 | // Only deal with non-null/undefined values |
| 59 | if ((options = arguments[i]) != null) |
| 60 | { |
| 61 | // Extend the base object |
| 62 | for (name in options) |
| 63 | { |
| 64 | src = target[name]; |
| 65 | copy = options[name]; |
| 66 | |
| 67 | // Prevent never-ending loop |
| 68 | if (target === copy) |
| 69 | { |
| 70 | continue; |
| 71 | } |
| 72 | |
| 73 | // Recurse if we're merging plain objects or arrays |
| 74 | if (deep && copy && (IsPlainObject(copy) || (copyIsArray = Array.isArray(copy)))) |
| 75 | { |
| 76 | if (copyIsArray) |
| 77 | { |
| 78 | copyIsArray = false; |
| 79 | clone = src && Array.isArray(src) ? src : []; |
| 80 | } |
| 81 | else |
| 82 | { |
| 83 | clone = src && IsPlainObject(src) ? src : {}; |
| 84 | } |
| 85 | |
| 86 | // Never move original objects, clone them |
| 87 | target[name] = Extend(deep, clone, copy); |
| 88 |
nothing calls this directly
no test coverage detected
searching dependent graphs…