itty-tools

1.0.0 • Public • Published

安装

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

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i itty-tools

      Weekly Downloads

      0

      Version

      1.0.0

      License

      ISC

      Unpacked Size

      2.18 kB

      Total Files

      5

      Last publish

      Collaborators

      • tyzyp2024