@punks/backend-core 0.0.17 → 0.0.18

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.
@@ -1,4 +1,4 @@
1
- export declare const csvParseRaw: (rows: string[], separator: string) => string[][];
1
+ export declare const csvParseRaw: (data: string | string[] | Blob, separator: string) => Promise<string[][]>;
2
2
  export interface CsvColumnDefinition<T> {
3
3
  name: string;
4
4
  value: (item: T) => any;
package/dist/esm/index.js CHANGED
@@ -201,7 +201,18 @@ const iterate = (values, action) => {
201
201
  };
202
202
 
203
203
  const DEFAULT_DELIMITER = ";";
204
- const csvParseRaw = (rows, separator) => {
204
+ const splitRows = async (data) => {
205
+ if (typeof data === "string") {
206
+ return data.split("\n");
207
+ }
208
+ if (data instanceof Blob) {
209
+ const text = await data.text();
210
+ return await splitRows(text);
211
+ }
212
+ return data;
213
+ };
214
+ const csvParseRaw = async (data, separator) => {
215
+ const rows = await splitRows(data);
205
216
  const records = [];
206
217
  for (const row of rows) {
207
218
  const record = row.split(separator);