# lite-ts-parser

> - 字段必须为英文字母且支持层级 例如: a.b.c.d

Latest version **11.19.11** (published 2025-02-19) · GPL-3.0 license · 0 weekly downloads

## Install

```sh
npm install lite-ts-parser
pnpm add lite-ts-parser
yarn add lite-ts-parser
bun add lite-ts-parser
```

## Health

**Score 35/100 (D)** — status: maintenance-mode.

Positive: has types; no vulnerabilities; high quality score.

Warnings: low downloads; no esm support.

Negative: stale; low maintenance score.

## Facts

| | |
|---|---|
| Version | 11.19.11 |
| Published | 2025-02-19 |
| First published | 2023-02-09 |
| Weekly downloads | 0 |
| License | GPL-3.0 |
| TypeScript types | bundled |
| Module format | CommonJS |
| Dependencies | 3 |
| Unpacked size | 72.1 KB |
| Known vulnerabilities | 0 (+2 in 1 direct dependencies) |
| Install scripts | no |
| Author | ahl5esoft |
| Maintainers | ahl5esoft |
| Keywords | parser, ts |

## Links

- npm: https://www.npmjs.com/package/lite-ts-parser
- npm.io page: https://npm.io/package/lite-ts-parser

## Dependencies (3)

- [xlsx](https://npm.io/package/xlsx.md) ^0.18.5
- [moment](https://npm.io/package/moment.md) ^2.30.1
- [lite-ts](https://npm.io/package/lite-ts.md) ^11.32.9

## Alternatives

- [babylon](https://npm.io/package/babylon.md) — 5.1M weekly downloads
- [csscolorparser](https://npm.io/package/csscolorparser.md) — 3.7M weekly downloads
- [expr-eval-fork](https://npm.io/package/expr-eval-fork.md) — 1.5M weekly downloads
- [@leeoniya/ufuzzy](https://npm.io/package/@leeoniya/ufuzzy.md) — 247.7K weekly downloads
- [xml-parser](https://npm.io/package/xml-parser.md) — 78.4K weekly downloads

## Recent versions

- 11.19.11 (latest) — 2025-02-19
- 11.18.11 — 2024-10-19
- 11.17.11 — 2024-07-16
- 11.16.11 — 2024-07-09
- 11.15.11 — 2024-04-19
- 11.14.11 — 2024-04-16
- 11.14.10 — 2024-04-16
- 11.14.9 — 2024-03-25
- 11.14.8 — 2024-03-22
- 11.13.8 — 2023-11-29
- 11.13.7 — 2023-11-29
- 11.13.6 — 2023-11-29
- 11.12.6 — 2023-11-20
- 11.12.5 — 2023-11-20
- 11.11.5 — 2023-11-20
- … 19 more at https://npm.io/package/lite-ts-parser/versions

## README

# ![Version](https://img.shields.io/badge/version-11.19.11-green.svg)

## 规范
  
- 字段必须为英文字母且支持层级 例如: a.b.c.d

## 页签

- 页签名必须与程序定义的类名一致

## 单元格

* 当单元格不包含`:类型`或只有`字段:`时 则表示该列仅作为显示 不会导入

### 字段名:array.子类型[.正则]

* 奖励数组(Reward\[]\[])

| 字段名:array:rewards.\n\n\n |
| :-: |
| 字段说明 |
| 支付余额\*1\*11<br/><br/>支付余额\*2*22<br/><br/><br/>支付余额\*3\*33 |

```typescript
[{
    字段名: [
        [
            [{
                count: 1,
                valueType: 4,
                weight: 11,
            }],
            [{
                count: 2,
                valueType: 4,
                weight: 22,
            }],
        ],
        [
            [{
                count: 3,
                valueType: 4,
                weight: 33,
            }],
        ]
    ]
}]
```

* 数值数组(Value[])

| 字段名:array:value |
| :-: |
| 字段说明 |
| 支付余额\*1<br/>支付余额\*2<br/>支付余额\*3 |

```typescript
[{
    字段名: [{
        count: 1,
        valueType: 4,
    },
    {
        count: 2,
        valueType: 4,
    },
    {
        count: 3,
        valueType: 4,
    }],
}]
```

* 枚举名数组

| 字段名:array:config.enum.config.ValueTypeData.text |
| :-: |
| 字段说明 |
| 支付余额<br/>支付余额 |

```typescript
[{
    字段名: [4, 4],
}]
```

### 字段名:bool

| 字段名:bool |
| :-: |
| 字段说明 |
| TRUE |

```typescript
[{
    字段名: true
}]
```

### 字段:enum:应用.枚举名[.字段(默认value)]

| 字段名:enum:config.ValueTypeData.text |
| :-: |
| 字段说明 |
| 支付余额 |

```typescript
[{
    字段名: 4
}]
```

### 字段名:json

| 字段名:json |
| :-: |
| 字段说明 |
| [1,2] |

```typescript
[{
    字段名: [1,2]
}]
```

### 字段名:number

| 字段名:number |
| :-: |
| 字段说明 |
| 100 |

```typescript
[{
    字段名: 100
}]
```

### 字段名:rewards

| 字段名:rewards |
| :-: |
| 字段说明 |
| 支付余额\*100\*1<br/>支付余额\*10\*99<br/><br/>支付余额*99 |

```typescript
// 支付余额编号: 1
[{
    字段名: [
        [{
            count: 100,
            valueType: 4,
            weight: 1,
        }, {
            count: 10,
            valueType: 4,
            weight: 99,
        }],
        [{
            count: 99,
            valueType: 4,
        }],
    ]
}]
```

### 字段名:string

| 字段名:string |
| :-: |
| 字段说明 |
| aa |

```typescript
[{
    字段名: "aa"
}]
```

### 字段名:unix

| 字段名:unix |
| :-: |
| 字段说明 |
| 2022-12-09 |

```typescript
[{
    字段名: 1670515200
}]
```

### 字段名:value

| 字段名:value |
| :-: |
| 字段说明 |
| 支付余额*99 |

```typescript
[{
    字段名: {
        count: 99,
        valueType: 4,
    }
}]
```

### 字段名:valueConditions

| 字段名:valueConditions |
| :-: |
| 字段说明 |
| 支付余额>=9<br/>支付余额<100<br/><br/>支付余额=1000 |

```typescript
[{
    字段名: [
        [{
            count: 9,
            op: '>=',
            valueType: 4,
        }, {
            count: 100,
            op: '<',
            valueType: 4,
        }],
        [{
            count: 1000,
            op: '=',
            valueType: 4,
        }],
    ]
}]
```

### 字段名:#:页签.筛选字段

* A页签

| xx:#:aa.no |
| :-: |
| 字段说明 |
| 1 |

* aa页签

| no:int | text:string |
| :-: | :-: |
| 编号 | 文本 |
| 1 | 你好 |
| 1 | 欢迎 |

```typescript
[{
    xx: [{
        text: '你好'
    }, {
        text: '欢迎'
    }]
}]
```

### \[字段名]:类型

| value:number | a.\[b]:string | a.b.c:number | a.b.d:bool |
| :-: | :-: | :-: | :-: |
| 编号 | 键 | 数字值 | 布尔值 |
| 1 | aa | 11 | false |
| 1 | bb | 22 | true |

```typescript
[{
    value: 1,
    a: {
        aa: {
            c: 11,
            d: false,
        },
        bb: {
            c: 22,
            d: true
        }
    }
}]
```

## 代码

### ParserFactoryBase - 解析工厂

```typescript
const factory: ParserFactoryBase;

const parser = facotry.build<T>('类型');
const res = await parser.parse(原始值);
// res is T
```

* ParserFactory - 默认工厂

```typescript
const enumFactory: EnumFactoryBase;
const factory: ParserFactoryBase = new ParserFactory(enumFactory, {
    // 扩展解析器
    类型: IParser,
    ...
});
```

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