@punks/backend-core 0.0.25 → 0.0.26

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.
@@ -6,5 +6,6 @@ export * from "./strings";
6
6
  export * from "./objects";
7
7
  export * from "./text";
8
8
  export * from "./threading";
9
+ export * from "./mappings";
9
10
  export * from "./uid";
10
11
  export { ExcelSheetDefinition, ExcelKeyTransform, ExcelColumnDefinition as ExcelRowBuilder, ExcelParseOptions, excelBuild, excelParse, } from "./xls";
@@ -0,0 +1,4 @@
1
+ export declare const mapOrThrow: <TInput, TOutput>(input: TInput, { mapper, throw: throwFn, }: {
2
+ mapper: (input: TInput) => TOutput | undefined;
3
+ throw: (input: TInput) => void;
4
+ }) => TOutput;
package/dist/esm/index.js CHANGED
@@ -323,6 +323,14 @@ function sleep(ms) {
323
323
  return new Promise((resolve) => setTimeout(resolve, ms));
324
324
  }
325
325
 
326
+ const mapOrThrow = (input, { mapper, throw: throwFn, }) => {
327
+ const output = mapper(input);
328
+ if (!output) {
329
+ return throwFn(input);
330
+ }
331
+ return output;
332
+ };
333
+
326
334
  const newUuid = () => {
327
335
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
328
336
  var r = (Math.random() * 16) | 0, v = c == "x" ? r : (r & 0x3) | 0x8;
@@ -28346,5 +28354,5 @@ const excelParse = (file, options) => {
28346
28354
  .map((x) => aggregateRow(header, x, options));
28347
28355
  };
28348
28356
 
28349
- 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, toItemsDict, toItemsMap, toMap, toTitleCase, trim$1 as trim, trimEnd, trimStart };
28357
+ 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, mapOrThrow, newUuid, notNull, notUndefined, pluralize, range, removeUndefinedProps, selectMany, sleep, sort, splitPath, toCamelCase, toDict, toItemsDict, toItemsMap, toMap, toTitleCase, trim$1 as trim, trimEnd, trimStart };
28350
28358
  //# sourceMappingURL=index.js.map