1.0.0 • Published 2 years ago

ithema-fabubao v1.0.0

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

安装

npm install ithema-fabubao

导入

const ithema = require('ithema-fabubao')

格式化时间

//调用dateFormat 对时间进行格式化
const dtStr = ithema.dateFormat(new Date())
console.log(dtStr)
//结果 2022-08-09 13:38:08

转义和还原html特殊字符

const htmlStr = '<h1 title="abc">这是h1标签<span>123&nbsp;</span></h1>'
const str = ithema.htmlEscape(htmlStr)
//调用htmlEscape 方法进行转换
console.log(str)
//结果 &lt;h1 title=&quot;abc&quot;&gt;这是h1标签&lt;span&gt;123&amp;nbsp;&lt;/span&gt;&lt;/h1&gt;

const str2 = ithema.htmlUnEscape(str)
//调用htmlUnEscape 方法进行还原
console.log(str2);
//结果 <h1 title="abc">这是h1标签<span>123&nbsp;</span></h1>

开源协议

ISC