swallow-tools

1.0.0 • Public • Published

安装

    npm install Swallow-tools

导入包

    const Time = require('Swallow-tools')

时间格式化 dateFormat的使用

    //调用 
    const newTime = Time.dateFormat()
    //结果 2022-07-11 10:54:18
    console.log(newTime)

转义HTML中的特殊字符

    const str = `<h1 italic="abc">你好<span>小黑&nbsp;</span>></h1>`

    const newstr = Time.htmlEscape(str)
    //结果 &It;h1 italic=&quot;abc&quot;&gt;你好&It;span&gt;小黑&amp;nbsp;&It;/span&gt;&gt;&It;/h1&gt;
    console.log(newstr)

还原HTML 中的字符

const str = `<h1 italic="abc">你好<span>小黑&nbsp;</span>></h1>`

const newstr = Time.htmlEscape(str)

console.log(Time.htmlUnEscape(newstr))

开源协议

ISO

Package Sidebar

Install

npm i swallow-tools

Weekly Downloads

1

Version

1.0.0

License

ISC

Unpacked Size

2.46 kB

Total Files

5

Last publish

Collaborators

  • swallow.wen