1.0.1 • Published 2 years ago

hl-tools v1.0.1

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

安装

 npm install hl-tools --save

导入

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

dataFormat的使用方法

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

const date = new Date();

const resultDate = tools.dataFormat(date);

// 结果是 2022-07-08 10:26:30
console.log(resultDate);

htmlEscape的使用方法 (对特殊字符进行转义)

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

const text = "<h1> sdfs<span>sd</span></h1>";

const htmlEscape = tools.htmlEscape(text);

// 结果是 &lt;h1&gt; sdfs&lt;span&gt;sd&lt;/span&gt;&lt;/h1&gt;
console.log(htmlEscape);

htmlUnEscape 的使用方法 (对特殊字符 进行还原)

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

const text = "&lt;h1&gt; sdfs&lt;span&gt;sd&lt;/span&gt;&lt;/h1&gt;";

const htmlUnEscape = tools.htmlUnEscape(text);

// 结果是 <h1> sdfs<span>sd</span></h1>
console.log(htmlUnEscape);