mirror of
https://github.com/BoostIo/Boostnote
synced 2025-12-12 17:26:17 +00:00
30 lines
577 B
JavaScript
30 lines
577 B
JavaScript
export function lastFindInArray (array, callback) {
|
|
for (let i = array.length - 1; i >= 0; --i) {
|
|
if (callback(array[i], i, array)) {
|
|
return array[i]
|
|
}
|
|
}
|
|
}
|
|
|
|
export function escapeHtmlCharacters (text) {
|
|
const matchHtmlRegExp = /["'&<>]/
|
|
const str = '' + text
|
|
const match = matchHtmlRegExp.exec(str)
|
|
|
|
if (!match) {
|
|
return str
|
|
}
|
|
|
|
return str
|
|
.replace(/&/g, '&')
|
|
.replace(/</g, '<')
|
|
.replace(/>/g, '>')
|
|
.replace(/"/g, '"')
|
|
.replace(/'/g, ''')
|
|
}
|
|
|
|
export default {
|
|
lastFindInArray,
|
|
escapeHtmlCharacters
|
|
}
|