@dereekb/util 11.0.21 → 11.1.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/fetch/index.cjs.js +2 -2
- package/fetch/index.esm.js +3 -3
- package/fetch/package.json +1 -1
- package/index.cjs.js +514 -344
- package/index.esm.js +535 -340
- package/package.json +1 -1
- package/src/lib/array/array.d.ts +7 -0
- package/src/lib/array/array.number.d.ts +15 -5
- package/src/lib/array/array.value.d.ts +26 -2
- package/src/lib/number/bitwise.dencoder.d.ts +3 -0
- package/src/lib/object/object.d.ts +5 -1
- package/src/lib/object/object.equal.d.ts +7 -0
- package/src/lib/object/object.filter.pojo.d.ts +14 -1
- package/src/lib/object/object.map.d.ts +35 -7
- package/src/lib/string/string.d.ts +22 -0
- package/src/lib/value/indexed.d.ts +16 -1
- package/src/lib/value/maybe.d.ts +11 -0
- package/test/CHANGELOG.md +4 -0
- package/test/package.json +1 -1
package/index.cjs.js
CHANGED
|
@@ -1627,213 +1627,6 @@ $$h({ target: 'Array', proto: true, forced: FORCED$2 }, {
|
|
|
1627
1627
|
}
|
|
1628
1628
|
});
|
|
1629
1629
|
|
|
1630
|
-
// MARK: Functions
|
|
1631
|
-
/**
|
|
1632
|
-
* Converts the input value to an array containing itself, or returns itself if it is an array.
|
|
1633
|
-
*
|
|
1634
|
-
* @param arrayOrValue
|
|
1635
|
-
* @returns
|
|
1636
|
-
*/
|
|
1637
|
-
function convertMaybeToArray(arrayOrValue) {
|
|
1638
|
-
if (arrayOrValue != null) {
|
|
1639
|
-
return convertToArray(arrayOrValue);
|
|
1640
|
-
} else {
|
|
1641
|
-
return [];
|
|
1642
|
-
}
|
|
1643
|
-
}
|
|
1644
|
-
const asArray = convertMaybeToArray;
|
|
1645
|
-
/**
|
|
1646
|
-
* Converts the input value to an array containing itself, or returns itself if it is an array.
|
|
1647
|
-
*
|
|
1648
|
-
* @param arrayOrValue
|
|
1649
|
-
* @returns
|
|
1650
|
-
*/
|
|
1651
|
-
function convertToArray(arrayOrValue) {
|
|
1652
|
-
return Array.isArray(arrayOrValue) ? arrayOrValue : [arrayOrValue];
|
|
1653
|
-
}
|
|
1654
|
-
/**
|
|
1655
|
-
* Returns the first value from the array.
|
|
1656
|
-
*/
|
|
1657
|
-
function firstValue(input) {
|
|
1658
|
-
return valueAtIndex(input, 0);
|
|
1659
|
-
}
|
|
1660
|
-
/**
|
|
1661
|
-
* Returns the last value from the array.
|
|
1662
|
-
*/
|
|
1663
|
-
function lastValue(input) {
|
|
1664
|
-
if (Array.isArray(input)) {
|
|
1665
|
-
return input[input.length - 1];
|
|
1666
|
-
} else {
|
|
1667
|
-
return input;
|
|
1668
|
-
}
|
|
1669
|
-
}
|
|
1670
|
-
/**
|
|
1671
|
-
* Returns a tuple with the first and last value of the input.
|
|
1672
|
-
*
|
|
1673
|
-
* If the input is not an array, returns that value as the first and last value.
|
|
1674
|
-
*
|
|
1675
|
-
* @param input
|
|
1676
|
-
* @returns
|
|
1677
|
-
*/
|
|
1678
|
-
function firstAndLastValue(input) {
|
|
1679
|
-
const first = firstValue(input);
|
|
1680
|
-
const last = lastValue(input);
|
|
1681
|
-
return [first, last];
|
|
1682
|
-
}
|
|
1683
|
-
function valueAtIndex(input, index) {
|
|
1684
|
-
if (Array.isArray(input)) {
|
|
1685
|
-
return input[index];
|
|
1686
|
-
} else {
|
|
1687
|
-
return input;
|
|
1688
|
-
}
|
|
1689
|
-
}
|
|
1690
|
-
/**
|
|
1691
|
-
* Concatinates the input arrays and filters out falsy values.
|
|
1692
|
-
*/
|
|
1693
|
-
function concatArrays(...arrays) {
|
|
1694
|
-
return flattenArray(arrays.filter(x => Boolean(x)));
|
|
1695
|
-
}
|
|
1696
|
-
/**
|
|
1697
|
-
* Flattens a two dimensional array into a single dimensional array. Any null/undefined values from the first dimension are filtered out.
|
|
1698
|
-
*
|
|
1699
|
-
* @param array
|
|
1700
|
-
* @returns
|
|
1701
|
-
*/
|
|
1702
|
-
function flattenArray(array) {
|
|
1703
|
-
const filteredValues = array.filter(x => Boolean(x));
|
|
1704
|
-
// concat with spread is faster than a depth-one flat
|
|
1705
|
-
return [].concat(...filteredValues);
|
|
1706
|
-
}
|
|
1707
|
-
/**
|
|
1708
|
-
* Flattens an array of ArrayOrValue values into a single array.
|
|
1709
|
-
*
|
|
1710
|
-
* @param array
|
|
1711
|
-
* @returns
|
|
1712
|
-
*/
|
|
1713
|
-
function flattenArrayOrValueArray(array) {
|
|
1714
|
-
return flattenArray(array.map(x => x ? convertToArray(x) : undefined));
|
|
1715
|
-
}
|
|
1716
|
-
function copyArray(input) {
|
|
1717
|
-
return input != null ? Array.from(input) : [];
|
|
1718
|
-
}
|
|
1719
|
-
function pushElementOntoArray(target, element, times) {
|
|
1720
|
-
for (let i = 0; i < times; i += 1) {
|
|
1721
|
-
target.push(element);
|
|
1722
|
-
}
|
|
1723
|
-
return target;
|
|
1724
|
-
}
|
|
1725
|
-
/**
|
|
1726
|
-
* Merges all input arrays into a single array.
|
|
1727
|
-
*
|
|
1728
|
-
* @param arrays
|
|
1729
|
-
* @returns
|
|
1730
|
-
*/
|
|
1731
|
-
function mergeArrays(arrays) {
|
|
1732
|
-
return mergeArraysIntoArray([], ...arrays);
|
|
1733
|
-
}
|
|
1734
|
-
/**
|
|
1735
|
-
* Merges the input arrays into the target array by pushing each item from each array. Creates an empty array if the target is null/undefined.
|
|
1736
|
-
*
|
|
1737
|
-
* @param target
|
|
1738
|
-
* @param arrays
|
|
1739
|
-
* @returns
|
|
1740
|
-
*/
|
|
1741
|
-
function mergeArraysIntoArray(target, ...arrays) {
|
|
1742
|
-
if (target == null) {
|
|
1743
|
-
target = [];
|
|
1744
|
-
}
|
|
1745
|
-
arrays.forEach(array => {
|
|
1746
|
-
if (array != null) {
|
|
1747
|
-
pushArrayItemsIntoArray(target, array);
|
|
1748
|
-
}
|
|
1749
|
-
});
|
|
1750
|
-
return target;
|
|
1751
|
-
}
|
|
1752
|
-
/**
|
|
1753
|
-
* Pushes the input value into the target array if it is not an array. If it is an array, inserts all values from that array into the target array.
|
|
1754
|
-
*
|
|
1755
|
-
* @param target
|
|
1756
|
-
* @param value
|
|
1757
|
-
* @returns
|
|
1758
|
-
*/
|
|
1759
|
-
function pushItemOrArrayItemsIntoArray(target, value) {
|
|
1760
|
-
if (Array.isArray(value)) {
|
|
1761
|
-
return pushArrayItemsIntoArray(target, value);
|
|
1762
|
-
} else {
|
|
1763
|
-
target.push(value);
|
|
1764
|
-
return target;
|
|
1765
|
-
}
|
|
1766
|
-
}
|
|
1767
|
-
/**
|
|
1768
|
-
* Merges all the values from the second array into the first using push.
|
|
1769
|
-
*
|
|
1770
|
-
* This is preferable in cases where immutability is not required.
|
|
1771
|
-
*
|
|
1772
|
-
* @param target
|
|
1773
|
-
* @param array
|
|
1774
|
-
*/
|
|
1775
|
-
function pushArrayItemsIntoArray(target, array) {
|
|
1776
|
-
Array.prototype.push.apply(target, array);
|
|
1777
|
-
return target;
|
|
1778
|
-
}
|
|
1779
|
-
/**
|
|
1780
|
-
* Copies/takes the elements from the front of the array up to the max.
|
|
1781
|
-
*
|
|
1782
|
-
* @param values
|
|
1783
|
-
* @param maxToTake
|
|
1784
|
-
* @returns
|
|
1785
|
-
*/
|
|
1786
|
-
function takeFront(values, maxToTake) {
|
|
1787
|
-
return values.slice(0, maxToTake);
|
|
1788
|
-
}
|
|
1789
|
-
/**
|
|
1790
|
-
* Copies/takes as many elements as possible from the end.
|
|
1791
|
-
*
|
|
1792
|
-
* @param values Values to take from.
|
|
1793
|
-
* @param maxToTake Max number of values to take from the end of the input array.
|
|
1794
|
-
* @param keepFromFront Number of values to retain in the front of the array. These are not taken.
|
|
1795
|
-
* @returns New array with the subset of taken values.
|
|
1796
|
-
*/
|
|
1797
|
-
function takeLast(values, maxToTake, keepFromFront = 0) {
|
|
1798
|
-
let results;
|
|
1799
|
-
if (maxToTake < keepFromFront) {
|
|
1800
|
-
throw new Error('Cannot take more than keeping from front.');
|
|
1801
|
-
} else if (keepFromFront === maxToTake) {
|
|
1802
|
-
results = values.slice(0, keepFromFront);
|
|
1803
|
-
} else {
|
|
1804
|
-
const length = values.length;
|
|
1805
|
-
const secondHalfStartIndex = Math.max(keepFromFront, length - (maxToTake - keepFromFront));
|
|
1806
|
-
const secondHalfEndIndex = length;
|
|
1807
|
-
results = [...values.slice(0, keepFromFront), ...values.slice(secondHalfStartIndex, secondHalfEndIndex)];
|
|
1808
|
-
}
|
|
1809
|
-
return results;
|
|
1810
|
-
}
|
|
1811
|
-
/**
|
|
1812
|
-
* Performs forEach with the input array and returns the array.
|
|
1813
|
-
*
|
|
1814
|
-
* @param array
|
|
1815
|
-
* @param forEach
|
|
1816
|
-
* @returns
|
|
1817
|
-
*/
|
|
1818
|
-
function forEachWithArray(array, forEach) {
|
|
1819
|
-
if (array) {
|
|
1820
|
-
array = convertToArray(array);
|
|
1821
|
-
array.forEach(forEach);
|
|
1822
|
-
} else {
|
|
1823
|
-
array = [];
|
|
1824
|
-
}
|
|
1825
|
-
return array;
|
|
1826
|
-
}
|
|
1827
|
-
/**
|
|
1828
|
-
* Counts all the values in a nested array.
|
|
1829
|
-
*
|
|
1830
|
-
* @param array
|
|
1831
|
-
* @returns
|
|
1832
|
-
*/
|
|
1833
|
-
function countAllInNestedArray(array) {
|
|
1834
|
-
return array.reduce((acc, curr) => acc + curr.length, 0);
|
|
1835
|
-
}
|
|
1836
|
-
|
|
1837
1630
|
var wellKnownSymbol$d = wellKnownSymbol$k;
|
|
1838
1631
|
|
|
1839
1632
|
var TO_STRING_TAG$1 = wellKnownSymbol$d('toStringTag');
|
|
@@ -2113,66 +1906,288 @@ function existsInIterable(values, fn) {
|
|
|
2113
1906
|
return true;
|
|
2114
1907
|
}
|
|
2115
1908
|
}
|
|
2116
|
-
return false;
|
|
1909
|
+
return false;
|
|
1910
|
+
}
|
|
1911
|
+
/**
|
|
1912
|
+
* Filters values from the iterable using a DecisionFunction.
|
|
1913
|
+
*
|
|
1914
|
+
* @param values
|
|
1915
|
+
* @param fn
|
|
1916
|
+
* @returns
|
|
1917
|
+
*/
|
|
1918
|
+
function filterFromIterable(values, fn) {
|
|
1919
|
+
const keep = [];
|
|
1920
|
+
for (const value of values) {
|
|
1921
|
+
if (fn(value)) {
|
|
1922
|
+
keep.push(value);
|
|
1923
|
+
}
|
|
1924
|
+
}
|
|
1925
|
+
return keep;
|
|
1926
|
+
}
|
|
1927
|
+
/**
|
|
1928
|
+
* Wraps the input tuple values as an array. The tuples should all be the same length in order to wrap them properly, and the tuple value cannot consist of only arrays of the same length.
|
|
1929
|
+
*
|
|
1930
|
+
* This is used to prevent functions from treating the tuple itself as an array.
|
|
1931
|
+
*
|
|
1932
|
+
* @param input
|
|
1933
|
+
*/
|
|
1934
|
+
function wrapTuples(input) {
|
|
1935
|
+
if (Array.isArray(input)) {
|
|
1936
|
+
// check if the first item is an array. Tuples can contain arrays as the first value.
|
|
1937
|
+
if (input.length > 0) {
|
|
1938
|
+
const firstValueInPotentialTupleOrArray = input[0];
|
|
1939
|
+
let inputIsSingleTuple = false;
|
|
1940
|
+
if (Array.isArray(firstValueInPotentialTupleOrArray)) {
|
|
1941
|
+
// if the first nested value is an array then the top-level value may be an array and not a tuple. Check the length of all the other values in the array to see if they have the same length.
|
|
1942
|
+
const expectedLength = firstValueInPotentialTupleOrArray.length;
|
|
1943
|
+
// if it is an array of tuples, all values should be the same length and be arrays. If not an array, then we're looking at a tuple.
|
|
1944
|
+
const firstNonUniformTupleValueIndex = input.findIndex(x => {
|
|
1945
|
+
if (Array.isArray(x)) {
|
|
1946
|
+
return x.length !== expectedLength;
|
|
1947
|
+
} else {
|
|
1948
|
+
return true; // non-array value. The input is a tuple.
|
|
1949
|
+
}
|
|
1950
|
+
});
|
|
1951
|
+
|
|
1952
|
+
inputIsSingleTuple = firstNonUniformTupleValueIndex !== -1;
|
|
1953
|
+
} else {
|
|
1954
|
+
inputIsSingleTuple = true;
|
|
1955
|
+
return [input];
|
|
1956
|
+
}
|
|
1957
|
+
// first value of the tuple could also be an array. If it is, check the other tuples all have the same length.
|
|
1958
|
+
if (inputIsSingleTuple) {
|
|
1959
|
+
return [input];
|
|
1960
|
+
} else {
|
|
1961
|
+
return input;
|
|
1962
|
+
}
|
|
1963
|
+
} else {
|
|
1964
|
+
return input; // is an empty array.
|
|
1965
|
+
}
|
|
1966
|
+
} else {
|
|
1967
|
+
throw new Error('Input is not an array/tuple...');
|
|
1968
|
+
}
|
|
1969
|
+
}
|
|
1970
|
+
|
|
1971
|
+
// MARK: Functions
|
|
1972
|
+
/**
|
|
1973
|
+
* Converts the input value to an array containing itself, or returns itself if it is an array.
|
|
1974
|
+
*
|
|
1975
|
+
* @param arrayOrValue
|
|
1976
|
+
* @returns
|
|
1977
|
+
*/
|
|
1978
|
+
function convertMaybeToArray(arrayOrValue) {
|
|
1979
|
+
if (arrayOrValue != null) {
|
|
1980
|
+
return convertToArray(arrayOrValue);
|
|
1981
|
+
} else {
|
|
1982
|
+
return [];
|
|
1983
|
+
}
|
|
1984
|
+
}
|
|
1985
|
+
const asArray = convertMaybeToArray;
|
|
1986
|
+
/**
|
|
1987
|
+
* Converts the input value to an array containing itself, or returns itself if it is an array.
|
|
1988
|
+
*
|
|
1989
|
+
* @param arrayOrValue
|
|
1990
|
+
* @returns
|
|
1991
|
+
*/
|
|
1992
|
+
function convertToArray(arrayOrValue) {
|
|
1993
|
+
return Array.isArray(arrayOrValue) ? arrayOrValue : [arrayOrValue];
|
|
1994
|
+
}
|
|
1995
|
+
/**
|
|
1996
|
+
* Returns the first value from the array.
|
|
1997
|
+
*/
|
|
1998
|
+
function firstValue(input) {
|
|
1999
|
+
return valueAtIndex(input, 0);
|
|
2000
|
+
}
|
|
2001
|
+
/**
|
|
2002
|
+
* Returns the last value from the array.
|
|
2003
|
+
*/
|
|
2004
|
+
function lastValue(input) {
|
|
2005
|
+
if (Array.isArray(input)) {
|
|
2006
|
+
return input[input.length - 1];
|
|
2007
|
+
} else {
|
|
2008
|
+
return input;
|
|
2009
|
+
}
|
|
2010
|
+
}
|
|
2011
|
+
/**
|
|
2012
|
+
* Returns a tuple with the first and last value of the input.
|
|
2013
|
+
*
|
|
2014
|
+
* If the input is not an array, returns that value as the first and last value.
|
|
2015
|
+
*
|
|
2016
|
+
* @param input
|
|
2017
|
+
* @returns
|
|
2018
|
+
*/
|
|
2019
|
+
function firstAndLastValue(input) {
|
|
2020
|
+
const first = firstValue(input);
|
|
2021
|
+
const last = lastValue(input);
|
|
2022
|
+
return [first, last];
|
|
2023
|
+
}
|
|
2024
|
+
function valueAtIndex(input, index) {
|
|
2025
|
+
if (Array.isArray(input)) {
|
|
2026
|
+
return input[index];
|
|
2027
|
+
} else {
|
|
2028
|
+
return input;
|
|
2029
|
+
}
|
|
2030
|
+
}
|
|
2031
|
+
/**
|
|
2032
|
+
* Concatinates the input arrays and filters out falsy values.
|
|
2033
|
+
*/
|
|
2034
|
+
function concatArrays(...arrays) {
|
|
2035
|
+
return flattenArray(arrays.filter(x => Boolean(x)));
|
|
2036
|
+
}
|
|
2037
|
+
/**
|
|
2038
|
+
* Flattens a two dimensional array into a single dimensional array. Any null/undefined values from the first dimension are filtered out.
|
|
2039
|
+
*
|
|
2040
|
+
* @param array
|
|
2041
|
+
* @returns
|
|
2042
|
+
*/
|
|
2043
|
+
function flattenArray(array) {
|
|
2044
|
+
const filteredValues = array.filter(x => Boolean(x));
|
|
2045
|
+
// concat with spread is faster than a depth-one flat
|
|
2046
|
+
return [].concat(...filteredValues);
|
|
2047
|
+
}
|
|
2048
|
+
/**
|
|
2049
|
+
* Flattens an array of ArrayOrValue values into a single array.
|
|
2050
|
+
*
|
|
2051
|
+
* @param array
|
|
2052
|
+
* @returns
|
|
2053
|
+
*/
|
|
2054
|
+
function flattenArrayOrValueArray(array) {
|
|
2055
|
+
return flattenArray(array.map(x => x ? convertToArray(x) : undefined));
|
|
2056
|
+
}
|
|
2057
|
+
function copyArray(input) {
|
|
2058
|
+
return input != null ? Array.from(input) : [];
|
|
2059
|
+
}
|
|
2060
|
+
function pushElementOntoArray(target, element, times) {
|
|
2061
|
+
for (let i = 0; i < times; i += 1) {
|
|
2062
|
+
target.push(element);
|
|
2063
|
+
}
|
|
2064
|
+
return target;
|
|
2065
|
+
}
|
|
2066
|
+
/**
|
|
2067
|
+
* Merges all input arrays into a single array.
|
|
2068
|
+
*
|
|
2069
|
+
* @param arrays
|
|
2070
|
+
* @returns
|
|
2071
|
+
*/
|
|
2072
|
+
function mergeArrays(arrays) {
|
|
2073
|
+
return mergeArraysIntoArray([], ...arrays);
|
|
2074
|
+
}
|
|
2075
|
+
/**
|
|
2076
|
+
* Merges the input arrays into the target array by pushing each item from each array. Creates an empty array if the target is null/undefined.
|
|
2077
|
+
*
|
|
2078
|
+
* @param target
|
|
2079
|
+
* @param arrays
|
|
2080
|
+
* @returns
|
|
2081
|
+
*/
|
|
2082
|
+
function mergeArraysIntoArray(target, ...arrays) {
|
|
2083
|
+
if (target == null) {
|
|
2084
|
+
target = [];
|
|
2085
|
+
}
|
|
2086
|
+
arrays.forEach(array => {
|
|
2087
|
+
if (array != null) {
|
|
2088
|
+
pushArrayItemsIntoArray(target, array);
|
|
2089
|
+
}
|
|
2090
|
+
});
|
|
2091
|
+
return target;
|
|
2092
|
+
}
|
|
2093
|
+
/**
|
|
2094
|
+
* Pushes the input value into the target array if it is not an array. If it is an array, inserts all values from that array into the target array.
|
|
2095
|
+
*
|
|
2096
|
+
* @param target
|
|
2097
|
+
* @param value
|
|
2098
|
+
* @returns
|
|
2099
|
+
*/
|
|
2100
|
+
function pushItemOrArrayItemsIntoArray(target, value) {
|
|
2101
|
+
if (Array.isArray(value)) {
|
|
2102
|
+
return pushArrayItemsIntoArray(target, value);
|
|
2103
|
+
} else {
|
|
2104
|
+
target.push(value);
|
|
2105
|
+
return target;
|
|
2106
|
+
}
|
|
2107
|
+
}
|
|
2108
|
+
/**
|
|
2109
|
+
* Merges all the values from the second array into the first using push.
|
|
2110
|
+
*
|
|
2111
|
+
* This is preferable in cases where immutability is not required.
|
|
2112
|
+
*
|
|
2113
|
+
* @param target
|
|
2114
|
+
* @param array
|
|
2115
|
+
*/
|
|
2116
|
+
function pushArrayItemsIntoArray(target, array) {
|
|
2117
|
+
Array.prototype.push.apply(target, array);
|
|
2118
|
+
return target;
|
|
2119
|
+
}
|
|
2120
|
+
/**
|
|
2121
|
+
* Copies/takes the elements from the front of the array up to the max.
|
|
2122
|
+
*
|
|
2123
|
+
* @param values
|
|
2124
|
+
* @param maxToTake
|
|
2125
|
+
* @returns
|
|
2126
|
+
*/
|
|
2127
|
+
function takeFront(values, maxToTake) {
|
|
2128
|
+
return values.slice(0, maxToTake);
|
|
2129
|
+
}
|
|
2130
|
+
/**
|
|
2131
|
+
* Copies/takes as many elements as possible from the end.
|
|
2132
|
+
*
|
|
2133
|
+
* @param values Values to take from.
|
|
2134
|
+
* @param maxToTake Max number of values to take from the end of the input array.
|
|
2135
|
+
* @param keepFromFront Number of values to retain in the front of the array. These are not taken.
|
|
2136
|
+
* @returns New array with the subset of taken values.
|
|
2137
|
+
*/
|
|
2138
|
+
function takeLast(values, maxToTake, keepFromFront = 0) {
|
|
2139
|
+
let results;
|
|
2140
|
+
if (maxToTake < keepFromFront) {
|
|
2141
|
+
throw new Error('Cannot take more than keeping from front.');
|
|
2142
|
+
} else if (keepFromFront === maxToTake) {
|
|
2143
|
+
results = values.slice(0, keepFromFront);
|
|
2144
|
+
} else {
|
|
2145
|
+
const length = values.length;
|
|
2146
|
+
const secondHalfStartIndex = Math.max(keepFromFront, length - (maxToTake - keepFromFront));
|
|
2147
|
+
const secondHalfEndIndex = length;
|
|
2148
|
+
results = [...values.slice(0, keepFromFront), ...values.slice(secondHalfStartIndex, secondHalfEndIndex)];
|
|
2149
|
+
}
|
|
2150
|
+
return results;
|
|
2151
|
+
}
|
|
2152
|
+
/**
|
|
2153
|
+
* Performs forEach with the input array and returns the array.
|
|
2154
|
+
*
|
|
2155
|
+
* @param array
|
|
2156
|
+
* @param forEach
|
|
2157
|
+
* @returns
|
|
2158
|
+
*/
|
|
2159
|
+
function forEachWithArray(array, forEach) {
|
|
2160
|
+
if (array) {
|
|
2161
|
+
array = convertToArray(array);
|
|
2162
|
+
array.forEach(forEach);
|
|
2163
|
+
} else {
|
|
2164
|
+
array = [];
|
|
2165
|
+
}
|
|
2166
|
+
return array;
|
|
2117
2167
|
}
|
|
2118
2168
|
/**
|
|
2119
|
-
*
|
|
2169
|
+
* Counts all the values in a nested array.
|
|
2120
2170
|
*
|
|
2121
|
-
* @param
|
|
2122
|
-
* @param fn
|
|
2171
|
+
* @param array
|
|
2123
2172
|
* @returns
|
|
2124
2173
|
*/
|
|
2125
|
-
function
|
|
2126
|
-
|
|
2127
|
-
for (const value of values) {
|
|
2128
|
-
if (fn(value)) {
|
|
2129
|
-
keep.push(value);
|
|
2130
|
-
}
|
|
2131
|
-
}
|
|
2132
|
-
return keep;
|
|
2174
|
+
function countAllInNestedArray(array) {
|
|
2175
|
+
return array.reduce((acc, curr) => acc + curr.length, 0);
|
|
2133
2176
|
}
|
|
2134
2177
|
/**
|
|
2135
|
-
*
|
|
2136
|
-
*
|
|
2137
|
-
* This is used to prevent functions from treating the tuple itself as an array.
|
|
2178
|
+
* Creates a copy of the array with the items at the specified indexes removed.
|
|
2138
2179
|
*
|
|
2139
|
-
* @param
|
|
2180
|
+
* @param array
|
|
2140
2181
|
*/
|
|
2141
|
-
function
|
|
2142
|
-
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
|
|
2146
|
-
|
|
2147
|
-
if (Array.isArray(firstValueInPotentialTupleOrArray)) {
|
|
2148
|
-
// if the first nested value is an array then the top-level value may be an array and not a tuple. Check the length of all the other values in the array to see if they have the same length.
|
|
2149
|
-
const expectedLength = firstValueInPotentialTupleOrArray.length;
|
|
2150
|
-
// if it is an array of tuples, all values should be the same length and be arrays. If not an array, then we're looking at a tuple.
|
|
2151
|
-
const firstNonUniformTupleValueIndex = input.findIndex(x => {
|
|
2152
|
-
if (Array.isArray(x)) {
|
|
2153
|
-
return x.length !== expectedLength;
|
|
2154
|
-
} else {
|
|
2155
|
-
return true; // non-array value. The input is a tuple.
|
|
2156
|
-
}
|
|
2157
|
-
});
|
|
2158
|
-
|
|
2159
|
-
inputIsSingleTuple = firstNonUniformTupleValueIndex !== -1;
|
|
2160
|
-
} else {
|
|
2161
|
-
inputIsSingleTuple = true;
|
|
2162
|
-
return [input];
|
|
2163
|
-
}
|
|
2164
|
-
// first value of the tuple could also be an array. If it is, check the other tuples all have the same length.
|
|
2165
|
-
if (inputIsSingleTuple) {
|
|
2166
|
-
return [input];
|
|
2167
|
-
} else {
|
|
2168
|
-
return input;
|
|
2169
|
-
}
|
|
2170
|
-
} else {
|
|
2171
|
-
return input; // is an empty array.
|
|
2182
|
+
function removeValuesAtIndexesFromArrayCopy(array, removeIndexes) {
|
|
2183
|
+
const result = [];
|
|
2184
|
+
const ignoredIndexes = iterableToSet(removeIndexes);
|
|
2185
|
+
array.forEach((value, index) => {
|
|
2186
|
+
if (!ignoredIndexes.has(index)) {
|
|
2187
|
+
result.push(value);
|
|
2172
2188
|
}
|
|
2173
|
-
}
|
|
2174
|
-
|
|
2175
|
-
}
|
|
2189
|
+
});
|
|
2190
|
+
return result;
|
|
2176
2191
|
}
|
|
2177
2192
|
|
|
2178
2193
|
/**
|
|
@@ -2828,33 +2843,43 @@ function isSameNonNullValue(a, b) {
|
|
|
2828
2843
|
function valuesAreBothNullishOrEquivalent(a, b) {
|
|
2829
2844
|
return a != null && b != null ? a === b : a == b;
|
|
2830
2845
|
}
|
|
2846
|
+
/**
|
|
2847
|
+
* Updates "a" with "b".
|
|
2848
|
+
*
|
|
2849
|
+
* - If b is defined, then returns b
|
|
2850
|
+
* - If b is undefined, then returns a
|
|
2851
|
+
* - If b is null, then returns null
|
|
2852
|
+
*
|
|
2853
|
+
* @param a
|
|
2854
|
+
* @param b
|
|
2855
|
+
*/
|
|
2856
|
+
function updateMaybeValue(a, b) {
|
|
2857
|
+
return b === undefined ? a : b;
|
|
2858
|
+
}
|
|
2831
2859
|
|
|
2860
|
+
function filterMaybeArrayFunction(filterFn) {
|
|
2861
|
+
return values => {
|
|
2862
|
+
if (values != null) {
|
|
2863
|
+
return values.filter(filterFn);
|
|
2864
|
+
} else {
|
|
2865
|
+
return [];
|
|
2866
|
+
}
|
|
2867
|
+
};
|
|
2868
|
+
}
|
|
2832
2869
|
/**
|
|
2833
2870
|
* Filters all maybe values from the input array. If a maybe value is input, returns an empty array.
|
|
2834
2871
|
*
|
|
2835
2872
|
* @param values
|
|
2836
2873
|
* @returns
|
|
2837
2874
|
*/
|
|
2838
|
-
|
|
2839
|
-
if (values != null) {
|
|
2840
|
-
return values.filter(hasNonNullValue);
|
|
2841
|
-
} else {
|
|
2842
|
-
return [];
|
|
2843
|
-
}
|
|
2844
|
-
}
|
|
2875
|
+
const filterMaybeArrayValues = filterMaybeArrayFunction(hasNonNullValue);
|
|
2845
2876
|
/**
|
|
2846
2877
|
* Filters all empty and maybe values from the input array. If a maybe value is input, returns an empty array.
|
|
2847
2878
|
*
|
|
2848
2879
|
* @param values
|
|
2849
2880
|
* @returns
|
|
2850
2881
|
*/
|
|
2851
|
-
|
|
2852
|
-
if (values != null) {
|
|
2853
|
-
return values.filter(hasValueOrNotEmpty);
|
|
2854
|
-
} else {
|
|
2855
|
-
return [];
|
|
2856
|
-
}
|
|
2857
|
-
}
|
|
2882
|
+
const filterEmptyArrayValues = filterMaybeArrayFunction(hasValueOrNotEmpty);
|
|
2858
2883
|
/**
|
|
2859
2884
|
* Checks whether or not all values are MaybeNot values.
|
|
2860
2885
|
*
|
|
@@ -2873,6 +2898,25 @@ function allValuesAreMaybeNot(values) {
|
|
|
2873
2898
|
function allValuesAreNotMaybe(values) {
|
|
2874
2899
|
return values.findIndex(x => x == null) === -1;
|
|
2875
2900
|
}
|
|
2901
|
+
// MARK: Compat
|
|
2902
|
+
/**
|
|
2903
|
+
* Filters all maybe values from the input array. If a maybe value is input, returns an empty array.
|
|
2904
|
+
*
|
|
2905
|
+
* @param values
|
|
2906
|
+
* @returns
|
|
2907
|
+
*
|
|
2908
|
+
* @deprecated use filterMaybeArrayValues instead.
|
|
2909
|
+
*/
|
|
2910
|
+
const filterMaybeValues = filterMaybeArrayValues;
|
|
2911
|
+
/**
|
|
2912
|
+
* Filters all empty and maybe values from the input array. If a maybe value is input, returns an empty array.
|
|
2913
|
+
*
|
|
2914
|
+
* @param values
|
|
2915
|
+
* @returns
|
|
2916
|
+
*
|
|
2917
|
+
* @deprecated use filterEmptyArrayValues instead.
|
|
2918
|
+
*/
|
|
2919
|
+
const filterEmptyValues = filterEmptyArrayValues;
|
|
2876
2920
|
|
|
2877
2921
|
/**
|
|
2878
2922
|
* Convenience function that is used to "build" an object of a specific type.
|
|
@@ -2952,7 +2996,7 @@ function mapFunctionOutput(output, input) {
|
|
|
2952
2996
|
* @param fns
|
|
2953
2997
|
*/
|
|
2954
2998
|
function chainMapSameFunctions(input) {
|
|
2955
|
-
const fns =
|
|
2999
|
+
const fns = filterMaybeArrayValues(asArray(input).filter(x => !isMapIdentityFunction(x))); // remove all identify functions too
|
|
2956
3000
|
let fn;
|
|
2957
3001
|
switch (fns.length) {
|
|
2958
3002
|
case 0:
|
|
@@ -3000,7 +3044,7 @@ function unique(values, excludeInput) {
|
|
|
3000
3044
|
return Array.from(unique);
|
|
3001
3045
|
}
|
|
3002
3046
|
function readKeysFromFilterUniqueFunctionAdditionalKeysInput(additionalKeysInput, readKey) {
|
|
3003
|
-
return
|
|
3047
|
+
return filterMaybeArrayValues(additionalKeysInput != null ? Array.isArray(additionalKeysInput) ? additionalKeysInput : readKeysFromFilterUniqueFunctionAdditionalKeys(additionalKeysInput, readKey) : []);
|
|
3004
3048
|
}
|
|
3005
3049
|
function readKeysFromFilterUniqueFunctionAdditionalKeys(input, readKey) {
|
|
3006
3050
|
const keys = new Set(input.keys);
|
|
@@ -3020,7 +3064,7 @@ function filterUniqueFunction(readKey, additionalKeysInput) {
|
|
|
3020
3064
|
const baseKeys = readKeysFromFilterUniqueFunctionAdditionalKeysInput(additionalKeysInput, readKey);
|
|
3021
3065
|
function calculateExclude(excludeInput) {
|
|
3022
3066
|
const newExcludeKeys = excludeInput ? Array.isArray(excludeInput) ? excludeInput.map(readKey) : readKeysFromFilterUniqueFunctionAdditionalKeys(excludeInput, readKey) : [];
|
|
3023
|
-
return newExcludeKeys != null && newExcludeKeys.length ? mergeArrays([
|
|
3067
|
+
return newExcludeKeys != null && newExcludeKeys.length ? mergeArrays([filterMaybeArrayValues(newExcludeKeys), baseKeys]) : baseKeys;
|
|
3024
3068
|
}
|
|
3025
3069
|
return (input, excludeInput) => {
|
|
3026
3070
|
const exclude = calculateExclude(excludeInput);
|
|
@@ -5103,6 +5147,12 @@ function range(input, inputEnd) {
|
|
|
5103
5147
|
return range;
|
|
5104
5148
|
}
|
|
5105
5149
|
|
|
5150
|
+
/**
|
|
5151
|
+
* The default index number when no index is set.
|
|
5152
|
+
*
|
|
5153
|
+
* Only applicable for non-negative indexes.
|
|
5154
|
+
*/
|
|
5155
|
+
const UNSET_INDEX_NUMBER = -1;
|
|
5106
5156
|
/**
|
|
5107
5157
|
* Convenience function for calling readKeysToMap() and keying the values by their index number.
|
|
5108
5158
|
*
|
|
@@ -5186,6 +5236,20 @@ function computeNextFreeIndexFunction(readIndex, nextIndex) {
|
|
|
5186
5236
|
}
|
|
5187
5237
|
};
|
|
5188
5238
|
}
|
|
5239
|
+
/**
|
|
5240
|
+
* Creates a new ComputeNextFreeIndexFunction that assumes that the input values are sorted in ascending order, with the latest index at the end.
|
|
5241
|
+
*/
|
|
5242
|
+
function computeNextFreeIndexOnSortedValuesFunction(readIndex, nextIndex) {
|
|
5243
|
+
const readNextIndex = nextIndex != null ? nextIndex : x => readIndex(x) + 1; //return the max index + 1 by default.
|
|
5244
|
+
return sortedValues => {
|
|
5245
|
+
const lastValueInSorted = lastValue(sortedValues);
|
|
5246
|
+
if (lastValueInSorted != null) {
|
|
5247
|
+
return readNextIndex(lastValueInSorted);
|
|
5248
|
+
} else {
|
|
5249
|
+
return 0;
|
|
5250
|
+
}
|
|
5251
|
+
};
|
|
5252
|
+
}
|
|
5189
5253
|
/**
|
|
5190
5254
|
* Returns a MinAndMaxIndexFunction.
|
|
5191
5255
|
*
|
|
@@ -6557,6 +6621,34 @@ function repeatString(string, reapeat) {
|
|
|
6557
6621
|
}
|
|
6558
6622
|
return result;
|
|
6559
6623
|
}
|
|
6624
|
+
const DEFAULT_CUT_STRING_END_TEXT = '...';
|
|
6625
|
+
function cutStringFunction(config) {
|
|
6626
|
+
const {
|
|
6627
|
+
maxLength: inputMaxLength,
|
|
6628
|
+
maxLengthIncludesEndText,
|
|
6629
|
+
endText: inputEndText
|
|
6630
|
+
} = config;
|
|
6631
|
+
const endText = inputEndText === undefined ? DEFAULT_CUT_STRING_END_TEXT : '';
|
|
6632
|
+
const maxLength = maxLengthIncludesEndText !== false ? inputMaxLength - endText.length : inputMaxLength;
|
|
6633
|
+
return input => {
|
|
6634
|
+
let result = input;
|
|
6635
|
+
if (input != null) {
|
|
6636
|
+
const inputLength = input.length;
|
|
6637
|
+
if (inputLength > inputMaxLength) {
|
|
6638
|
+
result = input.substring(0, maxLength) + endText;
|
|
6639
|
+
} else {
|
|
6640
|
+
result = input;
|
|
6641
|
+
}
|
|
6642
|
+
}
|
|
6643
|
+
return result;
|
|
6644
|
+
};
|
|
6645
|
+
}
|
|
6646
|
+
function cutString(input, maxLength, endText) {
|
|
6647
|
+
return cutStringFunction({
|
|
6648
|
+
maxLength,
|
|
6649
|
+
endText
|
|
6650
|
+
})(input);
|
|
6651
|
+
}
|
|
6560
6652
|
|
|
6561
6653
|
/**
|
|
6562
6654
|
* map utility function for an iterable that maps and places the results into an array.
|
|
@@ -6997,7 +7089,7 @@ function authRolesSetHasRoles(authRolesSet, roles) {
|
|
|
6997
7089
|
* @returns
|
|
6998
7090
|
*/
|
|
6999
7091
|
function mergeFilterFunctions(...inputFilters) {
|
|
7000
|
-
const filters =
|
|
7092
|
+
const filters = filterMaybeArrayValues(inputFilters);
|
|
7001
7093
|
let filter;
|
|
7002
7094
|
switch (filters.length) {
|
|
7003
7095
|
case 0:
|
|
@@ -7257,7 +7349,7 @@ function mergeObjectsFunction(filter) {
|
|
|
7257
7349
|
dynamic: true // no need to use cache, as cache won't be used.
|
|
7258
7350
|
});
|
|
7259
7351
|
|
|
7260
|
-
return objects => overrideFn(
|
|
7352
|
+
return objects => overrideFn(filterMaybeArrayValues(objects))({});
|
|
7261
7353
|
}
|
|
7262
7354
|
// MARK: POJO
|
|
7263
7355
|
/**
|
|
@@ -7408,8 +7500,9 @@ function filterFromPOJOFunction({
|
|
|
7408
7500
|
delete object[key];
|
|
7409
7501
|
}
|
|
7410
7502
|
});
|
|
7411
|
-
return obj => {
|
|
7412
|
-
|
|
7503
|
+
return (obj, copyOverride) => {
|
|
7504
|
+
const copyObj = typeof copyOverride === 'boolean' ? copyOverride : copy;
|
|
7505
|
+
if (copyObj) {
|
|
7413
7506
|
obj = Object.assign({}, obj);
|
|
7414
7507
|
}
|
|
7415
7508
|
forEachFn(obj);
|
|
@@ -7472,6 +7565,27 @@ function valuesFromPOJOFunction(filter = exports.KeyValueTypleValueFilter.UNDEFI
|
|
|
7472
7565
|
return context.values;
|
|
7473
7566
|
};
|
|
7474
7567
|
}
|
|
7568
|
+
// MARK: Filter Keys
|
|
7569
|
+
/**
|
|
7570
|
+
* Returns a FilterTuplesOnPOJOFunction that returns an object that contains only the input keys, or does not contain the input keys if invertFilter is true.
|
|
7571
|
+
*
|
|
7572
|
+
* @param keysToFilter
|
|
7573
|
+
* @returns
|
|
7574
|
+
*/
|
|
7575
|
+
function filterKeysOnPOJOFunction(keysToFilter, invertFilter = false) {
|
|
7576
|
+
const keysSet = new Set(keysToFilter);
|
|
7577
|
+
const filterFn = invertBooleanReturnFunction(([key]) => keysSet.has(key), invertFilter);
|
|
7578
|
+
return filterTuplesOnPOJOFunction(filterFn);
|
|
7579
|
+
}
|
|
7580
|
+
function filterTuplesOnPOJOFunction(filterTupleOnObject) {
|
|
7581
|
+
return input => {
|
|
7582
|
+
const result = {};
|
|
7583
|
+
Object.entries(input).filter(filterTupleOnObject).forEach(tuple => {
|
|
7584
|
+
result[tuple[0]] = tuple[1];
|
|
7585
|
+
});
|
|
7586
|
+
return result;
|
|
7587
|
+
};
|
|
7588
|
+
}
|
|
7475
7589
|
function forEachKeyValueOnPOJOFunction({
|
|
7476
7590
|
forEach,
|
|
7477
7591
|
filter
|
|
@@ -7483,60 +7597,6 @@ function forEachKeyValueOnPOJOFunction({
|
|
|
7483
7597
|
};
|
|
7484
7598
|
}
|
|
7485
7599
|
|
|
7486
|
-
/**
|
|
7487
|
-
* Converts an ObjectMap into a Map.
|
|
7488
|
-
*
|
|
7489
|
-
* @param object
|
|
7490
|
-
* @returns
|
|
7491
|
-
*/
|
|
7492
|
-
function objectToMap(object) {
|
|
7493
|
-
return new Map(objectToTuples(object));
|
|
7494
|
-
}
|
|
7495
|
-
/**
|
|
7496
|
-
* Converts an ObjectMap into tuples.
|
|
7497
|
-
*
|
|
7498
|
-
* @param object
|
|
7499
|
-
* @returns
|
|
7500
|
-
*/
|
|
7501
|
-
function objectToTuples(object) {
|
|
7502
|
-
const keys = Object.keys(object);
|
|
7503
|
-
return keys.map(x => [x, object[x]]);
|
|
7504
|
-
}
|
|
7505
|
-
/**
|
|
7506
|
-
* Creates a MapObjectMapFunction that calls mapObjectMap().
|
|
7507
|
-
*
|
|
7508
|
-
* @param mapFn
|
|
7509
|
-
* @returns
|
|
7510
|
-
*/
|
|
7511
|
-
function mapObjectMapFunction(mapFn) {
|
|
7512
|
-
return object => mapObjectMap(object, mapFn);
|
|
7513
|
-
}
|
|
7514
|
-
/**
|
|
7515
|
-
* Maps the values of an ObjectMap from one type to another and returns an ObjectMap containing that type.
|
|
7516
|
-
*
|
|
7517
|
-
* @param object
|
|
7518
|
-
*/
|
|
7519
|
-
function mapObjectMap(object, mapFn) {
|
|
7520
|
-
const mappedObject = {};
|
|
7521
|
-
return mapObjectToTargetObject(object, mappedObject, mapFn);
|
|
7522
|
-
}
|
|
7523
|
-
/**
|
|
7524
|
-
* Maps the values of an ObjectMap from one type to the target and return the target.
|
|
7525
|
-
*
|
|
7526
|
-
* @param object
|
|
7527
|
-
* @param target
|
|
7528
|
-
* @param mapFn
|
|
7529
|
-
* @returns
|
|
7530
|
-
*/
|
|
7531
|
-
function mapObjectToTargetObject(object, target, mapFn) {
|
|
7532
|
-
const keys = Object.keys(object);
|
|
7533
|
-
keys.forEach(key => {
|
|
7534
|
-
const value = object[key];
|
|
7535
|
-
target[key] = mapFn(value, key);
|
|
7536
|
-
});
|
|
7537
|
-
return target;
|
|
7538
|
-
}
|
|
7539
|
-
|
|
7540
7600
|
/**
|
|
7541
7601
|
* Determines whether the input values are "allowed" for the given AllowedSet.
|
|
7542
7602
|
*
|
|
@@ -7694,7 +7754,7 @@ function authRoleClaimsService(config, defaults = {}) {
|
|
|
7694
7754
|
return entry.roles != null;
|
|
7695
7755
|
}
|
|
7696
7756
|
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
|
7697
|
-
const tuples =
|
|
7757
|
+
const tuples = Object.entries(config).filter(([, entry]) => entry != null) // skip any ignored/null values
|
|
7698
7758
|
.map(x => {
|
|
7699
7759
|
const inputEntry = x[1];
|
|
7700
7760
|
let entry;
|
|
@@ -8657,9 +8717,9 @@ function unitedStatesAddressString(input, addLinebreaks = true) {
|
|
|
8657
8717
|
parts.push(`${state} ${zip}`);
|
|
8658
8718
|
}
|
|
8659
8719
|
}
|
|
8660
|
-
const nonEmptyParts =
|
|
8720
|
+
const nonEmptyParts = filterEmptyArrayValues(parts);
|
|
8661
8721
|
if (nonEmptyParts.length > 0) {
|
|
8662
|
-
address =
|
|
8722
|
+
address = filterEmptyArrayValues(nonEmptyParts.map(x => x.trim())).join(lineBreakLine);
|
|
8663
8723
|
}
|
|
8664
8724
|
return address;
|
|
8665
8725
|
}
|
|
@@ -12618,7 +12678,7 @@ function primativeKeyDencoder(config) {
|
|
|
12618
12678
|
const map = primativeKeyDencoderMap(config.values);
|
|
12619
12679
|
const fn = input => {
|
|
12620
12680
|
if (Array.isArray(input)) {
|
|
12621
|
-
const values =
|
|
12681
|
+
const values = filterMaybeArrayValues(input.map(x => map.get(x)));
|
|
12622
12682
|
return values;
|
|
12623
12683
|
} else {
|
|
12624
12684
|
let value = map.get(input);
|
|
@@ -14382,10 +14442,21 @@ function isLogicalDateStringCode(logicalDate) {
|
|
|
14382
14442
|
* Recursively compares Arrays, Objects, Maps, Sets, Primatives, and Dates.
|
|
14383
14443
|
*/
|
|
14384
14444
|
function areEqualPOJOValues(a, b) {
|
|
14445
|
+
return areEqualPOJOValuesUsingPojoFilter(a, b, MAP_IDENTITY);
|
|
14446
|
+
}
|
|
14447
|
+
/**
|
|
14448
|
+
* Performs a deep comparison to check if all values on the input filters are equal. Each input is run through the pojo filter
|
|
14449
|
+
*
|
|
14450
|
+
* Recursively compares Arrays, Objects, Maps, Sets, Primatives, and Dates.
|
|
14451
|
+
*/
|
|
14452
|
+
function areEqualPOJOValuesUsingPojoFilter(a, b, pojoFilter) {
|
|
14385
14453
|
// check self
|
|
14386
14454
|
if (a === b) {
|
|
14387
14455
|
return true;
|
|
14388
14456
|
}
|
|
14457
|
+
// run pojo filter before comparison
|
|
14458
|
+
a = pojoFilter(a, true);
|
|
14459
|
+
b = pojoFilter(b, true);
|
|
14389
14460
|
// check one value is nullish and other is not
|
|
14390
14461
|
if ((a == null || b == null) && (a || b)) {
|
|
14391
14462
|
return false;
|
|
@@ -14400,7 +14471,7 @@ function areEqualPOJOValues(a, b) {
|
|
|
14400
14471
|
}
|
|
14401
14472
|
const firstInequalityIndex = a.findIndex((aValue, i) => {
|
|
14402
14473
|
const bValue = b[i];
|
|
14403
|
-
return !
|
|
14474
|
+
return !areEqualPOJOValuesUsingPojoFilter(aValue, bValue, pojoFilter);
|
|
14404
14475
|
});
|
|
14405
14476
|
return firstInequalityIndex === -1;
|
|
14406
14477
|
} else if (a instanceof Set) {
|
|
@@ -14412,14 +14483,15 @@ function areEqualPOJOValues(a, b) {
|
|
|
14412
14483
|
}
|
|
14413
14484
|
const firstInequalityIndex = Array.from(a.entries()).findIndex(([key, aValue]) => {
|
|
14414
14485
|
const bValue = bMap.get(key);
|
|
14415
|
-
return !
|
|
14486
|
+
return !areEqualPOJOValuesUsingPojoFilter(aValue, bValue, pojoFilter);
|
|
14416
14487
|
});
|
|
14417
14488
|
return firstInequalityIndex === -1;
|
|
14418
14489
|
}
|
|
14419
14490
|
} else if (typeof b === 'object') {
|
|
14491
|
+
var _a, _b;
|
|
14420
14492
|
// check contructors/types
|
|
14421
|
-
const firstType = a == null ? void 0 :
|
|
14422
|
-
const secondType = b == null ? void 0 :
|
|
14493
|
+
const firstType = (_a = a) == null ? void 0 : _a.constructor.name;
|
|
14494
|
+
const secondType = (_b = b) == null ? void 0 : _b.constructor.name;
|
|
14423
14495
|
if (firstType !== secondType) {
|
|
14424
14496
|
return false; // false if not the same type
|
|
14425
14497
|
}
|
|
@@ -14437,7 +14509,7 @@ function areEqualPOJOValues(a, b) {
|
|
|
14437
14509
|
const firstInequalityIndex = aKeys.findIndex(key => {
|
|
14438
14510
|
const aKeyValue = aObject[key];
|
|
14439
14511
|
const bKeyValue = bObject[key];
|
|
14440
|
-
return !
|
|
14512
|
+
return !areEqualPOJOValuesUsingPojoFilter(aKeyValue, bKeyValue, pojoFilter);
|
|
14441
14513
|
});
|
|
14442
14514
|
if (firstInequalityIndex === -1) {
|
|
14443
14515
|
return true; // is equal if no non-matching key/value pair is found
|
|
@@ -14521,6 +14593,89 @@ function objectKeyEqualityComparatorFunction(readKey) {
|
|
|
14521
14593
|
return safeEqualityComparatorFunction((a, b) => readKey(a) === readKey(b));
|
|
14522
14594
|
}
|
|
14523
14595
|
|
|
14596
|
+
/**
|
|
14597
|
+
* Converts an ObjectMap into a Map.
|
|
14598
|
+
*
|
|
14599
|
+
* @param object
|
|
14600
|
+
* @returns
|
|
14601
|
+
*/
|
|
14602
|
+
function objectToMap(object) {
|
|
14603
|
+
return new Map(Object.entries(object));
|
|
14604
|
+
}
|
|
14605
|
+
/**
|
|
14606
|
+
* Creates a MapObjectMapFunction that calls mapObjectMap().
|
|
14607
|
+
*
|
|
14608
|
+
* @param mapFn
|
|
14609
|
+
* @returns
|
|
14610
|
+
*/
|
|
14611
|
+
function mapObjectMapFunction(mapFn) {
|
|
14612
|
+
return object => mapObjectMap(object, mapFn);
|
|
14613
|
+
}
|
|
14614
|
+
/**
|
|
14615
|
+
* Maps the values of an ObjectMap from one type to another and returns an ObjectMap containing that type.
|
|
14616
|
+
*
|
|
14617
|
+
* @param object
|
|
14618
|
+
*/
|
|
14619
|
+
function mapObjectMap(object, mapFn) {
|
|
14620
|
+
const mappedObject = {};
|
|
14621
|
+
return mapObjectToTargetObject(object, mappedObject, mapFn);
|
|
14622
|
+
}
|
|
14623
|
+
/**
|
|
14624
|
+
* Maps the values of an ObjectMap from one type to the target and return the target.
|
|
14625
|
+
*
|
|
14626
|
+
* @param object
|
|
14627
|
+
* @param target
|
|
14628
|
+
* @param mapFn
|
|
14629
|
+
* @returns
|
|
14630
|
+
*/
|
|
14631
|
+
function mapObjectToTargetObject(object, target, mapFn) {
|
|
14632
|
+
const keys = Object.keys(object);
|
|
14633
|
+
keys.forEach(key => {
|
|
14634
|
+
const value = object[key];
|
|
14635
|
+
target[key] = mapFn(value, key);
|
|
14636
|
+
});
|
|
14637
|
+
return target;
|
|
14638
|
+
}
|
|
14639
|
+
/**
|
|
14640
|
+
* Maps the keys of the input object to a new object with the mapped keys.
|
|
14641
|
+
*
|
|
14642
|
+
* @param object
|
|
14643
|
+
*/
|
|
14644
|
+
function mapObjectKeysFunction(mapKeyFn) {
|
|
14645
|
+
return object => {
|
|
14646
|
+
const target = {};
|
|
14647
|
+
Object.entries(object).forEach(([key, value]) => {
|
|
14648
|
+
const newKey = mapKeyFn(key, value);
|
|
14649
|
+
target[newKey] = value;
|
|
14650
|
+
});
|
|
14651
|
+
return target;
|
|
14652
|
+
};
|
|
14653
|
+
}
|
|
14654
|
+
/**
|
|
14655
|
+
* Maps all the keys of an object to a new object with keys of the object mapped to lowercase.
|
|
14656
|
+
*
|
|
14657
|
+
* @param object
|
|
14658
|
+
* @param target
|
|
14659
|
+
* @param mapFn
|
|
14660
|
+
*/
|
|
14661
|
+
const mapObjectKeysToLowercase = mapObjectKeysFunction(key => {
|
|
14662
|
+
let nextKey = key;
|
|
14663
|
+
if (typeof key === 'string') {
|
|
14664
|
+
nextKey = key.toLowerCase();
|
|
14665
|
+
}
|
|
14666
|
+
return nextKey;
|
|
14667
|
+
});
|
|
14668
|
+
// MARK: Compat
|
|
14669
|
+
/**
|
|
14670
|
+
* Converts an ObjectMap into tuples.
|
|
14671
|
+
*
|
|
14672
|
+
* @deprecated use Object.entries instead.
|
|
14673
|
+
*
|
|
14674
|
+
* @param object
|
|
14675
|
+
* @returns
|
|
14676
|
+
*/
|
|
14677
|
+
const objectToTuples = Object.entries;
|
|
14678
|
+
|
|
14524
14679
|
function makeCopyModelFieldFunction(key, inputConfig) {
|
|
14525
14680
|
const config = inputConfig != null ? inputConfig : {};
|
|
14526
14681
|
const hasDefault = objectHasKey(config, 'default');
|
|
@@ -14647,8 +14802,8 @@ function copyField(defaultOutput) {
|
|
|
14647
14802
|
|
|
14648
14803
|
function maybeMergeModelModifiers(input) {
|
|
14649
14804
|
const modifiers = asArray(input);
|
|
14650
|
-
const allModifyData =
|
|
14651
|
-
const allModifyModel =
|
|
14805
|
+
const allModifyData = filterMaybeArrayValues(modifiers.map(x => x.modifyData));
|
|
14806
|
+
const allModifyModel = filterMaybeArrayValues(modifiers.map(x => x.modifyModel));
|
|
14652
14807
|
const modifyData = maybeMergeModifiers(allModifyData);
|
|
14653
14808
|
const modifyModel = maybeMergeModifiers(allModifyModel);
|
|
14654
14809
|
return {
|
|
@@ -15633,7 +15788,7 @@ function makeHashDecodeMap(decodeValues, hashFn) {
|
|
|
15633
15788
|
}
|
|
15634
15789
|
function decodeHashedValuesWithDecodeMap(hashedValues, decodeMap) {
|
|
15635
15790
|
const values = hashedValues.map(x => decodeMap.get(x));
|
|
15636
|
-
return
|
|
15791
|
+
return filterMaybeArrayValues(values);
|
|
15637
15792
|
}
|
|
15638
15793
|
|
|
15639
15794
|
/**
|
|
@@ -16128,6 +16283,7 @@ exports.BooleanStringKeyArrayUtilityInstance = BooleanStringKeyArrayUtilityInsta
|
|
|
16128
16283
|
exports.CATCH_ALL_HANDLE_RESULT_KEY = CATCH_ALL_HANDLE_RESULT_KEY;
|
|
16129
16284
|
exports.CUT_VALUE_TO_ZERO_PRECISION = CUT_VALUE_TO_ZERO_PRECISION;
|
|
16130
16285
|
exports.DATE_NOW_VALUE = DATE_NOW_VALUE;
|
|
16286
|
+
exports.DEFAULT_CUT_STRING_END_TEXT = DEFAULT_CUT_STRING_END_TEXT;
|
|
16131
16287
|
exports.DEFAULT_LAT_LNG_STRING_VALUE = DEFAULT_LAT_LNG_STRING_VALUE;
|
|
16132
16288
|
exports.DEFAULT_RANDOM_EMAIL_FACTORY_CONFIG = DEFAULT_RANDOM_EMAIL_FACTORY_CONFIG;
|
|
16133
16289
|
exports.DEFAULT_RANDOM_PHONE_NUMBER_FACTORY_CONFIG = DEFAULT_RANDOM_PHONE_NUMBER_FACTORY_CONFIG;
|
|
@@ -16217,6 +16373,7 @@ exports.TimerCancelledError = TimerCancelledError;
|
|
|
16217
16373
|
exports.TimerInstance = TimerInstance;
|
|
16218
16374
|
exports.TypedServiceRegistryInstance = TypedServiceRegistryInstance;
|
|
16219
16375
|
exports.UNLOADED_PAGE = UNLOADED_PAGE;
|
|
16376
|
+
exports.UNSET_INDEX_NUMBER = UNSET_INDEX_NUMBER;
|
|
16220
16377
|
exports.US_STATE_CODE_STRING_REGEX = US_STATE_CODE_STRING_REGEX;
|
|
16221
16378
|
exports.UTC_DATE_STRING_REGEX = UTC_DATE_STRING_REGEX;
|
|
16222
16379
|
exports.UTC_TIMEZONE_STRING = UTC_TIMEZONE_STRING;
|
|
@@ -16252,6 +16409,7 @@ exports.applyToMultipleFields = applyToMultipleFields;
|
|
|
16252
16409
|
exports.approximateTimerEndDate = approximateTimerEndDate;
|
|
16253
16410
|
exports.areEqualContext = areEqualContext;
|
|
16254
16411
|
exports.areEqualPOJOValues = areEqualPOJOValues;
|
|
16412
|
+
exports.areEqualPOJOValuesUsingPojoFilter = areEqualPOJOValuesUsingPojoFilter;
|
|
16255
16413
|
exports.arrayContainsDuplicateValue = arrayContainsDuplicateValue;
|
|
16256
16414
|
exports.arrayContentsDiffer = arrayContentsDiffer;
|
|
16257
16415
|
exports.arrayDecision = arrayDecision;
|
|
@@ -16307,6 +16465,7 @@ exports.compareFnOrder = compareFnOrder;
|
|
|
16307
16465
|
exports.compareWithMappedValuesFunction = compareWithMappedValuesFunction;
|
|
16308
16466
|
exports.computeNextFractionalHour = computeNextFractionalHour;
|
|
16309
16467
|
exports.computeNextFreeIndexFunction = computeNextFreeIndexFunction;
|
|
16468
|
+
exports.computeNextFreeIndexOnSortedValuesFunction = computeNextFreeIndexOnSortedValuesFunction;
|
|
16310
16469
|
exports.concatArrays = concatArrays;
|
|
16311
16470
|
exports.concatArraysUnique = concatArraysUnique;
|
|
16312
16471
|
exports.containsAllStringsAnyCase = containsAllStringsAnyCase;
|
|
@@ -16332,6 +16491,8 @@ exports.countPOJOKeys = countPOJOKeys;
|
|
|
16332
16491
|
exports.countPOJOKeysFunction = countPOJOKeysFunction;
|
|
16333
16492
|
exports.cronExpressionRepeatingEveryNMinutes = cronExpressionRepeatingEveryNMinutes;
|
|
16334
16493
|
exports.cssClassesSet = cssClassesSet;
|
|
16494
|
+
exports.cutString = cutString;
|
|
16495
|
+
exports.cutStringFunction = cutStringFunction;
|
|
16335
16496
|
exports.cutToPrecision = cutToPrecision;
|
|
16336
16497
|
exports.cutValueToInteger = cutValueToInteger;
|
|
16337
16498
|
exports.cutValueToPrecision = cutValueToPrecision;
|
|
@@ -16379,6 +16540,7 @@ exports.expandTrees = expandTrees;
|
|
|
16379
16540
|
exports.exponentialPromiseRateLimiter = exponentialPromiseRateLimiter;
|
|
16380
16541
|
exports.extendLatLngBound = extendLatLngBound;
|
|
16381
16542
|
exports.filterAndMapFunction = filterAndMapFunction;
|
|
16543
|
+
exports.filterEmptyArrayValues = filterEmptyArrayValues;
|
|
16382
16544
|
exports.filterEmptyValues = filterEmptyValues;
|
|
16383
16545
|
exports.filterFalsyAndEmptyValues = filterFalsyAndEmptyValues;
|
|
16384
16546
|
exports.filterFromIterable = filterFromIterable;
|
|
@@ -16388,9 +16550,13 @@ exports.filterKeyValueTupleFunction = filterKeyValueTupleFunction;
|
|
|
16388
16550
|
exports.filterKeyValueTuples = filterKeyValueTuples;
|
|
16389
16551
|
exports.filterKeyValueTuplesFunction = filterKeyValueTuplesFunction;
|
|
16390
16552
|
exports.filterKeyValueTuplesInputToFilter = filterKeyValueTuplesInputToFilter;
|
|
16553
|
+
exports.filterKeysOnPOJOFunction = filterKeysOnPOJOFunction;
|
|
16554
|
+
exports.filterMaybeArrayFunction = filterMaybeArrayFunction;
|
|
16555
|
+
exports.filterMaybeArrayValues = filterMaybeArrayValues;
|
|
16391
16556
|
exports.filterMaybeValues = filterMaybeValues;
|
|
16392
16557
|
exports.filterNullAndUndefinedValues = filterNullAndUndefinedValues;
|
|
16393
16558
|
exports.filterOnlyUndefinedValues = filterOnlyUndefinedValues;
|
|
16559
|
+
exports.filterTuplesOnPOJOFunction = filterTuplesOnPOJOFunction;
|
|
16394
16560
|
exports.filterUndefinedValues = filterUndefinedValues;
|
|
16395
16561
|
exports.filterUniqueByIndex = filterUniqueByIndex;
|
|
16396
16562
|
exports.filterUniqueCaseInsensitiveStrings = filterUniqueCaseInsensitiveStrings;
|
|
@@ -16648,6 +16814,8 @@ exports.mapIdentityFunction = mapIdentityFunction;
|
|
|
16648
16814
|
exports.mapIterable = mapIterable;
|
|
16649
16815
|
exports.mapKeysIntersectionObjectToArray = mapKeysIntersectionObjectToArray;
|
|
16650
16816
|
exports.mapMaybeFunction = mapMaybeFunction;
|
|
16817
|
+
exports.mapObjectKeysFunction = mapObjectKeysFunction;
|
|
16818
|
+
exports.mapObjectKeysToLowercase = mapObjectKeysToLowercase;
|
|
16651
16819
|
exports.mapObjectMap = mapObjectMap;
|
|
16652
16820
|
exports.mapObjectMapFunction = mapObjectMapFunction;
|
|
16653
16821
|
exports.mapObjectToTargetObject = mapObjectToTargetObject;
|
|
@@ -16804,6 +16972,7 @@ exports.removeModelsWithSameKey = removeModelsWithSameKey;
|
|
|
16804
16972
|
exports.removeModifiers = removeModifiers;
|
|
16805
16973
|
exports.removeTrailingFileTypeSeparators = removeTrailingFileTypeSeparators;
|
|
16806
16974
|
exports.removeTrailingSlashes = removeTrailingSlashes;
|
|
16975
|
+
exports.removeValuesAtIndexesFromArrayCopy = removeValuesAtIndexesFromArrayCopy;
|
|
16807
16976
|
exports.removeWebProtocolPrefix = removeWebProtocolPrefix;
|
|
16808
16977
|
exports.repeatString = repeatString;
|
|
16809
16978
|
exports.replaceCharacterAtIndexIf = replaceCharacterAtIndexIf;
|
|
@@ -16922,6 +17091,7 @@ exports.uniqueCaseInsensitiveStringsSet = uniqueCaseInsensitiveStringsSet;
|
|
|
16922
17091
|
exports.uniqueKeys = uniqueKeys;
|
|
16923
17092
|
exports.uniqueModels = uniqueModels;
|
|
16924
17093
|
exports.unitedStatesAddressString = unitedStatesAddressString;
|
|
17094
|
+
exports.updateMaybeValue = updateMaybeValue;
|
|
16925
17095
|
exports.urlWithoutParameters = urlWithoutParameters;
|
|
16926
17096
|
exports.useAsync = useAsync;
|
|
16927
17097
|
exports.useCallback = useCallback;
|