UNPKG

cjl_npm_tools

Version:

提供了关于时间,日期方面的方法,还有像深度拷贝,封装的百度翻译,16进制颜色转换等

36 lines (34 loc) 822 B
//定义转义HTML字符的函数 function htmlEscape(html){ return html.replace(/<|>|"|&/g,(res)=>{ switch (res) { case '<': return '&lt;' case '>': return '&gt;' case '&': return '&amp;' case '"': return '&quot;' } }) } //定义还原HTML字符的函数 function UnhtmlEscape(html){ return html.replace(/&lt;|&gt;|&amp;|&quot;/g,(res)=>{ switch (res) { case '&lt;': return '<' case '&gt;': return '>' case '&amp;': return '&;' case '&quot;': return '"' } }) } module.exports={ htmlEscape, UnhtmlEscape }