1.0.0 • Published 10 months ago

faded-tools v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
10 months ago

安装

npm install faded-tools

导入

const data = require('./index')

格式化时间

// 调用 dataFormat 函数 传入时间对象即可
const dtStr = data.dataFormat(new Date())

// 结果 2024-11-11 21:04:16
console.log("🚀 ~ dtStr:", dtStr)

格式化时间

// 调用 dataFormat 函数 传入时间对象即可
const dtStr = data.dataFormat(new Date())

// 结果 2024-11-11 21:04:16
console.log("🚀 ~ dtStr:", dtStr)

转义 html 标签

// 待转义的html
const html = '<h1 title="abc">这是h1标签<span>123&nbsp;</span></h1>'
// 调用 htmlEscape 函数 传入需要转义的html标签即可
const strHtml = data.htmlEscape(html)
// 结果 &lt;h1 title=&quot;abc&quot;&gt;这是h1标签&lt;span&gt;123&amp;nbsp;&lt;/span&
console.log("🚀 ~ strHtml:", strHtml)

反转义 html 标签

// 转义后的html
const strUnHtml = data.htmlUnEscape(strHtml)
// 结果 <h1 title="abc">这是h1标签<span>123&nbsp;</span></h1>
console.log("🚀 ~ strUnHtml:", strUnHtml)

开源协议

ISC

1.0.0

10 months ago