phaser/src/loader/MergeXHRSettings.js

43 lines
1.2 KiB
JavaScript
Raw Normal View History

2018-02-12 16:01:20 +00:00
/**
* @author Richard Davey <rich@photonstorm.com>
2020-01-15 12:07:09 +00:00
* @copyright 2020 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
*/
var Extend = require('../utils/object/Extend');
2016-11-30 00:18:34 +00:00
var XHRSettings = require('./XHRSettings');
/**
* 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.
*
2019-05-09 11:04:54 +00:00
* @return {Phaser.Types.Loader.XHRSettingsObject} A newly formed XHRSettings object.
*/
2016-11-30 00:18:34 +00:00
var MergeXHRSettings = function (global, local)
{
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;