tree-processor 0.2.0 → 0.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +35 -0
- package/dist/stats.html +1 -1
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -235,6 +235,41 @@ const fieldNames = { children: 'subNodes', id: 'nodeId' };
|
|
|
235
235
|
const result = t.findTree(treeData, (item) => item.nodeId === 2, fieldNames);
|
|
236
236
|
```
|
|
237
237
|
|
|
238
|
+
## 测试
|
|
239
|
+
|
|
240
|
+
项目包含 **73 个测试用例**,覆盖了各种场景和边界情况:
|
|
241
|
+
|
|
242
|
+
### 测试覆盖范围
|
|
243
|
+
|
|
244
|
+
- ✅ **基础功能测试** - 所有 13 个核心方法的正常使用场景
|
|
245
|
+
- ✅ **边界情况测试** - 空数据、单节点、深层嵌套等
|
|
246
|
+
- ✅ **异常处理测试** - children 字段为 null/undefined/非数组等情况
|
|
247
|
+
- ✅ **索引边界测试** - 负数索引、超出范围、空路径等
|
|
248
|
+
- ✅ **复杂场景测试** - 多根节点、数据修改、组合操作等
|
|
249
|
+
- ✅ **自定义字段名测试** - 各种自定义字段名的使用场景
|
|
250
|
+
- ✅ **特殊值处理测试** - id 为 0、false、字符串等特殊情况
|
|
251
|
+
- ✅ **去重功能测试** - 嵌套重复、null/undefined 值去重等
|
|
252
|
+
|
|
253
|
+
### 运行测试
|
|
254
|
+
|
|
255
|
+
```bash
|
|
256
|
+
# 运行所有测试
|
|
257
|
+
npm test
|
|
258
|
+
|
|
259
|
+
# 运行测试并生成覆盖率报告
|
|
260
|
+
npm run test:coverage
|
|
261
|
+
|
|
262
|
+
# 运行测试(单次,不监听文件变化)
|
|
263
|
+
npm test -- --run
|
|
264
|
+
```
|
|
265
|
+
|
|
266
|
+
### 测试统计
|
|
267
|
+
|
|
268
|
+
- **测试文件**: 2 个(功能测试 + 导入测试)
|
|
269
|
+
- **测试用例**: 73 个
|
|
270
|
+
- **测试框架**: Vitest
|
|
271
|
+
- **覆盖率**: 包含边界情况和复杂场景的全面测试
|
|
272
|
+
|
|
238
273
|
## 开发
|
|
239
274
|
|
|
240
275
|
```bash
|
package/dist/stats.html
CHANGED
|
@@ -4929,7 +4929,7 @@ var drawChart = (function (exports) {
|
|
|
4929
4929
|
</script>
|
|
4930
4930
|
<script>
|
|
4931
4931
|
/*<!--*/
|
|
4932
|
-
const data = {"version":2,"tree":{"name":"root","children":[{"name":"tree-processor.
|
|
4932
|
+
const data = {"version":2,"tree":{"name":"root","children":[{"name":"tree-processor.umd.js","children":[{"name":"src/index.ts","uid":"ba49a412-1"}]}],"isRoot":true},"nodeParts":{"ba49a412-1":{"renderedLength":9165,"gzipLength":1358,"brotliLength":1184,"metaUid":"ba49a412-0"}},"nodeMetas":{"ba49a412-0":{"id":"\\src\\index.ts","moduleParts":{"tree-processor.umd.js":"ba49a412-1"},"imported":[],"importedBy":[],"isEntry":true}},"env":{"rollup":"4.56.0"},"options":{"gzip":true,"brotli":true,"sourcemap":false}};
|
|
4933
4933
|
|
|
4934
4934
|
const run = () => {
|
|
4935
4935
|
const width = window.innerWidth;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "tree-processor",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"description": "A lightweight TypeScript library for processing tree-structured data with array-like methods (map, filter, find, push, pop, etc.), supporting tree-shaking and custom field names",
|
|
5
5
|
"main": "dist/tree-processor.cjs.js",
|
|
6
6
|
"module": "dist/tree-processor.esm.js",
|