refactor(array-tracer): 移除泛型默认值并重命名参数

- 移除 `T extends JsonValue = JsonValue` 中的默认类型参数
- 将接口中的 `item` 参数重命名为 `element` 以提高可读性
- 删除被注释掉的调试代码 `console.log`
This commit is contained in:
2026-03-04 14:45:57 +08:00
parent a0c0c17984
commit 5a80d653c1
+3 -5
View File
@@ -1,17 +1,17 @@
import { getTracerContext } from '../context'; import { getTracerContext } from '../context';
import type { JsonValue } from '../types'; import type { JsonValue } from '../types';
interface ArrayTracerCreateOptions<T extends JsonValue> { interface ArrayTracerCreateOptions<T> {
description?: string; description?: string;
initial?: T[]; initial?: T[];
walker?: (builder: { add: (item: T) => void }) => void; walker?: (builder: { add: (element: T) => void }) => void;
} }
interface ArrayTracerMetadata { interface ArrayTracerMetadata {
length: number; length: number;
} }
export const createArrayTracer = <T extends JsonValue = JsonValue>( export const createArrayTracer = <T extends JsonValue>(
options: ArrayTracerCreateOptions<T>, options: ArrayTracerCreateOptions<T>,
) => { ) => {
const { description, initial, walker } = options; const { description, initial, walker } = options;
@@ -37,8 +37,6 @@ export const createArrayTracer = <T extends JsonValue = JsonValue>(
return []; return [];
}; };
// console.log(_initial);
const { command } = getTracerContext(); const { command } = getTracerContext();
const validateIndex = (index: number) => { const validateIndex = (index: number) => {