qixiacy
v1.0.0
Published
提供了格式化时间、HTMLEscape相关的功能
Downloads
2
Readme
安装
npm install qixiacy
导入
const qixiacy = require("qixiacy")
格式化时间
// 调用 dateFormat 方法 对时间进行格式化
const dateStr = qixiacy.dateFormat(new Date());
// 结果 2022-07-26 13:37:34
console.log(dateStr);
转义 HTML 中的特殊字符
// 定义待转化的 HTML 字符串
const str = '<h1 class="title">这是h1标签</h1>';
// 调用 htmlEscape 方法进行转换
const m = qixiacy.htmlEscape(str)
// 结果 &glt;h1 class="title">这是h1标签&glt;/h1>
console.log(m);
还原 HTML 中的特殊字符
// 待还原的 HTML 字符串
const s = qixiacy.htmlUnEscape(m)
// 结果 <h1 class="title">这是h1标签</h1>
console.log(s);
开源协议
ISC