phaser/src/loader/MergeXHRSettings.js

37 lines
1,010 B
JavaScript
Raw Normal View History

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
*
* @param {Phaser.Loader.XHRSettings} global - The global XHRSettings object.
* @param {Phaser.Loader.XHRSettings} local - The local XHRSettings object.
*
* @return {Phaser.Loader.XHRSettings} 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;