1.0.0 • Published 4 years ago

finale-utils v1.0.0

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

安装

npm install finale-utils

导入

const finale = require('finale-utils');

格式化时间的功能

// 调用dateFormat方法进行转换
console.log(finale.dateFormat(new Date()));

转义HTML中的特殊字符

const htmlStr = `<h1 title="abc"><span>123&nbsp;</span>这是h1标签</h1>`;
console.log(finale.htmlEscape(htmlStr));
// 输出结果
// &lt;h1 title=&quot;abc&quot;&gt;&lt;span&gt;123&amp;nbsp;&lt;/span&gt;这是h1标签&lt;/h1&gt;

还原HTML中的特殊字符

const str = `&lt;h1 title=&quot;abc&quot;&gt;&lt;span&gt;123&amp;nbsp;&lt;/span&gt;这是h1标签&lt;/h1&gt;`;
console.log(finale.htmlUnEscape(str));
// 输出的结果
// <h1 title="abc"><span>123&nbsp;</span>这是h1标签</h1>

开源协议

ISC

1.0.0

4 years ago