1.0.0 • Published 1 year ago
yusheng-tools v1.0.0
安装
npm install yusheng-tools
导入
const yusheng = require('yusheng-tools')
格式化时间
// 调用 dateFormat 对时间进行格式化
const tm = index.dateFormat(new Date())
console.log(tm);
// 结果: 2023-04-23 11:23:04
转义 HTML 中的特殊字符
// 调用 htmlEscape 进行HTML特殊符号转义
const htmlStr = '<h1 title="abc">123</h1><span>abc </span>'
const html = index.htmlEscape(htmlStr)
console.log(html);
// 结果 <h1 title="abc">123</h1><span>abc&nbsp</span>
还原 HTML 中的特殊字符
// 调用 htmlUnEscape 进行HTML特殊符号还原
const str = '<h1 title="abc">123</h1><span>abc&nbsp</span>'
const html2 = index.htmlUnEscape(str)
console.log(html2);
// 结果 <h1 title="abc">123</h1><span>abc </span>
开源协议
ISC
1.0.0
1 year ago