UNPKG

emo-itheima-tools

Version:

格式化时间和html escape

34 lines (32 loc) 761 B
function escape(htmlStr){ return htmlStr.replace(/<|>|"|&/g,(m)=>{ switch(m){ case '<': return '&lt;' case '>': return '&gt;' case '"': return '&quot;' case '&': return '&amp;' } }) } function unEscape(htmlStr){ return htmlStr.replace(/&lt;|&gt;|&quot;|&amp;/g,(m)=>{ switch(m){ case '&lt;': return '<' case '&gt;': return '>' case '&quot;': return '"' case '&amp;': return '&' } }) } module.exports = { escape, unEscape }