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>
2019-01-15 16:20:22 +00:00
* @copyright 2019 Photon Storm Ltd.
2018-02-12 16:01:20 +00:00
* @license {@link https://github.com/photonstorm/phaser/blob/master/license.txt|MIT License}
*/
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;