1.0.2 • Published 1 year ago

ityx-tools v1.0.2

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

安装

npm install ityx-tools

导入

const ityx = require('ityx-tools')

格式化事件

// 调用 dateFormat()方法对时间格式化
const dt = ityx.dateFormat(new Date());
console.log(dt);    // 结果 2024-04-10 23:43:03

转义htlm中的字符

// 待转义的字符串
const htmlStr = `<h1 title="123">标题<span>副标题&nbsp</span></h1>`;
const str = ityx.htmlEscape(htmlStr);
console.log(str);
// 结果 &lt;h1 title=&quot;123&quot;&gt;标题&lt;span&gt;副标题&amp;nbsp&lt;/span&gt;&lt;/h1&gt;

还原htlm中的字符

// 待转义的h5
const hs = '&lt;h1 title=&quot;123&quot;&gt;标题&lt;span&gt;副标题&amp;nbsp&lt;/span&gt;&lt;/h1&gt;'
const html = ityx.htmlUnescape(hs);
console.log(html); // 结果 <h1 title="123">标题<span>副标题&nbsp</span></h1>

开源协议

ISC

1.0.2

1 year ago

1.0.1

1 year ago

1.0.0

3 years ago