@punks/backend-core 0.0.19 → 0.0.20
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.
- package/dist/cjs/index.js +13 -5
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/utils/csv.d.ts +1 -1
- package/dist/esm/index.js +13 -5
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/utils/csv.d.ts +1 -1
- package/dist/index.d.ts +1 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -220,14 +220,22 @@ const splitRows = (data) => {
|
|
|
220
220
|
}
|
|
221
221
|
return data;
|
|
222
222
|
};
|
|
223
|
-
const csvParseRaw = (data, separator) => {
|
|
223
|
+
const csvParseRaw = (data, separator = DEFAULT_DELIMITER) => {
|
|
224
224
|
const rows = splitRows(data);
|
|
225
225
|
const records = [];
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
226
|
+
if (rows.length === 0) {
|
|
227
|
+
return records;
|
|
228
|
+
}
|
|
229
|
+
const headers = rows[0].split(separator);
|
|
230
|
+
for (let i = 1; i < rows.length; i++) {
|
|
231
|
+
const values = rows[i].split(separator);
|
|
232
|
+
const record = {};
|
|
233
|
+
for (let j = 0; j < headers.length; j++) {
|
|
234
|
+
const header = headers[j];
|
|
235
|
+
const value = values[j];
|
|
236
|
+
record[header] = value;
|
|
230
237
|
}
|
|
238
|
+
records.push(record);
|
|
231
239
|
}
|
|
232
240
|
return records;
|
|
233
241
|
};
|