From 9d6e7a75f8b49284fbdab83fe984f7db76ffa42c Mon Sep 17 00:00:00 2001 From: hyper Date: Fri, 10 Apr 2026 12:34:47 +0800 Subject: [PATCH] refactor: add export for createPart --- src/core/part-factory.ts | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/core/part-factory.ts b/src/core/part-factory.ts index 94d0ac2..ce20c03 100644 --- a/src/core/part-factory.ts +++ b/src/core/part-factory.ts @@ -7,12 +7,7 @@ export function createPartsFromTable(items: readonly T[], getId: (item: T, in const count = getCount ? (typeof getCount === 'function' ? getCount(entry) : getCount) : 1; for (let i = 0; i < count; i++) { const id = getId(entry, i); - pool[id] = { - id, - regionId: '', - position: [], - ...entry as Immutable - }; + pool[id] = createPart(id, entry); } } return pool; @@ -20,4 +15,13 @@ export function createPartsFromTable(items: readonly T[], getId: (item: T, in export function createParts(item: T, getId: (index: number) => string, count?: number){ return createPartsFromTable([item], (_,index) => getId(index), count); +} + +export function createPart(id: string, entry: T): Part { + return { + id, + regionId: '', + position: [], + ...entry as Immutable + } } \ No newline at end of file