1.0.0 • Published 2 years ago

xxf-tools v1.0.0

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

安装

npm install itxxf-tools

导入

const itxxf = require('itxxf-tools')

格式化时间

//对时间进行格式化
const dateStr=itxxf.dateFormat(new Date())
console.log(dateStr)
//结果 2022-09-16 15:48:21

转义html的特殊字符

const htmlStr='<h1 title="abc">你好啊<span>这是span标签</span></h1>'
//调用htmlEscape方法进行转换
const str=itxxf.htmlEscape(htmlStr)
//结果:&lt;h1 title=$quot;abc$quot;&gt;你好啊&lt;span&gt;这是span标签&lt;/span&gt;&lt;/h1&gt;
console.log(str)

//还原html字符串功能

//待还原的html字符串
const str2=itxxf.unHtmlEscape(str)
//结果:<h1 title=$quot;abc$quot;>你好啊<span>这是span标签</span></h1>
console.log(str2)

开源协议

ISC