1.0.0 • Published 8 months ago

nahida-tools v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
8 months ago

安裝方式

npm i nahida-tools

导入

const nahida = require('nahida-tools');

格式化时间

//调用formatDate对时间进行格式化
const tt =nahida.formatDate(new Date());
console.log(tt);
//输出为:2024-11-14 04:29:34

转义和还原HTML字符

//调用htmlEscape对testHtml的一个HTML标签做转换
const testHtml='<h1 title="abc">云璃<span>彦卿&nbsp;</span></h1>';
const htmlStr=nahida.htmlEscape(testHtml);
console.log(htmlStr);//输出为:&lt;h1 title=&quot;abc&quot;&gt;云璃&lt;span&gt;彦卿&amp;nbsp;&lt;/span&gt;&lt;/h1&gt;
//调用htmlUNEscape对testHtml的一个HTML标签做还原
const newHtml=nahida.htmlUnEscape                                                                                                                  (htmlStr);
console.log(newHtml);//输出为:<h1 title="abc">云璃<span>彦卿&nbsp;</span></h1   

开源协议

ISC

1.0.0

8 months ago