Spaces:
Sleeping
Sleeping
File size: 505 Bytes
4a288a7 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 | // @flow
export default resolveTokens;
/**
* Replace tokens in a string template with values in an object
*
* @param properties a key/value relationship between tokens and replacements
* @param text the template string
* @returns the template with tokens replaced
* @private
*/
function resolveTokens(properties: {+[string]: mixed}, text: string): string {
return text.replace(/{([^{}]+)}/g, (match, key: string) => {
return key in properties ? String(properties[key]) : '';
});
}
|