node.js - 我想去意大利化这个功能
问题描述
我怎样才能使这个功能更好?我不喜欢必须使用 aforEach
来定义可操作内容的事实。我正在考虑在 find 上运行 reduce,但这对我来说太混乱了。
_replace (content, find, replace, delimiter = '', findDelimiter = '') {
if (!Array.isArray(find)) find = [find]
let result = content
find.forEach(ref => {
result = result.split(findDelimiter).reduce((a, e) => a + delimiter + (this._reference[replace][this._reference[ref].indexOf(e)] || e), '')
})
return result
}
解决方案
推荐阅读
- java - 我正在尝试将一串数字放入 TextView 但我的应用程序在显示之前崩溃了
- delphi - 如何更改文本转语音中的默认语音?
- typescript - 打字稿 - 添加额外的函数参数
- javascript - hotel-datepicker 设置默认日期
- mysql - mysql数据库中数据复制和插入的脚本
- reactjs - 如何在反应钩子表单中的输入字段中使用数组状态?
- python - auto_arima(... ,seasonal=False) 但得到 SARIMAX
- ios - 将 Apple 证书和配置文件导入 Azure Pipeline
- javascript - Javascript:innerHTML 导致 NaN 返回值
- javascript - Chrome 离线存储无法在 iOS 上运行