1.0.1 • Published 1 year ago

zhy-tools v1.0.1

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

安装

npm install zhy-tools

导入

const tools = require('zhy-tools')

格式化时间

// 调用 dateFormat 对时间进行格式化
const timer = new Date()
const dates = tools.dateFormat(timer)
// 结果 2023-03-01 16:10:53
console.log(dates)

转义 HTML 中的特殊符号

// 原始数据
const htmlStr = '<h1 title="abc">我是H1标签<span>我在span标签里面&nbsp</span><h1/>'
// 调用 htmlEscape 方法进行转换
const newstr = tools.htmlEscape(htmlStr)
// 转换结果 &lt;h1 title=&quot;abc&quot;&gt;我是H1标签&lt;span&gt;我在span标签里面&amp;nbsp&lt;/span&gt;&lt;h1/&gt;
console.log(newstr)

还原 HTML 中的特殊字符

// 调用 htmlUnEscape 方法进行转换
const newstr = tools.htmlUnEscape(htmlStr)
// 转换结果 <h1 title="abc">我是H1标签<span>我在span标签里面&nbsp</span><h1/>
console.log(newstr)

开源协议

ISC

1.0.1

1 year ago

1.0.0

2 years ago