1.0.0 • Published 1 year ago

lsr-tools v1.0.0

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

安装

npm install lsr-tools

导入

const lsr = require('./lsr-tools');

格式化时间

// 调用 dateFormat 对时间进行格式化
const dt = new Date();
let newdt = lsr.dateFormat(dt);
console.log(newdt);
// 结果  2023-01-20 09:47:06

转义 HTML 中的特殊字符

// 带转换的 HTML 字符串
// 调用 htmlEscape 方法进行转换
// 转换的结果 
let str = '<h1>666</h1>';
const newstr = lsr.htmlEscape(str)
console.log(newstr);

还原 HTML 中的特殊字符

// 待还原的 HTML 字符串
// 输出的结果 
let ht = '&lt; &gt; &quot; &amp;'
const newht = lsr.unHtmlEscape(ht)
console.log(newht);

开源协议

ISC