1.0.0 • Published 2 years ago

dkc-tools v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
2 years ago

安装

    npm install dkc-tools

导入

const  dkc = require('dkc-tools') 

格式化时间

// 调用 dateFormat 对时间进行格式化
const te = time.dataFormat(new Date())
//输出结果 2022-04-01 10:37:06
console.log(te)

转义 HTML 特殊字符

// 定义了待转义的 HTML 字符串
const str = "<h1 title='zbc'>hell! <span>小黄</span></h1>"
// 调用 htmlEscape方法进行转换
const tr = time.htmlEscape(str)
// 转换的结果为 &lt;h1 title='zbc'&gt;hell! &lt;span&gt;小黄&lt;/span&gt;&lt;/h1&gt;
console.log(tr)

还原 HTML 中的特殊字符

// 待还原的 HTML 字符串
const t = time.htmlUnEscape(tr)
// 转换的结果为 <h1 title='zbc'>hell! <span>小黄</span></h1>
console.log(t) 

开源协议

ISC