UNPKG

xe-utils

Version:

JavaScript 函数库、工具类

14 lines (11 loc) 377 B
import toValueString from './toValueString' import keys from './keys' function helperFormatEscaper (dataMap) { var replaceRegexp = new RegExp('(?:' + keys(dataMap).join('|') + ')', 'g') return function (str) { return toValueString(str).replace(replaceRegexp, function (match) { return dataMap[match] }) } } export default helperFormatEscaper