## 安装
```
npm install itheima-tools
```



## 导入
```js
const itheima = require('itheima-tools') //导入时，路径的名字就是安装包时的名字
```



##  格式化时间
``` js
//调用dateFormat方法，将当前时间格式化，格式化成自己设置的样子
const dt = new Date()  //得到当前的时间
const result = itheima.dateFormat(dt)
//输出结果2022-09-03 17:50:37
console.log(result);
```


## 转义HTML中的特殊字符
```js
const htmlStr = '<h1 title="abc">这是h1标签<span>123&nbsp</span></h1>'  //要转换的HTML字符
const str = itheima.htmlEscape(htmlStr)//调用htmlEscape方法进行转换，把带有<>"&转换为特殊字符
console.log(str);//输出结果&lth1 title=&quotabc&quot&gt这是h1标签&ltspan&gt123&ampnbsp&lt/span&gt&lt/h1&gt
```



##  还原HTML中的特殊字符
```js 
const str2 = itheima.htmlUnEscape(str)//调用htmlUnEscpae方法，将特殊字符还原为HTML标签字符
console.log(str2);//输出结果<h1 title="abc">这是h1标签<span>123&nbsp</span></h1>
```


## 开源协议
ISC


