Use Object.assign() instead of _.defaults()

This commit is contained in:
Daniel García Aubert 2019-09-13 17:58:23 +02:00
parent c0afd42fa2
commit e8d5e42300

View File

@ -1,6 +1,5 @@
'use strict'; 'use strict';
var _ = require('underscore');
var NamedMapMapConfigProvider = require('../models/mapconfig/provider/named-map-provider'); var NamedMapMapConfigProvider = require('../models/mapconfig/provider/named-map-provider');
var templateName = require('../backends/template_maps').templateName; var templateName = require('../backends/template_maps').templateName;
@ -70,12 +69,14 @@ function createNamedMapKey(user, templateId) {
var providerKeyTpl = ctx => `${ctx.authToken}:${ctx.configHash}:${ctx.format}:${ctx.layer}:${ctx.scale_factor}`; var providerKeyTpl = ctx => `${ctx.authToken}:${ctx.configHash}:${ctx.format}:${ctx.layer}:${ctx.scale_factor}`;
function createProviderKey(config, authToken, params) { function createProviderKey(config, authToken, params) {
var tplValues = _.defaults({}, params, { const defaults = {
authToken: authToken || '', authToken: authToken || '',
configHash: NamedMapMapConfigProvider.configHash(config), configHash: NamedMapMapConfigProvider.configHash(config),
layer: '', layer: '',
format: '', format: '',
scale_factor: 1 scale_factor: 1
}); };
return providerKeyTpl(tplValues); const ctx = Object.assign({}, defaults, params);
return providerKeyTpl(ctx);
} }