1.0.0 • Published 1 year ago

cjj-tools v1.0.0

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

安装

npm install cjj-tools

导入

const cjj_tools = require('cjj-tools')

格式化时间

const date = cjj_tools.formatDate(new Date)
// 转换后的结果: 2022-12-28 23:18:51

转换 HTML 字符串中的特殊字符

// 转换前的HTML字符串
const htmlStr = '<h1 style="">asdfasd&nbsp;</h1>'
// 转换后的结果: &lt;h1 style=&quot;&quot;&gt;asdfasd&amp;nbsp;&lt;/h1&gt;
console.log(cjj_tools.htmlEscape(htmlStr));

还原 HTML 字符串中的特殊字符

// 转换前的字符串
const htmlUnStr = '&lt;h1 style=&quot;&quot;&gt;asdfasd&amp;nbsp;&lt;/h1&gt;'
// 转换后的结果: <h1 style="">asdfasd&nbsp;</h1>
console.log(cjj_tools.htmlUnEscape(htmlUnStr));

开源协议

ISC