1.0.1 • Published 1 year ago

zjp-tools v1.0.1

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

安装

npm install zjp-tools

导入

const zjp = require('zjp-tools')

格式化时间

// 调用函数格式化时间
const date = zjp.formatDate(new Date())
// 2023-02-05-21 21:55:23
console.log(date)

转义 html 文件特殊字符

// html 字符串
const htmlStr = '<h2 title="abc">这是h2标签<span>123&nbsp;</span></h2>'
let res = zjp.htmlEscape(htmlStr)

// &lt;h2 title=&quot;abc&quot;&gt;这是h2标签&lt;span&gt;123&amp;nbsp;&lt;/span&gt;&lt;/h2&gt;
console.log(res);

还原 html 文件特殊字符

let rowHTML = htmlUnEscape(res)

// <h2 title="abc">这是h2标签<span>123&nbsp;</span></h2>
console.log(rowHTML);

开源协议

ISC

1.0.1

1 year ago