refactor: add export for createPart
This commit is contained in:
parent
3d5a484e52
commit
9d6e7a75f8
|
|
@ -7,12 +7,7 @@ export function createPartsFromTable<T>(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<T>
|
||||
};
|
||||
pool[id] = createPart(id, entry);
|
||||
}
|
||||
}
|
||||
return pool;
|
||||
|
|
@ -21,3 +16,12 @@ export function createPartsFromTable<T>(items: readonly T[], getId: (item: T, in
|
|||
export function createParts<T>(item: T, getId: (index: number) => string, count?: number){
|
||||
return createPartsFromTable([item], (_,index) => getId(index), count);
|
||||
}
|
||||
|
||||
export function createPart<T>(id: string, entry: T): Part<T> {
|
||||
return {
|
||||
id,
|
||||
regionId: '',
|
||||
position: [],
|
||||
...entry as Immutable<T>
|
||||
}
|
||||
}
|
||||
Loading…
Reference in New Issue