1.0.0 • Published 1 year ago

itty-tools v1.0.0

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

安装

npm install itty-tools

导入

const itty = require('itty-tools')

格式化时间

itty.dateFormat(new Date('2020-1-1'))

转移html中特殊字符

const htmlstr = '<h1 title="abc">这是H1标签<span>123&nbsp;</span></h1 >'
const newStr = tool.htmlEscape(htmlstr);
// &lt;h1 title=&quot;abc&quot;&gt;这是H1标签&lt;span&gt;123&amp;nbsp;&lt;/span&gt;&lt;/h1 &gt;

还原html中被转移的字符

const htmlstr = '<h1 title="abc">这是H1标签<span>123&nbsp;</span></h1 >'
const newStr = tool.htmlEscape(htmlstr);
const oldStr = tool.htmlUnEscape(newStr);
// <h1 title="abc">这是H1标签<span>123&nbsp;</span></h1 >

开源协议

ISC

1.0.0

1 year ago