@punks/backend-core 0.0.19 → 0.0.21
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 +14 -6
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/utils/csv.d.ts +1 -1
- package/dist/cjs/types/utils/index.d.ts +1 -1
- package/dist/esm/index.js +14 -6
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/utils/csv.d.ts +1 -1
- package/dist/esm/types/utils/index.d.ts +1 -1
- package/dist/index.d.ts +2 -2
- package/package.json +1 -1
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
/// <reference types="node" />
|
|
2
|
-
export declare const
|
|
2
|
+
export declare const csvParse: (data: string | string[] | Buffer, separator?: string) => Record<string, any>[];
|
|
3
3
|
export interface CsvColumnDefinition<T> {
|
|
4
4
|
name: string;
|
|
5
5
|
value: (item: T) => any;
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export * from "./array";
|
|
2
|
-
export { CsvColumnDefinition as ColumnDefinition, CsvBuildOptions, csvBuild,
|
|
2
|
+
export { CsvColumnDefinition as ColumnDefinition, CsvBuildOptions, csvBuild, csvParse, } from "./csv";
|
|
3
3
|
export { getDirectoryFilePaths } from "./files";
|
|
4
4
|
export { joinPath, splitPath, ensureDirectory, getDirectoryPath } from "./paths";
|
|
5
5
|
export * from "./strings";
|
package/dist/esm/index.js
CHANGED
|
@@ -211,14 +211,22 @@ const splitRows = (data) => {
|
|
|
211
211
|
}
|
|
212
212
|
return data;
|
|
213
213
|
};
|
|
214
|
-
const
|
|
214
|
+
const csvParse = (data, separator = DEFAULT_DELIMITER) => {
|
|
215
215
|
const rows = splitRows(data);
|
|
216
216
|
const records = [];
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
217
|
+
if (rows.length === 0) {
|
|
218
|
+
return records;
|
|
219
|
+
}
|
|
220
|
+
const headers = rows[0].split(separator);
|
|
221
|
+
for (let i = 1; i < rows.length; i++) {
|
|
222
|
+
const values = rows[i].split(separator);
|
|
223
|
+
const record = {};
|
|
224
|
+
for (let j = 0; j < headers.length; j++) {
|
|
225
|
+
const header = headers[j];
|
|
226
|
+
const value = values[j];
|
|
227
|
+
record[header] = value;
|
|
221
228
|
}
|
|
229
|
+
records.push(record);
|
|
222
230
|
}
|
|
223
231
|
return records;
|
|
224
232
|
};
|
|
@@ -28326,5 +28334,5 @@ const excelParse = (file, options) => {
|
|
|
28326
28334
|
.map((x) => aggregateRow(header, x, options));
|
|
28327
28335
|
};
|
|
28328
28336
|
|
|
28329
|
-
export { ExcelKeyTransform, Log, LogLevel, byField, byFieldDesc, camelToKebabCase, camelToSnakeCase, csvBuild,
|
|
28337
|
+
export { ExcelKeyTransform, Log, LogLevel, byField, byFieldDesc, camelToKebabCase, camelToSnakeCase, csvBuild, csvParse, distinct, distinctElements, ensureDirectory, ensureStartSlash, ensureTailingSlash, excelBuild, excelParse, first, flatten, getDirectoryFilePaths, getDirectoryPath, indexes, isNullOrUndefined, iterate, joinPath, jsonDistinct, last, newUuid, notNull, notUndefined, pluralize, range, removeUndefinedProps, selectMany, sleep, sort, splitPath, toCamelCase, toDict, toMap, toTitleCase, trim$1 as trim, trimEnd, trimStart };
|
|
28330
28338
|
//# sourceMappingURL=index.js.map
|