# choriakiinweill_tools

[![NPM version](https://img.shields.io/npm/v/choriakiinweill_tools.svg?style=flat-square)](https://www.npmjs.com/package/choriakiinweill_tools)
[![License](https://img.shields.io/npm/l/choriakiinweill_tools.svg?style=flat-square)](https://www.npmjs.com/package/choriakiinweill_tools)

提供了格式化时间和转义HTML字符串的功能。

## 安装

```bash
npm install choriakiinweill_tools
```

## 功能

### 1. 时间格式化

将日期对象格式化为 `YYYY-MM-DD HH:mm:ss` 格式。

```javascript
const { dateFormat } = require('choriakiinweill_tools');

const formattedDate = dateFormat(new Date());
console.log(formattedDate); // 输出: 2023-10-20 14:30:25
```

### 2. HTML 转义

将 HTML 字符串中的特殊字符进行转义，防止 XSS 攻击。

```javascript
const { htmlEscape, htmlUnEscape } = require('choriakiinweill_tools');

const htmlStr = '<h1>Hello World</h1>';
const escapedStr = htmlEscape(htmlStr);
console.log(escapedStr); // 输出: &lt;h1&gt;Hello World&lt;/h1&gt;

const unescapedStr = htmlUnEscape(escapedStr);
console.log(unescapedStr); // 输出: <h1>Hello World</h1>
```

## API

### `dateFormat(dateStr)`

- `dateStr` <Date> 要格式化的日期对象
- 返回值: <String> 格式化后的日期字符串

### `htmlEscape(htmlStr)`

- `htmlStr` <String> 要转义的 HTML 字符串
- 返回值: <String> 转义后的字符串

### `htmlUnEscape(str)`

- `str` <String> 要反转义的字符串
- 返回值: <String> 反转义后的 HTML 字符串

## 许可证

ISC