lesama-tools
Version:
管理时间格式化、HTMLEscape功能
37 lines (30 loc) • 944 B
Markdown
## 安装方式
```
npm install lesama-tools
```
## 导入方式
```
const lesama = require('lesama-tools')
```
## 使用方式
### 格式化时间方法
```js
// 结果 2025-03-27 14:38:25+
console.log(lesama.formatDate(new Date()))
```
### 转义HTML方法
```js
// 将html字符串转义为实体字符串
const htmlStr = '<div style="color: yellow;"><p>hello</p><span> </span></div>'
// 结果 <div style="color: yellow;"><p>hello</p><span>&nbsp;</span></div>
console.log(lesama.htmlEscape(htmlStr))
```
### 解码HTML方法
```js
// 将实体字符串转义为html字符串
const str = '<div style="color: yellow;"><p>hello</p><span>&nbsp;</span></div>'
// 结果 <div style="color: yellow;"><p>hello</p><span> </span></div>
console.log(lesama.htmlUnEscape(str))
```
## 开源协议
ISC