itxiaoyou-tools
Version:
提供了格式化时间、HTMLEscape相关的功能
38 lines (33 loc) • 923 B
Markdown
## Installation
```
npm install itxiaoyou-tools
```
## Import
```js
const itxiaoyou = require('itxiaoyou-tools')
```
## Format Time
```js
// Call dateFormat to format the time
const dt = itxiaoyou.dateFormat(new Date())
// Result: 2025-05-16 01:59:12
console.log(dt)
```
## Escape special characters in HTML
```js
// HTML string to be escaped
const htmlStr = '<h1 title="abc">这是h1标签<span>123 </span></h1>'
// Call htmlEscape method to escape
const newhtmlSrt = itxiaoyou.htmlEscape(htmlStr)
// Result: <h1 title="abc">这是h1标签<span>123&nbsp;</spangt;</h1>
console.log(newhtmlSrt)
```
## Unescape special characters in HTML
```js
// HTML string to be unescaped
const newhtmlStrs = itxiaoyou.htmlUnEscape(htmlStr)
// Result: <h1 title="abc">这是h1标签<span>123 </span></h1>
console.log(newhtmlStrs)
```
## License
ISC