1.0.1 • Published 2 years ago
dsq_tool v1.0.1
安装方式
npm install dsq_tool
导入方式
const dsq = require('dsq_tool')
格式化时间
// 调用dataFormat对时间进行格式化
const dtStr = dsq.dataFormat(new Date())
// 输出结果 2022-10-25 16:29:50
console.log(dtStr);
转义 HTML 中的特殊字符
// 带转换的HTML字符串
const ht = '< h1 > "测试" & nbsp; < /h1>'
// 调用htmlEscape对字符串进行转义
const htStr = dsq.htmlEscape(ht)
// 输出结果< h1 > "测试" & nbsp; < /h1>
console.log(htStr);
还原 HTML 中的特殊字符
// 还原的HTML字符串
const uht = '< h1 > "测试" & nbsp; < /h1>'
// 调用htmlUnEscape对字符串进行还原
const uhtStr = dsq.htmlUnEscape(uht)
// 输出结果< h1 > "测试" & nbsp; < /h1>
console.log(uhtStr);
开源协议
ISC