my-helps

1.0.0 • Public • Published

安装

npm install my-helps

导入

const dt = require('../node.js/my-helps')

格式化时间

//调用dataFormat 对时间进行格式化
const n = dt.dataFormat(new Date())
//结果 2022-05-05 20:28:04
console.log(n);

转义 HTML中的特殊字符

//待转义的 HTML字符串
const htmlstr = '<h1 title="abc">这是h标签<span>123&nbsp;</span></h1>'
// 调用 htmlEscape 方法进行转换
const m= dt.htmlEscape(htmlstr)
// 结果  &lt;h1 title=&quot;abc&quot;&gt;这是h标签&lt;span&gt;123&amp;nbsp;&lt;/span&gt;&lt;/h1&gt;
console.log(m);

还原 HTML中的特殊字符

//待还原的 HTML 字符串
const nn = dt.htmlUnEscape(m)
// 结果 <h1 title="abc">这是h标签<span>123&nbsp;</span></h1>
console.log(nn);

开源协议

ISC

Dependencies (0)

    Dev Dependencies (0)

      Package Sidebar

      Install

      npm i my-helps

      Weekly Downloads

      0

      Version

      1.0.0

      License

      ISC

      Unpacked Size

      2.73 kB

      Total Files

      5

      Last publish

      Collaborators

      • wunannan