Do not use Object.assign as _.defautls equivalent

This commit is contained in:
Daniel García Aubert 2018-10-19 11:57:54 +02:00
parent b75c1f7f08
commit 5573db2bc1
2 changed files with 14 additions and 19 deletions

View File

@ -72,14 +72,8 @@ module.exports = class MapStoreMapConfigProvider extends BaseMapConfigProvider {
}
createKey (base) {
const tplValues = Object.assign({
dbname: '',
token: '',
dbuser: '',
format: '',
layer: '',
scale_factor: 1
}, this.params);
const { dbname = '', token = '', dbuser = '', format = '', layer = '', scale_factor = 1 } = this.params;
const tplValues = { dbname, token, dbuser, format, layer, scale_factor };
return (base) ? baseKeyTpl(tplValues) : rendererKeyTpl(tplValues);
}

View File

@ -232,15 +232,16 @@ module.exports = class NamedMapMapConfigProvider extends BaseMapConfigProvider {
}
createKey (base) {
const tplValues = Object.assign({
dbname: '',
user: this.user,
templateName: this.templateName,
authToken: this.authToken || '',
configHash: configHash(this.config),
layer: '',
scale_factor: 1
}, this.params);
const {
dbname = '',
user = this.user,
templateName = this.templateName,
authToken = this.authToken || '',
configHash = createConfigHash(this.config),
layer = '',
scale_factor = 1
} = this.params;
const tplValues = { dbname, user, templateName, authToken, configHash, layer, scale_factor };
return (base) ? baseKeyTpl(tplValues) : rendererKeyTpl(tplValues);
}
@ -268,7 +269,7 @@ module.exports = class NamedMapMapConfigProvider extends BaseMapConfigProvider {
}
};
function configHash(config) {
function createConfigHash(config) {
if (!config) {
return '';
}
@ -276,4 +277,4 @@ function configHash(config) {
return crypto.createHash('md5').update(JSON.stringify(config)).digest('hex').substring(0,8);
}
module.exports.configHash = configHash;
module.exports.configHash = createConfigHash;