@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.
package/dist/cjs/index.js CHANGED
@@ -332,6 +332,14 @@ function sleep(ms) {
332
332
  return new Promise((resolve) => setTimeout(resolve, ms));
333
333
  }
334
334
 
335
+ const mapOrThrow = (input, { mapper, throw: throwFn, }) => {
336
+ const output = mapper(input);
337
+ if (!output) {
338
+ return throwFn(input);
339
+ }
340
+ return output;
341
+ };
342
+
335
343
  const newUuid = () => {
336
344
  return "xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx".replace(/[xy]/g, function (c) {
337
345
  var r = (Math.random() * 16) | 0, v = c == "x" ? r : (r & 0x3) | 0x8;
@@ -28379,6 +28387,7 @@ exports.iterate = iterate;
28379
28387
  exports.joinPath = joinPath;
28380
28388
  exports.jsonDistinct = jsonDistinct;
28381
28389
  exports.last = last;
28390
+ exports.mapOrThrow = mapOrThrow;
28382
28391
  exports.newUuid = newUuid;
28383
28392
  exports.notNull = notNull;
28384
28393
  exports.notUndefined = notUndefined;