1.0.0 • Published 7 months ago
tools-zpp v1.0.0
安装
npm install tools-zpp
导入
const tools = require('tools-zpp')
格式化时间
// 调用 dateFormat 对时间进行格式化
const dtStr = tools.dateFormat(Date.now())
console.log(dtStr)
// 结果 2023-11-04 11:14:10
转义 HTML 中的特殊字符
// 调用 htmlTranslate 方法进行转换
const htmlStr = '<h1 title="abc">这是h1标签<span>123 </span></h1>'
console.log(htmlTranslate.htmlTranslate(htmlStr));
// 结果 <h1 title="abc">这是h1标签<span>123&nbsp;</span></h1>
还原 HTML 中的特殊字符
// 调用 htmlUnTranslate 方法进行转换
const htmlStr = '<h1 title="abc">这是h1标签<span>123&nbsp;</span></h1>'
console.log(htmlTranslate.htmlUnTranslate(htmlStr));
// 结果 <h1 title="abc">这是h1标签<span>123undefinednbsp;</span></h1>
开源协议
ISC
1.0.0
7 months ago