1.0.0 • Published 1 year ago

dabulin-tools v1.0.0

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

// 安装方式、导入方式、格式化时间、转移HTML中的特殊字符、还原HTML中的特殊字符、开源协议

安装

npm i dabulin

导入方式

const dabulin = require('./dabulin-tools/index');

格式化时间

// 调用dateFormat 对时间进行格式化

const dt= dabulin.dateFormat(new Date());

// 结果 2023-05-16 11:38:05

console.log(dt);

转义HTML中的特殊字符

// 带转换的HTML字符串

const htmlStr = '<h1>"你好"</h1>'

// 调用htmlEscape 方法进行转换

const str = dabulin.htmlEscape(htmlStr);

// 转换的结果  &lt;h1&gt;&quot;你好&quot;&lt;/h1&gt;

console.log(str);

还原 HTML 中的特殊字符

// 待还原的字符串

const str2 = dabulin.htmlUnEscape(str);

// 结果 <h1>"你好"</h1>

console.log(str2);

开源协议

ISC