1.0.0 • Published 1 year ago

hjh_tools_utils v1.0.0

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

安装

npm install hjh_tools_utils

导入

const tools = require('hjh_tools_utils')

格式化时间

//对指定日期进行格式化并输出
const date=new Date()
console.log(tools.format(date))

转义 HTML 中的特殊字符

// 转义 HTML 特殊字符串
// 例如:<h1 title="caption">何家辉</h1> 转义成 &lt;h1 title=&quot;caption&quot;&gt;何家辉&lt;h1&gt;
const htmlStr='<h1 title="caption">何家辉</h1>'
const zhuanhuan=tools.zhuanhuan(htmlStr)
console.log(zhuanhuan)

还原 HTML 中的特殊字符

// 还原 HTML 特殊字符串
// 例如: &lt;h1 title=&quot;caption&quot;&gt;何家辉&lt;h1&gt;还原成 <h1 title="caption">何家辉</h1>
const htmlStr2='&lt;h1 title=&quot;caption&quot;&gt;何家辉&lt;/h1&gt;'
const huanyuan=tools.huanyuan(htmlStr2)
console.log(huanyuan)

开源协议

ISC

1.0.0

1 year ago