@punks/backend-core 0.0.74 → 0.0.76
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.
|
@@ -17,9 +17,11 @@ export declare enum ExcelKeyTransform {
|
|
|
17
17
|
Lower = "lower",
|
|
18
18
|
Upper = "upper"
|
|
19
19
|
}
|
|
20
|
+
export type ParsedExcelSheet = ReturnType<typeof parseExcelRaw>[number];
|
|
20
21
|
export type ExcelParseOptions = {
|
|
21
22
|
keysTransform?: ExcelKeyTransform;
|
|
22
23
|
sheetIndex?: number;
|
|
23
24
|
dateColumns?: string[];
|
|
25
|
+
sheetFilter?: (sheet: ParsedExcelSheet) => boolean;
|
|
24
26
|
};
|
|
25
|
-
export declare const excelParse: (file: string | ArrayBuffer, options?: ExcelParseOptions) => any
|
|
27
|
+
export declare const excelParse: (file: string | ArrayBuffer, options?: ExcelParseOptions) => any;
|
package/dist/esm/index.js
CHANGED
|
@@ -30971,12 +30971,14 @@ const aggregateRow = (header, row, options) => {
|
|
|
30971
30971
|
return record;
|
|
30972
30972
|
};
|
|
30973
30973
|
const excelParse = (file, options) => {
|
|
30974
|
-
const sheets = parseExcelRaw(file)
|
|
30975
|
-
|
|
30976
|
-
|
|
30977
|
-
|
|
30978
|
-
.
|
|
30979
|
-
|
|
30974
|
+
const sheets = parseExcelRaw(file).reduce((acc, sheet) => {
|
|
30975
|
+
if (options?.sheetFilter && !options.sheetFilter(sheet))
|
|
30976
|
+
return acc;
|
|
30977
|
+
const [header, ...rows] = sheet.data.filter((row) => isValidRow(row));
|
|
30978
|
+
acc.push(rows.map((row) => aggregateRow(header, row, options)));
|
|
30979
|
+
return acc;
|
|
30980
|
+
}, []);
|
|
30981
|
+
return sheets.length === 1 ? sheets[0] : sheets.flat();
|
|
30980
30982
|
};
|
|
30981
30983
|
|
|
30982
30984
|
const getLevelValue = (level) => {
|