tra-analysis/website/functions/node_modules/string-format-obj/index.js

19 lines
378 B
JavaScript
Raw Normal View History

2019-01-06 19:14:45 +00:00
'use strict';
module.exports = function (template, args) {
if (!args) {
return interpolate.bind(null, template);
}
return interpolate(template, args);
};
function interpolate(template, args) {
if (typeof args === 'undefined') {
args = {};
}
return template.replace(/{([^}]*)}/g, function (match, key) {
return key in args ? args[key] : match;
});
}