main.js
function format(template, values) {
	return Object
		.entries(values)
		.filter(
			([key]) => /^[a-z0-9_-]+$/gi.test(key)
		)
		.map(
			([key, value]) =>
				[new RegExp(`([^{]|^){${key}}([^}]|$)`,'g'), `$1${value}$2`]
		)
		.reduce(
			(str, [regexp, replacement]) => {
				return str.replace(regexp, replacement)
			}, template
		)
		.replace(/({|}){2}/g, '$1')
}
function format(template, values) {
	return Object
		.entries(values)
		.filter(
			([key]) => /^[a-z0-9_-]+$/gi.test(key)
		)
		.map(
			([key, value]) =>
				[new RegExp(`([^{]|^){${key}}([^}]|$)`,'g'), `$1${value}$2`]
		)
		.reduce(
			(str, [regexp, replacement]) => {
				return str.replace(regexp, replacement)
			}, template
		)
		.replace(/({|}){2}/g, '$1')
}
function format ( template , values ) { return Object . entries ( values ) . filter ( ( [ key ] ) => / ^[a-z0-9_-]+$ / gi . test ( key ) ) . map ( ( [ key , value ] ) => [ new RegExp ( ` ${ key } ` , 'g' ) , ` ${ value } ` ] ) . reduce ( ( str , [ regexp , replacement ] ) => { return str . replace ( regexp , replacement ) } , template ) . replace ( / ({|}){2} / g , '$1' ) }
Replace in-string variables with their values from given object
@param  {String} template
@param  {Object} values
@return {String}
Replace in - string variables with their values from given object