1.0.0 • Published 2 years ago

palenge-tools v1.0.0

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

安装

npm install palenge-tools

导入

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

格式化时间

// 1.调用dateFormat()方法
const dt = index.dateFormat(new Date());
// 2.输出格式化后的时间2022-04-03 01:19:33
console.log(dt);

转义html

// 1.调用htmlEscape()方法
const html = index.htmlEscape('<h1 title="abd">这是H1标签<span>123&nbsp;</span></h1>');
// 2.输出转义后的结果
console.log(html);

还原被转义的html

// 1.调用unHtml()方法
const unHtml = index.htmlUnEscape('&lt;h1 title=&quot;abd&quot;&gt;这是H1标签&lt;span&gt;123&amp;nbsp;&lt;/span&gt;&lt;/h1&gt;');
// 2.输出还原后的结果
console.log(unHtml);

开源协议

ISC