@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.
- package/dist/cjs/index.js +17 -7
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/types/utils/index.d.ts +2 -2
- package/dist/cjs/types/utils/strings.d.ts +1 -0
- package/dist/esm/index.js +17 -8
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/types/utils/index.d.ts +2 -2
- package/dist/esm/types/utils/strings.d.ts +1 -0
- package/dist/index.d.ts +2 -1
- package/package.json +1 -1
package/dist/cjs/index.js
CHANGED
|
@@ -121,28 +121,28 @@ const notNull = (x) => {
|
|
|
121
121
|
return x !== null;
|
|
122
122
|
};
|
|
123
123
|
const selectMany = (array, selector) => {
|
|
124
|
-
return array
|
|
124
|
+
return (array?.reduce(function (a, b) {
|
|
125
125
|
return a.concat(selector(b));
|
|
126
|
-
}, []);
|
|
126
|
+
}, []) ?? []);
|
|
127
127
|
};
|
|
128
128
|
const flatten = (array) => selectMany(array, (x) => x);
|
|
129
129
|
const distinct = (values) => {
|
|
130
|
-
return values
|
|
130
|
+
return values?.filter((n, i) => values.indexOf(n) === i) ?? [];
|
|
131
131
|
};
|
|
132
132
|
const distinctElements = (values, comparer) => {
|
|
133
|
-
return values
|
|
133
|
+
return (values?.filter((other, i, arr) => arr.findIndex((t) => comparer(t) === comparer(other)) === i) ?? []);
|
|
134
134
|
};
|
|
135
135
|
const jsonDistinct = (values) => {
|
|
136
136
|
return distinctElements(values, (x) => JSON.stringify(x));
|
|
137
137
|
};
|
|
138
138
|
const iterate = (values, action) => {
|
|
139
|
-
values
|
|
139
|
+
values?.forEach((value, index) => {
|
|
140
140
|
action(value, values?.[index + 1], values?.[index - 1]);
|
|
141
141
|
});
|
|
142
142
|
};
|
|
143
143
|
const groupBy = (values, keySelector) => {
|
|
144
144
|
const map = new Map();
|
|
145
|
-
values
|
|
145
|
+
values?.forEach((value) => {
|
|
146
146
|
const key = keySelector(value);
|
|
147
147
|
const items = map.get(key) || [];
|
|
148
148
|
items.push(value);
|
|
@@ -277,6 +277,15 @@ const toCamelCase = (str) => `${str[0].toLowerCase()}${str.slice(1)}`;
|
|
|
277
277
|
const toTitleCase = (str) => `${str[0].toUpperCase()}${str.slice(1)}`;
|
|
278
278
|
const ensureTailingSlash = (value) => value?.endsWith("/") ? value : value + "/";
|
|
279
279
|
const ensureStartSlash = (value) => value?.startsWith("/") ? value : "/" + value;
|
|
280
|
+
const multipleSplit = (str, separators) => {
|
|
281
|
+
const escapeRegExp = (separator) => {
|
|
282
|
+
return separator.replace(/[.*+?^${}()|[\]\\]/g, "\\$&"); // $& means the whole matched string
|
|
283
|
+
};
|
|
284
|
+
const regexPattern = separators
|
|
285
|
+
.map((separator) => escapeRegExp(separator))
|
|
286
|
+
.join("|");
|
|
287
|
+
return str.split(new RegExp(regexPattern));
|
|
288
|
+
};
|
|
280
289
|
|
|
281
290
|
const removeUndefinedProps = (obj, options = { recursive: false }) => {
|
|
282
291
|
const { recursive } = options;
|
|
@@ -30873,7 +30882,7 @@ const excelBuild = (...sheets) => {
|
|
|
30873
30882
|
const sheetContents = [];
|
|
30874
30883
|
for (const sheet of sheets) {
|
|
30875
30884
|
sheetContents.push({
|
|
30876
|
-
name: sheet.sheetName,
|
|
30885
|
+
name: sheet.sheetName.substring(0, 31),
|
|
30877
30886
|
data: [
|
|
30878
30887
|
sheet.columns.map((x) => x.header),
|
|
30879
30888
|
...sheet.data.map((d) => Array.from(buildRow(d, sheet))),
|
|
@@ -31253,6 +31262,7 @@ exports.logMemoryUsage = logMemoryUsage;
|
|
|
31253
31262
|
exports.mapAsync = mapAsync;
|
|
31254
31263
|
exports.mapOrThrow = mapOrThrow;
|
|
31255
31264
|
exports.mergeDeep = mergeDeep;
|
|
31265
|
+
exports.multipleSplit = multipleSplit;
|
|
31256
31266
|
exports.newUuid = newUuid;
|
|
31257
31267
|
exports.notNull = notNull;
|
|
31258
31268
|
exports.notUndefined = notUndefined;
|