2018-02-12 16:01:20 +00:00
|
|
|
/**
|
|
|
|
* @author Richard Davey <rich@photonstorm.com>
|
2019-01-15 16:20:22 +00:00
|
|
|
* @copyright 2019 Photon Storm Ltd.
|
2019-05-10 15:15:04 +00:00
|
|
|
* @license {@link https://opensource.org/licenses/MIT|MIT License}
|
2018-02-12 16:01:20 +00:00
|
|
|
*/
|
|
|
|
|
2018-01-25 23:19:23 +00:00
|
|
|
var Extend = require('../utils/object/Extend');
|
2016-11-30 00:18:34 +00:00
|
|
|
var XHRSettings = require('./XHRSettings');
|
|
|
|
|
2018-02-08 17:00:14 +00:00
|
|
|
/**
|
|
|
|
* Takes two XHRSettings Objects and creates a new XHRSettings object from them.
|
|
|
|
*
|
|
|
|
* The new object is seeded by the values given in the global settings, but any setting in
|
|
|
|
* the local object overrides the global ones.
|
|
|
|
*
|
|
|
|
* @function Phaser.Loader.MergeXHRSettings
|
|
|
|
* @since 3.0.0
|
|
|
|
*
|
2019-05-09 11:04:54 +00:00
|
|
|
* @param {Phaser.Types.Loader.XHRSettingsObject} global - The global XHRSettings object.
|
|
|
|
* @param {Phaser.Types.Loader.XHRSettingsObject} local - The local XHRSettings object.
|
2018-02-08 17:00:14 +00:00
|
|
|
*
|
2019-05-09 11:04:54 +00:00
|
|
|
* @return {Phaser.Types.Loader.XHRSettingsObject} A newly formed XHRSettings object.
|
2018-02-08 17:00:14 +00:00
|
|
|
*/
|
2016-11-30 00:18:34 +00:00
|
|
|
var MergeXHRSettings = function (global, local)
|
|
|
|
{
|
2018-02-14 17:52:52 +00:00
|
|
|
var output = (global === undefined) ? XHRSettings() : Extend({}, global);
|
2016-11-30 00:18:34 +00:00
|
|
|
|
|
|
|
if (local)
|
|
|
|
{
|
|
|
|
for (var setting in local)
|
|
|
|
{
|
|
|
|
if (local[setting] !== undefined)
|
|
|
|
{
|
|
|
|
output[setting] = local[setting];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
return output;
|
|
|
|
};
|
|
|
|
|
|
|
|
module.exports = MergeXHRSettings;
|