@zelgadis87/utils-core 4.9.0 → 4.11.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/dist/async/_index.d.ts +4 -0
- package/dist/index.d.ts +6 -6
- package/dist/lazy/_index.d.ts +2 -0
- package/dist/sorting/ComparisonChain.d.ts +1 -1
- package/dist/sorting/Sorter.d.ts +1 -1
- package/dist/sorting/_index.d.ts +4 -0
- package/dist/time/TimeDuration.d.ts +2 -2
- package/dist/time/TimeFrequency.d.ts +1 -1
- package/dist/time/TimeInstant.d.ts +15 -1
- package/dist/time/TimeRange.d.ts +1 -1
- package/dist/time/_index.d.ts +7 -0
- package/dist/time/types.d.ts +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/dist/upgrade/DataUpgrader.d.ts +1 -1
- package/dist/upgrade/_index.d.ts +2 -0
- package/dist/upgrade/getTransitionsPath.d.ts +1 -1
- package/dist/upgrade/types.d.ts +1 -1
- package/{src/utils/index.ts → dist/utils/_index.d.ts} +14 -16
- package/dist/utils/arrays/groupBy.d.ts +1 -1
- package/dist/utils/arrays/indexBy.d.ts +1 -1
- package/dist/utils/arrays.d.ts +1 -1
- package/dist/utils/css.d.ts +12 -6
- package/dist/utils/functions/constant.d.ts +1 -0
- package/dist/utils/functions/iff.d.ts +1 -1
- package/dist/utils/functions/pipedInvokeFromArray.d.ts +2 -0
- package/dist/utils/functions.d.ts +11 -0
- package/dist/utils/index.d.ts +1 -1
- package/dist/utils/numbers.d.ts +1 -0
- package/dist/utils/promises.d.ts +1 -0
- package/dist/utils/records/entries.d.ts +1 -1
- package/esbuild/index.cjs +60 -6
- package/esbuild/index.cjs.map +2 -2
- package/esbuild/index.mjs +55 -6
- package/esbuild/index.mjs.map +2 -2
- package/package.json +1 -1
- package/src/Logger.ts +1 -1
- package/src/async/_index.ts +7 -0
- package/src/index.ts +6 -6
- package/src/lazy/Lazy.ts +1 -1
- package/src/sorting/ComparisonChain.ts +1 -1
- package/src/sorting/Sorter.ts +1 -1
- package/src/time/TimeDuration.ts +2 -2
- package/src/time/TimeFrequency.ts +1 -1
- package/src/time/TimeInstant.ts +21 -1
- package/src/time/TimeRange.ts +1 -1
- package/src/time/_index.ts +9 -0
- package/src/time/types.ts +1 -1
- package/src/upgrade/DataUpgrader.ts +1 -2
- package/src/upgrade/getTransitionsPath.ts +1 -1
- package/src/upgrade/types.ts +1 -1
- package/src/utils/_index.ts +16 -0
- package/src/utils/arrays/groupBy.ts +1 -1
- package/src/utils/arrays/indexBy.ts +1 -1
- package/src/utils/arrays.ts +1 -1
- package/src/utils/css.ts +21 -12
- package/src/utils/functions/constant.ts +1 -0
- package/src/utils/functions/iff.ts +1 -1
- package/src/utils/functions.ts +25 -0
- package/src/utils/numbers.ts +3 -0
- package/src/utils/promises.ts +2 -1
- package/src/utils/records/entries.ts +1 -1
- package/src/async/index.ts +0 -7
- package/src/time/index.ts +0 -9
- /package/src/lazy/{index.ts → _index.ts} +0 -0
- /package/src/sorting/{index.ts → _index.ts} +0 -0
- /package/src/upgrade/{index.ts → _index.ts} +0 -0
package/esbuild/index.mjs
CHANGED
|
@@ -457,6 +457,7 @@ function identity(t) {
|
|
|
457
457
|
var constantNull = constant(null);
|
|
458
458
|
var constantTrue = constant(true);
|
|
459
459
|
var constantFalse = constant(false);
|
|
460
|
+
var constantUndefined = constant(void 0);
|
|
460
461
|
var alwaysTrue = constantTrue;
|
|
461
462
|
var alwaysFalse = constantFalse;
|
|
462
463
|
var constantZero = constant(0);
|
|
@@ -504,6 +505,20 @@ function or(...predicates) {
|
|
|
504
505
|
function xor(a, b) {
|
|
505
506
|
return (t) => a(t) !== b(t);
|
|
506
507
|
}
|
|
508
|
+
function pipedInvoke(...fns) {
|
|
509
|
+
return pipedInvokeFromArray(fns);
|
|
510
|
+
}
|
|
511
|
+
function pipedInvokeFromArray(fns) {
|
|
512
|
+
if (fns.length === 0) {
|
|
513
|
+
return identity;
|
|
514
|
+
}
|
|
515
|
+
if (fns.length === 1) {
|
|
516
|
+
return fns[0];
|
|
517
|
+
}
|
|
518
|
+
return function piped(input) {
|
|
519
|
+
return fns.reduce((prev, fn) => fn(prev), input);
|
|
520
|
+
};
|
|
521
|
+
}
|
|
507
522
|
|
|
508
523
|
// src/utils/arrays/uniqBy.ts
|
|
509
524
|
function uniq(arr) {
|
|
@@ -634,16 +649,22 @@ var semiColon = ";";
|
|
|
634
649
|
var space = " ";
|
|
635
650
|
var openBracket = "{";
|
|
636
651
|
var closeBracket = "}";
|
|
637
|
-
function cssDeclarationRulesDictionaryToCss(
|
|
652
|
+
function cssDeclarationRulesDictionaryToCss(syleDeclarationRulesForSelectorsProduceable, indent = 0) {
|
|
653
|
+
const syleDeclarationRulesForSelectors = produceableToValue(syleDeclarationRulesForSelectorsProduceable);
|
|
638
654
|
return Object.entries(syleDeclarationRulesForSelectors).map(([selector, styleDeclarationRules]) => {
|
|
639
|
-
const cssRules = cssSelectorDeclarationRulesDictionaryToCss(styleDeclarationRules);
|
|
655
|
+
const cssRules = cssSelectorDeclarationRulesDictionaryToCss(styleDeclarationRules, indent + 1);
|
|
640
656
|
if (!cssRules.length) return null;
|
|
641
|
-
return selector + space + openBracket + newLine + cssRules.
|
|
657
|
+
return repeat(tabulation, indent) + selector + space + openBracket + newLine + cssRules.join(newLine) + newLine + closeBracket;
|
|
642
658
|
}).filter(Boolean).join(newLine + newLine);
|
|
643
659
|
}
|
|
644
|
-
function cssSelectorDeclarationRulesDictionaryToCss(
|
|
645
|
-
|
|
646
|
-
|
|
660
|
+
function cssSelectorDeclarationRulesDictionaryToCss(styleDeclarationRules, indent = 0) {
|
|
661
|
+
return Object.entries(styleDeclarationRules).map(([key, value]) => {
|
|
662
|
+
if (typeof value === "string") {
|
|
663
|
+
return repeat(tabulation, indent) + pascalCaseToKebabCase(key) + colon + space + value + semiColon;
|
|
664
|
+
} else {
|
|
665
|
+
return repeat(tabulation, indent) + key + space + openBracket + newLine + cssSelectorDeclarationRulesDictionaryToCss(value, indent + 1).join(newLine) + newLine + repeat(tabulation, indent) + closeBracket;
|
|
666
|
+
}
|
|
667
|
+
});
|
|
647
668
|
}
|
|
648
669
|
function pascalCaseToKebabCase(s) {
|
|
649
670
|
return s.split(/([A-Z][a-z]*)/).filter(Boolean).map((n) => n.toLowerCase()).join("-");
|
|
@@ -787,6 +808,9 @@ function clamp(n, min2, max2) {
|
|
|
787
808
|
return n;
|
|
788
809
|
}
|
|
789
810
|
}
|
|
811
|
+
function clampInt0_100(n) {
|
|
812
|
+
return clamp(Math.round(n), 0, 100);
|
|
813
|
+
}
|
|
790
814
|
function tryToParseNumber(numberStr) {
|
|
791
815
|
return withTryCatch(() => {
|
|
792
816
|
const type = typeof ensureDefined(numberStr);
|
|
@@ -827,6 +851,8 @@ async function awaitAtMost(p, t) {
|
|
|
827
851
|
throw new TimeoutError();
|
|
828
852
|
});
|
|
829
853
|
}
|
|
854
|
+
var NEVER = new Promise((_resolve) => {
|
|
855
|
+
});
|
|
830
856
|
|
|
831
857
|
// src/utils/random.ts
|
|
832
858
|
var randomInterval = (min2, max2) => randomNumberInInterval(min2, max2);
|
|
@@ -1794,12 +1820,30 @@ var TimeInstant = class _TimeInstant extends TimeBase {
|
|
|
1794
1820
|
toDateUTC() {
|
|
1795
1821
|
return new Date(this.ms + (/* @__PURE__ */ new Date()).getTimezoneOffset() * 60 * 1e3);
|
|
1796
1822
|
}
|
|
1823
|
+
/**
|
|
1824
|
+
* @deprecated use {@link TimeInstant#isInThePast2} instead.
|
|
1825
|
+
*/
|
|
1797
1826
|
get isInThePast() {
|
|
1798
1827
|
return this.ms < Date.now();
|
|
1799
1828
|
}
|
|
1829
|
+
/**
|
|
1830
|
+
* @deprecated use {@link TimeInstant#isInTheFuture2} instead.
|
|
1831
|
+
*/
|
|
1800
1832
|
get isInTheFuture() {
|
|
1801
1833
|
return this.ms > Date.now();
|
|
1802
1834
|
}
|
|
1835
|
+
/**
|
|
1836
|
+
* @returns true if the instant is in the past, false otherwise
|
|
1837
|
+
*/
|
|
1838
|
+
isInThePast2() {
|
|
1839
|
+
return this.ms < Date.now();
|
|
1840
|
+
}
|
|
1841
|
+
/**
|
|
1842
|
+
* @returns true if the instant is in the future, false otherwise
|
|
1843
|
+
*/
|
|
1844
|
+
isInTheFuture2() {
|
|
1845
|
+
return this.ms > Date.now();
|
|
1846
|
+
}
|
|
1803
1847
|
isAfter(other) {
|
|
1804
1848
|
return this.ms > other.ms;
|
|
1805
1849
|
}
|
|
@@ -2695,6 +2739,7 @@ export {
|
|
|
2695
2739
|
Lazy,
|
|
2696
2740
|
LazyAsync,
|
|
2697
2741
|
Logger,
|
|
2742
|
+
NEVER,
|
|
2698
2743
|
Optional,
|
|
2699
2744
|
RandomTimeDuration,
|
|
2700
2745
|
RateThrottler,
|
|
@@ -2717,11 +2762,13 @@ export {
|
|
|
2717
2762
|
awaitAtMost,
|
|
2718
2763
|
capitalizeWord,
|
|
2719
2764
|
clamp,
|
|
2765
|
+
clampInt0_100,
|
|
2720
2766
|
constant,
|
|
2721
2767
|
constantFalse,
|
|
2722
2768
|
constantNull,
|
|
2723
2769
|
constantOne,
|
|
2724
2770
|
constantTrue,
|
|
2771
|
+
constantUndefined,
|
|
2725
2772
|
constantZero,
|
|
2726
2773
|
createSorterFor,
|
|
2727
2774
|
cssDeclarationRulesDictionaryToCss,
|
|
@@ -2807,6 +2854,8 @@ export {
|
|
|
2807
2854
|
padRight,
|
|
2808
2855
|
partition,
|
|
2809
2856
|
pick,
|
|
2857
|
+
pipedInvoke,
|
|
2858
|
+
pipedInvokeFromArray,
|
|
2810
2859
|
pluralize,
|
|
2811
2860
|
promiseSequence,
|
|
2812
2861
|
randomId,
|