1.0.0 • Published 11 months ago

tayllen.tools v1.0.0

Weekly downloads
-
License
ISC
Repository
-
Last release
11 months ago

//使用说明文档

安装

npm install tayllen-tools

导入

const tay = require("tayllen-tools");

格式化时间

//调用 dataFormat 对时间进行格式化
const time = tay.dataFormat(new Date());
//输出结果:2023-06-08 15:56:33

转译字符

//调用 htmlEscape 对指定文本转换为实体字符
const html = "<h1 title='666'>转译<span>888&nbsp;</span></h1>";
const str = tay.htmlEscape(html);
//输出结果:&lt;h1 title='666'&gt;转译&lt;span&gt;888&amp;nbsp;&lt;/span&gt;&lt;/h1&gt;

还原转译

//调用htmlUnEscape 将实体字符还原
const ht =
  "&lt;h1 title='666'&gt;转译&lt;span&gt;888&amp;nbsp;&lt;/span&gt;&lt;/h1&gt;";
const strr = tay.htmlUnEscape(ht);
//输出结果:<h1 title='666'>转译<span>888&nbsp;</span></h1>

开源协议

ISC

1.0.0

11 months ago