@zelgadis87/utils-core 4.8.0 → 4.10.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.
Files changed (59) hide show
  1. package/dist/async/_index.d.ts +4 -0
  2. package/dist/index.d.ts +6 -6
  3. package/dist/lazy/_index.d.ts +2 -0
  4. package/dist/sorting/ComparisonChain.d.ts +1 -1
  5. package/dist/sorting/Sorter.d.ts +1 -1
  6. package/dist/sorting/_index.d.ts +4 -0
  7. package/dist/time/TimeDuration.d.ts +2 -2
  8. package/dist/time/TimeFrequency.d.ts +1 -1
  9. package/dist/time/TimeInstant.d.ts +15 -1
  10. package/dist/time/TimeRange.d.ts +1 -1
  11. package/dist/time/_index.d.ts +7 -0
  12. package/dist/time/types.d.ts +1 -1
  13. package/dist/tsconfig.tsbuildinfo +1 -1
  14. package/dist/upgrade/DataUpgrader.d.ts +1 -1
  15. package/dist/upgrade/_index.d.ts +2 -0
  16. package/dist/upgrade/getTransitionsPath.d.ts +1 -1
  17. package/dist/upgrade/types.d.ts +1 -1
  18. package/{src/utils/index.ts → dist/utils/_index.d.ts} +14 -16
  19. package/dist/utils/arrays/groupBy.d.ts +1 -1
  20. package/dist/utils/arrays/indexBy.d.ts +1 -1
  21. package/dist/utils/arrays.d.ts +1 -1
  22. package/dist/utils/css.d.ts +12 -6
  23. package/dist/utils/functions/iff.d.ts +1 -1
  24. package/dist/utils/index.d.ts +1 -1
  25. package/dist/utils/promises.d.ts +3 -0
  26. package/dist/utils/records/entries.d.ts +1 -1
  27. package/esbuild/index.cjs +46 -6
  28. package/esbuild/index.cjs.map +2 -2
  29. package/esbuild/index.mjs +44 -6
  30. package/esbuild/index.mjs.map +2 -2
  31. package/package.json +1 -1
  32. package/src/Logger.ts +1 -1
  33. package/src/async/_index.ts +7 -0
  34. package/src/index.ts +6 -6
  35. package/src/lazy/Lazy.ts +1 -1
  36. package/src/sorting/ComparisonChain.ts +1 -1
  37. package/src/sorting/Sorter.ts +1 -1
  38. package/src/time/TimeDuration.ts +2 -2
  39. package/src/time/TimeFrequency.ts +1 -1
  40. package/src/time/TimeInstant.ts +21 -1
  41. package/src/time/TimeRange.ts +1 -1
  42. package/src/time/_index.ts +9 -0
  43. package/src/time/types.ts +1 -1
  44. package/src/upgrade/DataUpgrader.ts +1 -2
  45. package/src/upgrade/getTransitionsPath.ts +1 -1
  46. package/src/upgrade/types.ts +1 -1
  47. package/src/utils/_index.ts +16 -0
  48. package/src/utils/arrays/groupBy.ts +1 -1
  49. package/src/utils/arrays/indexBy.ts +1 -1
  50. package/src/utils/arrays.ts +1 -1
  51. package/src/utils/css.ts +21 -12
  52. package/src/utils/functions/iff.ts +1 -1
  53. package/src/utils/promises.ts +14 -0
  54. package/src/utils/records/entries.ts +1 -1
  55. package/src/async/index.ts +0 -7
  56. package/src/time/index.ts +0 -9
  57. /package/src/lazy/{index.ts → _index.ts} +0 -0
  58. /package/src/sorting/{index.ts → _index.ts} +0 -0
  59. /package/src/upgrade/{index.ts → _index.ts} +0 -0
package/esbuild/index.mjs CHANGED
@@ -634,16 +634,22 @@ var semiColon = ";";
634
634
  var space = " ";
635
635
  var openBracket = "{";
636
636
  var closeBracket = "}";
637
- function cssDeclarationRulesDictionaryToCss(syleDeclarationRulesForSelectors) {
637
+ function cssDeclarationRulesDictionaryToCss(syleDeclarationRulesForSelectorsProduceable, indent = 0) {
638
+ const syleDeclarationRulesForSelectors = produceableToValue(syleDeclarationRulesForSelectorsProduceable);
638
639
  return Object.entries(syleDeclarationRulesForSelectors).map(([selector, styleDeclarationRules]) => {
639
- const cssRules = cssSelectorDeclarationRulesDictionaryToCss(styleDeclarationRules);
640
+ const cssRules = cssSelectorDeclarationRulesDictionaryToCss(styleDeclarationRules, indent + 1);
640
641
  if (!cssRules.length) return null;
641
- return selector + space + openBracket + newLine + cssRules.map((rule) => tabulation + rule + semiColon).join(newLine) + newLine + closeBracket;
642
+ return repeat(tabulation, indent) + selector + space + openBracket + newLine + cssRules.join(newLine) + newLine + closeBracket;
642
643
  }).filter(Boolean).join(newLine + newLine);
643
644
  }
644
- function cssSelectorDeclarationRulesDictionaryToCss(styleDeclarationRulesProduceable) {
645
- const styleDeclarationRules = produceableToValue(styleDeclarationRulesProduceable);
646
- return Object.entries(styleDeclarationRules).map(([key, value]) => pascalCaseToKebabCase(key) + colon + space + produceableToValue(value));
645
+ function cssSelectorDeclarationRulesDictionaryToCss(styleDeclarationRules, indent = 0) {
646
+ return Object.entries(styleDeclarationRules).map(([key, value]) => {
647
+ if (typeof value === "string") {
648
+ return repeat(tabulation, indent) + pascalCaseToKebabCase(key) + colon + space + value + semiColon;
649
+ } else {
650
+ return repeat(tabulation, indent) + key + space + openBracket + newLine + cssSelectorDeclarationRulesDictionaryToCss(value, indent + 1).join(newLine) + newLine + repeat(tabulation, indent) + closeBracket;
651
+ }
652
+ });
647
653
  }
648
654
  function pascalCaseToKebabCase(s) {
649
655
  return s.split(/([A-Z][a-z]*)/).filter(Boolean).map((n) => n.toLowerCase()).join("-");
@@ -815,6 +821,18 @@ function promiseSequence(...fns) {
815
821
  function delayPromise(duration) {
816
822
  return (result) => duration.promise().then(() => result);
817
823
  }
824
+ var TimeoutError = class extends Error {
825
+ };
826
+ async function awaitAtMost(p, t) {
827
+ return Promise.race([
828
+ p.then((value) => ({ status: "ok", value })),
829
+ t.promise().then(() => ({ status: "timeout" }))
830
+ ]).then(({ status, value }) => {
831
+ if (status === "ok")
832
+ return value;
833
+ throw new TimeoutError();
834
+ });
835
+ }
818
836
 
819
837
  // src/utils/random.ts
820
838
  var randomInterval = (min2, max2) => randomNumberInInterval(min2, max2);
@@ -1782,12 +1800,30 @@ var TimeInstant = class _TimeInstant extends TimeBase {
1782
1800
  toDateUTC() {
1783
1801
  return new Date(this.ms + (/* @__PURE__ */ new Date()).getTimezoneOffset() * 60 * 1e3);
1784
1802
  }
1803
+ /**
1804
+ * @deprecated use {@link TimeInstant#isInThePast2} instead.
1805
+ */
1785
1806
  get isInThePast() {
1786
1807
  return this.ms < Date.now();
1787
1808
  }
1809
+ /**
1810
+ * @deprecated use {@link TimeInstant#isInTheFuture2} instead.
1811
+ */
1788
1812
  get isInTheFuture() {
1789
1813
  return this.ms > Date.now();
1790
1814
  }
1815
+ /**
1816
+ * @returns true if the instant is in the past, false otherwise
1817
+ */
1818
+ isInThePast2() {
1819
+ return this.ms < Date.now();
1820
+ }
1821
+ /**
1822
+ * @returns true if the instant is in the future, false otherwise
1823
+ */
1824
+ isInTheFuture2() {
1825
+ return this.ms > Date.now();
1826
+ }
1791
1827
  isAfter(other) {
1792
1828
  return this.ms > other.ms;
1793
1829
  }
@@ -2695,12 +2731,14 @@ export {
2695
2731
  TimeInstant,
2696
2732
  TimeRange,
2697
2733
  TimeUnit,
2734
+ TimeoutError,
2698
2735
  alwaysFalse,
2699
2736
  alwaysTrue,
2700
2737
  and,
2701
2738
  asError,
2702
2739
  asPromise,
2703
2740
  average,
2741
+ awaitAtMost,
2704
2742
  capitalizeWord,
2705
2743
  clamp,
2706
2744
  constant,