1.0.0 • Published 2 years ago

dong973-tools v1.0.0

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

安装

npm i my-tools

导入

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

格式化时间

const dt = new Date();
console.log(my.dateFormat(dt));
// 结果:2022-10-30 21:14:31

转义 html 的特殊字符

原 html:这是 h1 标签这是 span 标签

const ans = my.htmlEscope(htmlStr);
console.log(ans);
//<h1 style="abc">这是h1标签<span>这是span标签</span></h1>

还原 html 的特殊字符

const ans1 = my.escopeHtml(ans);
console.log(ans1);
//<h1 style="abc">这是h1标签<span>这是span标签</span></h1>

开源协议

ISC