@punks/backend-core 0.0.17 → 0.0.19
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 +12 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/utils/csv.d.ts +2 -1
- package/dist/esm/index.js +12 -1
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/utils/csv.d.ts +2 -1
- package/dist/index.d.ts +2 -1
- package/package.json +1 -1
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
|
|
1
|
+
/// <reference types="node" />
|
|
2
|
+
export declare const csvParseRaw: (data: string | string[] | Buffer, separator: string) => string[][];
|
|
2
3
|
export interface CsvColumnDefinition<T> {
|
|
3
4
|
name: string;
|
|
4
5
|
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
|
|
204
|
+
const splitRows = (data) => {
|
|
205
|
+
if (typeof data === "string") {
|
|
206
|
+
return data.split("\n");
|
|
207
|
+
}
|
|
208
|
+
if (data instanceof Buffer) {
|
|
209
|
+
const text = data.toString("utf-8");
|
|
210
|
+
return splitRows(text);
|
|
211
|
+
}
|
|
212
|
+
return data;
|
|
213
|
+
};
|
|
214
|
+
const csvParseRaw = (data, separator) => {
|
|
215
|
+
const rows = splitRows(data);
|
|
205
216
|
const records = [];
|
|
206
217
|
for (const row of rows) {
|
|
207
218
|
const record = row.split(separator);
|