1.0.0 • Published 1 year ago

looper-tools v1.0.0

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

安装

npm install looper-tools

导入

const looper = require('looper-tools')

格式化事件

// 调用 dateFormat 对时间进行格式化
let dateStr = index.dateFormat(date)
// 输出结果如下  2023-02-22 13:52:55
console.log(dateStr)

转义 HTML 中的特殊字符

// 带有 html 标签的字符
let str = '<h1>404 "N"ot F&ound</h1>'
// 调用 htmlEscape 对HTML进行转义
const newStr = index.htmlEscape(str)
// 输出结果如下  &lt:h1&gt:404 &quot:N&quot:ot F&amp:ound&lt:/h1&gt:
console.log(newStr)

还原 HTML 中的特殊字符

// 带有 html 标签的字符
let str = '&lt:h1&gt:404 &quot:N&quot:ot F&amp:ound&lt:/h1&gt:'
// 调用 htmlEscape 对HTML进行转义
const newStr = index.unHtmlEscape(str)
// 输出结果如下  <h1>404 "N"ot F&ound</h1>
console.log(newStr)

开源协议

ISC