1.0.0 • Published 1 year ago

itzfr-tools v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
1 year ago

安装

npm install itzfr-tools

导入

const itzfr = require('itzfr-tools')

格式化时间

// 调用 dateFormat 对时间进行格式化
const dtStr = itzfr.dateFormat(new Date())
console.log(dtStr)
// 结果 2024-05-05 17:44:45

转义 HTML 中的特殊字符

// 调用 htmlEscape 方法进行转换
const htmlStr = itzfr.htmlEscape('<h1 style="color:red">H1标签</h1>')
console.log(htmlStr)
// 转换的结果   &lt;h1 style=&quot;color:red&quot;&gt;H1标签&lt;/h1&gt;

还原 HTML 中的特殊字符

// 待还原的 HTML 字符串
const htmlStr2 = itzfr.htmlUnEscape(htmlStr)
console.log(htmlStr2)
// 输出的结果   <h1 style="color:red">H1标签</h1>

开源协议

ISC
1.0.0

1 year ago