Skip to content

Commit

Permalink
simplify
Browse files Browse the repository at this point in the history
  • Loading branch information
physik932 committed Dec 3, 2024
1 parent 7703b7c commit e599dd5
Showing 1 changed file with 2 additions and 12 deletions.
14 changes: 2 additions & 12 deletions src/javascripts/lib/helpers.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,7 @@ export function resizeContainer (max = Number.POSITIVE_INFINITY) {
* @return {String} final template
*/
export function templatingLoop (set, getTemplate, initialValue = '') {
return set.reduce((accumulator, item, index) => {
return `${accumulator}${getTemplate(item, index)}`
}, initialValue)
return set.reduce((accumulator, item, index) => `${accumulator}${getTemplate(item, index)}`, initialValue)
}

/**
Expand All @@ -48,15 +46,7 @@ export function render (replacedNodeSelector, htmlString) {
export function escapeSpecialChars (str) {
if (typeof str !== 'string') throw new TypeError('escapeSpecialChars function expects input in type String')

const escape = {
'&': '&',
'<': '&lt;',
'>': '&gt;',
'"': '&quot;',
"'": '&#x27;',
'`': '&#x60;',
'=': '&#x3D;'
}
const escape = {'&': '&amp;', '<': '&lt;', '>': '&gt;', '"': '&quot;', "'": '&#x27;', '`': '&#x60;', '=': '&#x3D;'}

return str.replace(/[&<>"'`=]/g, function (m) { return escape[m] })
}
Expand Down

0 comments on commit e599dd5

Please sign in to comment.