@punks/backend-core 0.0.16 → 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.
- package/dist/cjs/index.js +16 -1
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/utils/csv.d.ts +1 -1
- package/dist/cjs/types/utils/strings.d.ts +2 -0
- package/dist/esm/index.js +15 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/utils/csv.d.ts +1 -1
- package/dist/esm/types/utils/strings.d.ts +2 -0
- package/dist/index.d.ts +4 -2
- package/package.json +1 -1
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export declare const csvParseRaw: (
|
|
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;
|
|
@@ -5,3 +5,5 @@ export declare const camelToSnakeCase: (str: string) => string;
|
|
|
5
5
|
export declare const camelToKebabCase: (str: string) => string;
|
|
6
6
|
export declare const toCamelCase: (str: string) => string;
|
|
7
7
|
export declare const toTitleCase: (str: string) => string;
|
|
8
|
+
export declare const ensureTailingSlash: (value: string) => string;
|
|
9
|
+
export declare const ensureStartSlash: (value: string) => string;
|
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 = 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);
|
|
@@ -259,6 +270,8 @@ const camelToSnakeCase = (str) => trimStart(str.replace(/[A-Z]/g, (letter) => `_
|
|
|
259
270
|
const camelToKebabCase = (str) => trimStart(str.replace(/[A-Z]/g, (letter) => `-${letter.toLowerCase()}`), "-");
|
|
260
271
|
const toCamelCase = (str) => `${str[0].toLowerCase()}${str.slice(1)}`;
|
|
261
272
|
const toTitleCase = (str) => `${str[0].toUpperCase()}${str.slice(1)}`;
|
|
273
|
+
const ensureTailingSlash = (value) => value?.endsWith("/") ? value : value + "/";
|
|
274
|
+
const ensureStartSlash = (value) => value?.startsWith("/") ? value : "/" + value;
|
|
262
275
|
|
|
263
276
|
const removeUndefinedProps = (obj, options = { recursive: false }) => {
|
|
264
277
|
const { recursive } = options;
|
|
@@ -28313,5 +28326,5 @@ const excelParse = (file, options) => {
|
|
|
28313
28326
|
.map((x) => aggregateRow(header, x, options));
|
|
28314
28327
|
};
|
|
28315
28328
|
|
|
28316
|
-
export { ExcelKeyTransform, Log, LogLevel, byField, byFieldDesc, camelToKebabCase, camelToSnakeCase, csvBuild, csvParseRaw, distinct, distinctElements, ensureDirectory, 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 };
|
|
28329
|
+
export { ExcelKeyTransform, Log, LogLevel, byField, byFieldDesc, camelToKebabCase, camelToSnakeCase, csvBuild, csvParseRaw, 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 };
|
|
28317
28330
|
//# sourceMappingURL=index.js.map
|