1.0.0 • Published 2 years ago

itqiu-tools v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

安装

npm install itqiu-tools

导入

const itqiu = require('./itqiu-tools')

格式化时间

//调用dateFormat进行时间的格式化
const time = itqiu.dateFormat(new Date())
//结果为2023-03-29 11:31:15
console.log(time)

转义html

//带转换的html字符串
const str = `<h1 style='abc'>1111</h1>`
// 调用htmlEscape方法进行转换
const result = itqiu.htmlEscape(str)
// 转换的结果为&lt;h1 style='abc'&gt;1111&lt;/h1&gt;
console.log(result)

还原html

// 转移后的字符串
const result = &lt;h1 style='abc'&gt;1111&lt;/h1&gt;
//调用htmlUnEscape方法转换
const result2 = itqiu.htmlUnEscape(result)
//转换结果为<h1 style='abc'>1111</h1>
console.log(result2)

开源协议

ISC

1.0.0

2 years ago