@punks/backend-core 0.0.70 → 0.0.73

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,6 +1,6 @@
1
1
  export * from "./array";
2
2
  export { addTime, subtractTime, floorDateToSecond, TimeUnit } from "./dates";
3
- export { CsvColumnDefinition as ColumnDefinition, CsvBuildOptions, csvBuild, csvParse, } from "./csv";
3
+ export { CsvColumnDefinition, CsvBuildOptions, csvBuild, csvParse } from "./csv";
4
4
  export { getDirectoryFilePaths } from "./files";
5
5
  export { joinPath, splitPath, ensureDirectory, getDirectoryPath, createDayPath, } from "./paths";
6
6
  export * from "./strings";
@@ -11,4 +11,4 @@ export { buildTree, TreeNodeBuilder } from "./trees";
11
11
  export * from "./mappings";
12
12
  export * from "./uid";
13
13
  export { serializeQueryString, buildUrl, deserializeQueryString, getQueryParameter, updateQueryParameters, joinUrl, } from "./urls";
14
- export { ExcelSheetDefinition, ExcelKeyTransform, ExcelColumnDefinition as ExcelRowBuilder, ExcelParseOptions, excelBuild, excelParse, } from "./xls";
14
+ export { ExcelSheetDefinition, ExcelKeyTransform, ExcelColumnDefinition, ExcelParseOptions, excelBuild, excelParse, } from "./xls";
@@ -7,3 +7,4 @@ export declare const toCamelCase: (str: string) => string;
7
7
  export declare const toTitleCase: (str: string) => string;
8
8
  export declare const ensureTailingSlash: (value: string) => string;
9
9
  export declare const ensureStartSlash: (value: string) => string;
10
+ export declare const multipleSplit: (str: string, separators: string[]) => string[];
package/dist/esm/index.js CHANGED
@@ -93,28 +93,28 @@ const notNull = (x) => {
93
93
  return x !== null;
94
94
  };
95
95
  const selectMany = (array, selector) => {
96
- return array.reduce(function (a, b) {
96
+ return (array?.reduce(function (a, b) {
97
97
  return a.concat(selector(b));
98
- }, []);
98
+ }, []) ?? []);
99
99
  };
100
100
  const flatten = (array) => selectMany(array, (x) => x);
101
101
  const distinct = (values) => {
102
- return values.filter((n, i) => values.indexOf(n) === i);
102
+ return values?.filter((n, i) => values.indexOf(n) === i) ?? [];
103
103
  };
104
104
  const distinctElements = (values, comparer) => {
105
- return values.filter((other, i, arr) => arr.findIndex((t) => comparer(t) === comparer(other)) === i);
105
+ return (values?.filter((other, i, arr) => arr.findIndex((t) => comparer(t) === comparer(other)) === i) ?? []);
106
106
  };
107
107
  const jsonDistinct = (values) => {
108
108
  return distinctElements(values, (x) => JSON.stringify(x));
109
109
  };
110
110
  const iterate = (values, action) => {
111
- values.forEach((value, index) => {
111
+ values?.forEach((value, index) => {
112
112
  action(value, values?.[index + 1], values?.[index - 1]);
113
113
  });
114
114
  };
115
115
  const groupBy = (values, keySelector) => {
116
116
  const map = new Map();
117
- values.forEach((value) => {
117
+ values?.forEach((value) => {
118
118
  const key = keySelector(value);
119
119
  const items = map.get(key) || [];
120
120
  items.push(value);
@@ -249,6 +249,15 @@ const toCamelCase = (str) => `${str[0].toLowerCase()}${str.slice(1)}`;
249
249
  const toTitleCase = (str) => `${str[0].toUpperCase()}${str.slice(1)}`;
250
250
  const ensureTailingSlash = (value) => value?.endsWith("/") ? value : value + "/";
251
251
  const ensureStartSlash = (value) => value?.startsWith("/") ? value : "/" + value;
252
+ const multipleSplit = (str, separators) => {
253
+ const escapeRegExp = (separator) => {
254
+ return separator.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string
255
+ };
256
+ const regexPattern = separators
257
+ .map((separator) => escapeRegExp(separator))
258
+ .join("|");
259
+ return str.split(new RegExp(regexPattern));
260
+ };
252
261
 
253
262
  const removeUndefinedProps = (obj, options = { recursive: false }) => {
254
263
  const { recursive } = options;
@@ -30845,7 +30854,7 @@ const excelBuild = (...sheets) => {
30845
30854
  const sheetContents = [];
30846
30855
  for (const sheet of sheets) {
30847
30856
  sheetContents.push({
30848
- name: sheet.sheetName,
30857
+ name: sheet.sheetName.substring(0, 31),
30849
30858
  data: [
30850
30859
  sheet.columns.map((x) => x.header),
30851
30860
  ...sheet.data.map((d) => Array.from(buildRow(d, sheet))),
@@ -31183,5 +31192,5 @@ const processArrayItemMove = (items, input) => {
31183
31192
  }));
31184
31193
  };
31185
31194
 
31186
- export { ConsoleLogger, DatadogLogger, ExcelKeyTransform, FileLogger, Log, LogLevel, MetaSerializationType, addTime, buildObject, buildTree, buildUrl, byField, byFieldDesc, camelToKebabCase, camelToSnakeCase, createDayPath, csvBuild, csvParse, deserializeQueryString, distinct, distinctElements, ensureDirectory, ensureStartSlash, ensureTailingSlash, excelBuild, excelParse, first, flatten, floorDateToSecond, getDirectoryFilePaths, getDirectoryPath, getQueryParameter, groupBy, indexes, isNullOrUndefined, iterate, joinPath, joinUrl, jsonDistinct, jsonSerialize, last, logMemoryUsage, mapAsync, mapOrThrow, mergeDeep, newUuid, notNull, notUndefined, pluralize, processArrayDifferences, processArrayItemMove, range, removeUndefinedProps, selectMany, serializeQueryString, sleep, sort, splitPath, subArrays, subtractTime, toArrayDict, toCamelCase, toDict, toItemsDict, toItemsMap, toMap, toTitleCase, trim$1 as trim, trimEnd, trimStart, updateQueryParameters };
31195
+ export { ConsoleLogger, DatadogLogger, ExcelKeyTransform, FileLogger, Log, LogLevel, MetaSerializationType, addTime, buildObject, buildTree, buildUrl, byField, byFieldDesc, camelToKebabCase, camelToSnakeCase, createDayPath, csvBuild, csvParse, deserializeQueryString, distinct, distinctElements, ensureDirectory, ensureStartSlash, ensureTailingSlash, excelBuild, excelParse, first, flatten, floorDateToSecond, getDirectoryFilePaths, getDirectoryPath, getQueryParameter, groupBy, indexes, isNullOrUndefined, iterate, joinPath, joinUrl, jsonDistinct, jsonSerialize, last, logMemoryUsage, mapAsync, mapOrThrow, mergeDeep, multipleSplit, newUuid, notNull, notUndefined, pluralize, processArrayDifferences, processArrayItemMove, range, removeUndefinedProps, selectMany, serializeQueryString, sleep, sort, splitPath, subArrays, subtractTime, toArrayDict, toCamelCase, toDict, toItemsDict, toItemsMap, toMap, toTitleCase, trim$1 as trim, trimEnd, trimStart, updateQueryParameters };
31187
31196
  //# sourceMappingURL=index.js.map