1.1.0 • Published 7 months ago

servletutils v1.1.0

Weekly downloads
-
License
ISC
Repository
-
Last release
7 months ago

安装

npm i servlet-utils

导入

const servletUtils = require('servlet-utils')

格式化时间

// 调用 dateFormat 对时间格式化
const dtStr = servletUtils.dateFormat(new Date())
// 结果 2023-10-26 22:20:29
console.log(dtStr)

转义 HTML 中的特殊字符

const htmlStr = '<h1>标&nbsp;签</h1>'
// 调用 htmlEscape 对字符进行转义
const newStr = servletUtils.htmlEscape(htmlStr)
// 结果 &lt;h1&gt;标&amp;nbsp;签&lt;/h1&gt;
console.log(newStr)

转义 HTML 中的特殊字符

const htmlStr = '&lt;h1&gt;标&amp;nbsp;签&lt;/h1&gt;'
// 调用 htmlEscape 对字符进行转义
const newStr = servletUtils.htmlUnEscape(htmlStr)
// 结果 <h1>标&nbsp;签</h1>
console.log(newStr)

开源协议

ISC

1.1.0

7 months ago