1.0.0 • Published 1 year ago

tyler-tools v1.0.0

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

安装

npm install tyler-tools

导入

const tyler = require('./tyler-tools')

格式化时间

console.log(tyler.dateFormat(new Date()));
//输出结果: 2023-03-04 22:55:48

转义html字符串

//待转义的字符串
var htmlStr = '<h1 title="myhtml">123&nbsp;</h1>'
//得到转义后的字符串
var newHtmlStr = tyler.htmlEscape(htmlStr);
//输出结果:&lt;h1 title=&quot;myhtml&quot;&gt;123&amp;nbsp;&lt;/h1&gt;
console.log(newHtmlStr);

还原html转义后的字符串

//调用还原html字符串转义方法
//输出结果:<h1 title="myhtml">123&nbsp;</h1>
console.log(tyler.htmlUnescape(newHtmlStr));

开源协议

ISC