1.0.0 • Published 10 months ago
wagu v1.0.0
安装
npm install wagu
导入
const wagu = require('wagu')
格式化时间
// 调用times对时间格式化
const time = wagu.times(new Date())
console.log(time)
//结果 2023-07-05 17:20:31
转义 HTML 中的特殊字符
// 带转化的 HTML 字符串
const htmlStr = '<h1 title="abc">hello <span>123 </span> </h1>'
// 调用htmlEscaape
console.log(wagu.htmlEscape(htmlStr))
// 转化的结果 <h1 title="abc">hello <span>123&nbsp;</span> </h1>
还原 HTML 中的特殊字符
// 待还原的html字符
console.log(wagu.htmlUnEscape(wagu.htmlEscape(htmlStr)))
// 输出的结果<h1 title="abc">hello <span>123 </span> </h1>
开源协议
ISC
1.0.0
10 months ago