1.0.2 • Published 1 year ago

hjfirst_tools v1.0.2

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

安装

npm i hjfirst_tools

导入

const hj = require('hjfirst_tools')

格式化时间

//调用dateFormat对时间进行格式化
const dtStr = hj.dateFormate(new Date());
//输出结果 2022-11-10 19:03:13
console.log(dtStr);

转义html

const strs = '<h1 title="哥哥">你好,这是我的<span>妹妹&nbsp;"豆豆"</span></h1>';
//调用
const htmlstr = hj.htmlEscape(strs)
//结果&lt;h1 title=&quot;哥哥&quot;&gt;你好,这是我的&lt;span&gt;妹妹&amp;nbsp;&quot;豆豆&quot;&lt;/span&gt;&lt;/h1&gt;
console.log(htmlstr);

还原html特殊字符串

//调用
const htmls = hj.htmlUnEscape(htmlstr)
//结果<h1 title="哥哥">你好,这是我的<span>妹妹&nbsp;"豆豆"</span></h1>;

console.log(htmls);

开源协议

ISC