1.0.0 • Published 1 year ago

lyl-tools v1.0.0

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

安装

npm install lyl-tools

导入

const tools = require("lyl-tools");

格式化时间

// 调用dateFormat方法对时间进行格式化
const dtStr = tools.dateFormat(new Date());
// 结果 2024-06-04 18:40:28
console.log("dtStr");

转义 HTML 中的特殊字符

// 待转换的HTML字符串
const htmlStr = "<h1 title="dad">撒的好机会</h1>";
// 调用htmlEscape方法进行转换
const str = tools.htmlEscape(htmlStr);
// 转换后的结果&lt;h1 title=&quot;dad&quot;&gt;撒的好机会&lt;/h1&gt;
console.log('str');

还原 HTML 中的特殊字符

// 待还原的HTML字符串
const htmlStr = "&lt;h1 title=&quot;dad&quot;&gt;撒的好机会&lt;/h1&gt;";
// 调用htmlEscape方法进行转换
const str = tools.htmlUnEscape(htmlStr);
// 转换后的结果<h1 title="dad">撒的好机会</h1>
console.log("str");

开源协议

ISC

1.0.0

1 year ago