@lpovo/lp-tools
v1.0.0
Published
提供格式化时间、HTMLEscape相关功能
Downloads
109
Readme
安装
npm install lp-tools导入
const lp=require('lp-tools')
格式化时间
// 调用dateFormat对时间进行格式化
const dtStr = lp.dateFormat(new Date())
// 结果 2026-03-03-20-22-49
console.log(dtStr)
转义 HTML 中的特殊字符
// 带转换的 HTML 字符串
const htmlStr='<h1 title="abc">这是h1标签 </h1>'
// 调用htmlEscape方法进行转换
const str=lp.htmlEscape(htmlStr)
// 转换的结果 <h1 title="abc">这是h1标签&nbsp;</h1>
console.log(str)
还原 HTML 中的特殊字符
// 带还原的 HTML 字符串
const str2 = lp.htmlUnEscape(str)
//输出的结果 <h1 title="abc">这是h1标签 </h1>
console.log(str2)开源协议
ISC
