dsq_tool

1.0.1 • Public • Published

安装方式

npm install dsq_tool

导入方式

const dsq = require('dsq_tool')

格式化时间

// 调用dataFormat对时间进行格式化
const dtStr = dsq.dataFormat(new Date())
// 输出结果 2022-10-25 16:29:50
console.log(dtStr);

转义 HTML 中的特殊字符

// 带转换的HTML字符串
const ht = '< h1 > "测试" & nbsp; < /h1>'
// 调用htmlEscape对字符串进行转义
const htStr = dsq.htmlEscape(ht)
// 输出结果&lt; h1 &gt; &quot;测试&quot; &amp; nbsp; &lt; /h1&gt;
console.log(htStr);

还原 HTML 中的特殊字符

// 还原的HTML字符串
const uht = '&lt; h1 &gt; &quot;测试&quot; &amp; nbsp; &lt; /h1&gt;'
// 调用htmlUnEscape对字符串进行还原
const uhtStr = dsq.htmlUnEscape(uht)
// 输出结果< h1 > "测试" & nbsp; < /h1>
console.log(uhtStr);

开源协议

ISC

Readme

Keywords

Package Sidebar

Install

npm i dsq_tool

Weekly Downloads

0

Version

1.0.1

License

ISC

Unpacked Size

2.61 kB

Total Files

5

Last publish

Collaborators

  • daitingyao