파일 이식(0.31.1)

This commit is contained in:
2022-07-08 00:11:41 +09:00
parent db08cec2cb
commit 96d76a06ef
217 changed files with 29966 additions and 2 deletions
+20
View File
@@ -0,0 +1,20 @@
import type { ValuesOf } from "@/defs";
import { zip } from "lodash";
export function merge2DArrToObjectArr<T extends Record<string, unknown>>(column: (keyof T)[], list: ValuesOf<T>[][]): T[]{
const result: T[] = [];
for(const rawItem of list){
const item: Record<string, unknown> = {};
if(column.length != rawItem.length){
throw `column과 item의 길이가 같지 않습니다: ${column.length} != ${list.length}, ${JSON.stringify(item)}`;
}
for(const [key, value] of zip(column, rawItem)){
item[key as string] = value;
}
result.push(item as T);
}
return result;
}