# itheima-xiangqian

> 提供了格式化时间 转义html标签和还原html字符

Latest version **1.0.2** (published 2020-10-15) · ISC license · 0 weekly downloads

## Install

```sh
npm install itheima-xiangqian
pnpm add itheima-xiangqian
yarn add itheima-xiangqian
bun add itheima-xiangqian
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.2 |
| Published | 2020-10-15 |
| First published | 2020-10-15 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 0 |
| Unpacked size | 5.2 KB |
| Known vulnerabilities | 0 |
| Install scripts | no |
| Author | xiangqian |
| Maintainers | xiangqian-npm |
| Keywords | itheima, xiangqian, format |

## Links

- npm: https://www.npmjs.com/package/itheima-xiangqian
- npm.io page: https://npm.io/package/itheima-xiangqian

## Alternatives

- [mobx-react](https://npm.io/package/mobx-react.md) — 2.8M weekly downloads
- [rc-tree](https://npm.io/package/rc-tree.md) — 2.6M weekly downloads
- [@react-oauth/google](https://npm.io/package/@react-oauth/google.md) — 1.3M weekly downloads
- [@wagmi/connectors](https://npm.io/package/@wagmi/connectors.md) — 877.0K weekly downloads
- [vee-validate](https://npm.io/package/vee-validate.md) — 836.4K weekly downloads

## Recent versions

- 1.0.2 (latest) — 2020-10-15
- 1.0.1 — 2020-10-15
- 1.0.0 — 2020-10-15

## README

# 安装方式

```npm
npm install itheima-xiangqian
```

# 导入方式

```js
const xiangqian = require("itheima-xiangqian");
```

# 格式化时间

### 使用

```js
xiangqian.formatTime([log]);
```

> #### //参数：
>
> ​ log：
> ​ true： => 直接返回时间格式输出结果 （默认值是 true,可用 1 代替 true）
>
> ​ xiangqian.formatTime()
>
> ​ false：=> 不输出结果，返回一个字符串，需要常量来接收 （可用 0 代替 false）

### eg：

```js
1;
xiangqian.formatTime();
// 输出：2020年10月15日星期四10时11分25秒
2;
xiangqian.formTime(false);
// 无输出
3;
const time = xiangqian.formatTime(false);
console.log(time);
// 输出：2020年10月15日星期四10时11分25秒
```

## 转义 HTML 中的特殊字符

### 使用

```js
const str = xiangqian.htmlEscape(htmlStr, [log]);
```

> #### //参数：
>
> ​ htmlStr: => // 带转换的 HTML 字符串
>
> ​ log：
> ​ true： => 直接返回时间格式输出结果 （默认值是 true,可用 1 代替 true）
>
> ​ xiangqian.formatTime()
>
> ​ false：=> 不输出结果，返回一个字符串，需要常量来接收 （可用 0 代替 false）

### eg:

```js
// 带转换的 HTML 字符串
const htmlStr = '<h1 title="abc">这是h1标签<span>123&nbsp;</span></h1>';

// 调用 htmlEscape 方法进行转换
1;
xiangqian.htmlEscape(htmlStr, true);
// 转换的结果 &lt;h1 title=&quot;abc&quot;&gt;这是h1标签&lt;span&gt;123&amp;nbsp;&lt;/span&gt;&lt;/h1&gt;

2;
const str = xiangqian.htmlEscape(htmlStr);
console.log(str);
// 转换的结果 &lt;h1 title=&quot;abc&quot;&gt;这是h1标签&lt;span&gt;123&amp;nbsp;&lt;/span&gt;&lt;/h1&gt;
```

## 还原 HTML 中的特殊字符

```js
// 待还原的 HTML 字符串
var str = "&lt;h1 title=&quot;abc&quot;&gt;这是h1标签&lt;span&gt;123&amp;nbsp;&lt;/span&gt;&lt;/h1&gt;";

// 调用 htmlUnEscape 方法进行转换
1;
xiangqian.htmlUnEscape(str);
// 输出的结果 <h1 title="abc">这是h1标签<span>123&nbsp;</span></h1>

2;
const str2 = xiangqian.htmlUnEscape(str, false);
console.log(str2);
// 输出的结果 <h1 title="abc">这是h1标签<span>123&nbsp;</span></h1>
```

## 开源协议

## **ISC**

---
_Source: https://npm.io/package/itheima-xiangqian · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
