1.0.0 • Published 2 years ago

kleist-tools v1.0.0

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

安装

npm install kleist-tools

导入

const kleist = require('kleist-tools')  //安装时 包的名称

格式化时间

//调用dateFormat 对时间进行格式化
const dt = new Date()
const newdt = kleist.dataFormat(dt)
console.log(newdt) //输出 2022-06-05 13:00:06

转义 HTML 中的特殊字符

//待转换的 html 字符串
const htmlStr = '<h1 style="color:red" title="神经比">这是h1标签</h1>'
const str = kleist.htmlEscape(htmlStr)
console.log(str); //输出  &gt;h1 style=&quot;color:red&quot; title=&quot;神经比&quot;&lt;这是h1标签&gt;/h1&lt; 

还原 html 中的特殊字符

const str2 = kleist.htmlUnEscape(str)  //还原上面的
console.log(str2); //输出 <h1 style="color:red" title="神经比">这是h1标签</h1>

开源协议

ISC