@zelgadis87/utils-core 4.8.0 → 4.9.0

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/esbuild/index.mjs CHANGED
@@ -815,6 +815,18 @@ function promiseSequence(...fns) {
815
815
  function delayPromise(duration) {
816
816
  return (result) => duration.promise().then(() => result);
817
817
  }
818
+ var TimeoutError = class extends Error {
819
+ };
820
+ async function awaitAtMost(p, t) {
821
+ return Promise.race([
822
+ p.then((value) => ({ status: "ok", value })),
823
+ t.promise().then(() => ({ status: "timeout" }))
824
+ ]).then(({ status, value }) => {
825
+ if (status === "ok")
826
+ return value;
827
+ throw new TimeoutError();
828
+ });
829
+ }
818
830
 
819
831
  // src/utils/random.ts
820
832
  var randomInterval = (min2, max2) => randomNumberInInterval(min2, max2);
@@ -2695,12 +2707,14 @@ export {
2695
2707
  TimeInstant,
2696
2708
  TimeRange,
2697
2709
  TimeUnit,
2710
+ TimeoutError,
2698
2711
  alwaysFalse,
2699
2712
  alwaysTrue,
2700
2713
  and,
2701
2714
  asError,
2702
2715
  asPromise,
2703
2716
  average,
2717
+ awaitAtMost,
2704
2718
  capitalizeWord,
2705
2719
  clamp,
2706
2720
  constant,