@dereekb/util 13.11.2 → 13.11.3
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/eslint/index.cjs.default.js +1 -0
- package/eslint/index.cjs.js +607 -0
- package/eslint/index.cjs.mjs +2 -0
- package/eslint/index.d.ts +1 -0
- package/eslint/index.esm.js +603 -0
- package/eslint/package.json +23 -0
- package/eslint/src/index.d.ts +1 -0
- package/eslint/src/lib/comments.d.ts +54 -0
- package/eslint/src/lib/index.d.ts +3 -0
- package/eslint/src/lib/plugin.d.ts +18 -0
- package/eslint/src/lib/prefer-no-side-effects-in-jsdoc.rule.d.ts +42 -0
- package/eslint/src/lib/require-no-side-effects.rule.d.ts +54 -0
- package/fetch/package.json +2 -2
- package/index.cjs.js +1203 -23
- package/index.esm.js +1203 -23
- package/package.json +7 -1
- package/src/lib/array/array.factory.d.ts +2 -0
- package/src/lib/array/array.filter.d.ts +50 -17
- package/src/lib/array/array.find.d.ts +1 -0
- package/src/lib/array/array.index.d.ts +7 -0
- package/src/lib/array/array.indexed.d.ts +21 -0
- package/src/lib/array/array.make.d.ts +7 -0
- package/src/lib/array/array.random.d.ts +1 -0
- package/src/lib/array/array.unique.d.ts +3 -0
- package/src/lib/array/array.value.d.ts +7 -0
- package/src/lib/auth/auth.role.claims.d.ts +7 -0
- package/src/lib/boolean.d.ts +1 -0
- package/src/lib/contact/random.d.ts +14 -0
- package/src/lib/date/date.d.ts +6 -0
- package/src/lib/date/time.d.ts +7 -0
- package/src/lib/date/week.d.ts +7 -0
- package/src/lib/error/error.d.ts +7 -0
- package/src/lib/filter/filter.d.ts +7 -0
- package/src/lib/function/function.boolean.d.ts +7 -0
- package/src/lib/function/function.forward.d.ts +14 -0
- package/src/lib/getter/getter.cache.d.ts +7 -0
- package/src/lib/getter/getter.d.ts +34 -0
- package/src/lib/getter/getter.map.d.ts +7 -0
- package/src/lib/getter/getter.util.d.ts +7 -0
- package/src/lib/grouping.d.ts +8 -0
- package/src/lib/hash.d.ts +1 -0
- package/src/lib/key.d.ts +16 -0
- package/src/lib/map/map.key.d.ts +14 -0
- package/src/lib/model/id.batch.d.ts +7 -0
- package/src/lib/model/id.factory.d.ts +7 -0
- package/src/lib/model/model.conversion.d.ts +35 -0
- package/src/lib/model/model.copy.d.ts +7 -0
- package/src/lib/model/model.d.ts +19 -0
- package/src/lib/model/model.modify.d.ts +14 -0
- package/src/lib/nodejs/stream.d.ts +7 -0
- package/src/lib/number/bound.d.ts +3 -0
- package/src/lib/number/dollar.d.ts +7 -0
- package/src/lib/number/factory.d.ts +7 -0
- package/src/lib/number/random.d.ts +1 -0
- package/src/lib/number/round.d.ts +22 -0
- package/src/lib/number/sort.d.ts +7 -0
- package/src/lib/number/transform.d.ts +7 -0
- package/src/lib/object/object.array.delta.d.ts +7 -0
- package/src/lib/object/object.equal.d.ts +7 -0
- package/src/lib/object/object.filter.pojo.d.ts +87 -0
- package/src/lib/object/object.filter.tuple.d.ts +16 -0
- package/src/lib/object/object.key.d.ts +14 -0
- package/src/lib/object/object.map.d.ts +14 -0
- package/src/lib/path/path.d.ts +9 -0
- package/src/lib/promise/promise.d.ts +21 -0
- package/src/lib/promise/promise.factory.d.ts +7 -0
- package/src/lib/promise/promise.task.d.ts +7 -0
- package/src/lib/service/handler.config.d.ts +28 -0
- package/src/lib/service/handler.d.ts +14 -0
- package/src/lib/set/set.d.ts +21 -0
- package/src/lib/set/set.decision.d.ts +7 -0
- package/src/lib/set/set.delta.d.ts +7 -0
- package/src/lib/set/set.selection.d.ts +7 -0
- package/src/lib/sort.d.ts +8 -0
- package/src/lib/string/char.d.ts +7 -0
- package/src/lib/string/dencoder.d.ts +35 -0
- package/src/lib/string/factory.d.ts +22 -1
- package/src/lib/string/replace.d.ts +78 -0
- package/src/lib/string/search.d.ts +7 -0
- package/src/lib/string/sort.d.ts +7 -0
- package/src/lib/string/string.d.ts +1 -0
- package/src/lib/string/transform.d.ts +53 -0
- package/src/lib/string/tree.d.ts +7 -0
- package/src/lib/string/url.d.ts +7 -0
- package/src/lib/tree/tree.array.d.ts +1 -0
- package/src/lib/tree/tree.explore.d.ts +3 -0
- package/src/lib/type.d.ts +3 -2
- package/src/lib/value/bound.d.ts +28 -0
- package/src/lib/value/comparator.d.ts +16 -0
- package/src/lib/value/decision.d.ts +5 -0
- package/src/lib/value/equal.d.ts +2 -0
- package/src/lib/value/indexed.d.ts +127 -0
- package/src/lib/value/map.d.ts +22 -0
- package/src/lib/value/maybe.type.d.ts +2 -2
- package/src/lib/value/modifier.d.ts +13 -0
- package/src/lib/value/point.d.ts +56 -0
- package/src/lib/value/use.d.ts +37 -0
- package/src/lib/value/vector.d.ts +7 -0
- package/test/index.cjs.js +17 -4
- package/test/index.esm.js +17 -4
- package/test/package.json +2 -2
- package/test/src/lib/shared/shared.fail.d.ts +24 -5
package/index.esm.js
CHANGED
|
@@ -787,6 +787,14 @@ function _unsupported_iterable_to_array$A(o, minLen) {
|
|
|
787
787
|
* const fn = readKeysFunction<string>((x) => x);
|
|
788
788
|
* fn(['a', 'b', 'c']); // ['a', 'b', 'c']
|
|
789
789
|
* ```
|
|
790
|
+
*
|
|
791
|
+
* @dbxUtil
|
|
792
|
+
* @dbxUtilCategory value
|
|
793
|
+
* @dbxUtilKind factory
|
|
794
|
+
* @dbxUtilTags key, read, factory, array, primitive
|
|
795
|
+
* @dbxUtilRelated read-keys-set-function
|
|
796
|
+
*
|
|
797
|
+
* @__NO_SIDE_EFFECTS__
|
|
790
798
|
*/ function readKeysFunction(readKey) {
|
|
791
799
|
return function(values) {
|
|
792
800
|
var result;
|
|
@@ -824,6 +832,14 @@ function _unsupported_iterable_to_array$A(o, minLen) {
|
|
|
824
832
|
* const fn = readKeysSetFunction<string>((x) => x);
|
|
825
833
|
* fn(['a', 'b', 'a']); // Set { 'a', 'b' }
|
|
826
834
|
* ```
|
|
835
|
+
*
|
|
836
|
+
* @dbxUtil
|
|
837
|
+
* @dbxUtilCategory value
|
|
838
|
+
* @dbxUtilKind factory
|
|
839
|
+
* @dbxUtilTags key, read, set, factory, dedupe, primitive
|
|
840
|
+
* @dbxUtilRelated read-keys-function
|
|
841
|
+
*
|
|
842
|
+
* @__NO_SIDE_EFFECTS__
|
|
827
843
|
*/ function readKeysSetFunction(readKey) {
|
|
828
844
|
return function(values) {
|
|
829
845
|
var result;
|
|
@@ -1190,9 +1206,16 @@ function _unsupported_iterable_to_array$z(o, minLen) {
|
|
|
1190
1206
|
/**
|
|
1191
1207
|
* Creates a {@link SetHasValueFunction} from an {@link IterableOrValue} by first converting it to a Set.
|
|
1192
1208
|
*
|
|
1209
|
+
* @dbxUtil
|
|
1210
|
+
* @dbxUtilCategory set
|
|
1211
|
+
* @dbxUtilKind factory
|
|
1212
|
+
* @dbxUtilTags set, has, decision, factory, membership, exclude
|
|
1213
|
+
* @dbxUtilRelated set-has-value-function, set-includes-function
|
|
1214
|
+
*
|
|
1193
1215
|
* @param iterable - The values to create a set from.
|
|
1194
1216
|
* @param exclude - If true, the returned function returns true for values NOT in the set.
|
|
1195
1217
|
* @returns A function that tests membership.
|
|
1218
|
+
* @__NO_SIDE_EFFECTS__
|
|
1196
1219
|
*/ function hasValueFunction(iterable) {
|
|
1197
1220
|
var exclude = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
1198
1221
|
var set = asSet(iterable);
|
|
@@ -1201,9 +1224,16 @@ function _unsupported_iterable_to_array$z(o, minLen) {
|
|
|
1201
1224
|
/**
|
|
1202
1225
|
* Creates a {@link SetHasValueFunction} for the given set. When `exclude` is true, returns the inverse (true for values not in the set).
|
|
1203
1226
|
*
|
|
1227
|
+
* @dbxUtil
|
|
1228
|
+
* @dbxUtilCategory set
|
|
1229
|
+
* @dbxUtilKind factory
|
|
1230
|
+
* @dbxUtilTags set, has, decision, factory, membership, exclude
|
|
1231
|
+
* @dbxUtilRelated has-value-function, set-includes-function
|
|
1232
|
+
*
|
|
1204
1233
|
* @param set - The set to check against.
|
|
1205
1234
|
* @param exclude - If true, returns true for values NOT in the set.
|
|
1206
1235
|
* @returns A function that tests membership.
|
|
1236
|
+
* @__NO_SIDE_EFFECTS__
|
|
1207
1237
|
*/ function setHasValueFunction(set, exclude) {
|
|
1208
1238
|
var hasValueFunction;
|
|
1209
1239
|
if (exclude) {
|
|
@@ -1242,10 +1272,17 @@ function _unsupported_iterable_to_array$z(o, minLen) {
|
|
|
1242
1272
|
/**
|
|
1243
1273
|
* Creates a {@link SetIncludesFunction} that checks whether the set includes given values using the specified mode.
|
|
1244
1274
|
*
|
|
1275
|
+
* @dbxUtil
|
|
1276
|
+
* @dbxUtilCategory set
|
|
1277
|
+
* @dbxUtilKind factory
|
|
1278
|
+
* @dbxUtilTags set, includes, decision, factory, all, any, mode
|
|
1279
|
+
* @dbxUtilRelated has-value-function, set-has-value-function
|
|
1280
|
+
*
|
|
1245
1281
|
* @param valuesSet - The reference set.
|
|
1246
1282
|
* @param mode - Whether to require 'all' values or 'any' value to be present. Defaults to 'all'.
|
|
1247
1283
|
* @param emptyValuesToFindArrayResult - The result when the values to find are empty.
|
|
1248
1284
|
* @returns A function that tests inclusion against the set.
|
|
1285
|
+
* @__NO_SIDE_EFFECTS__
|
|
1249
1286
|
*/ function setIncludesFunction(valuesSet) {
|
|
1250
1287
|
var mode = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 'all', emptyValuesToFindArrayResult = arguments.length > 2 ? arguments[2] : void 0;
|
|
1251
1288
|
var fn;
|
|
@@ -1418,9 +1455,16 @@ function _unsupported_iterable_to_array$y(o, minLen) {
|
|
|
1418
1455
|
/**
|
|
1419
1456
|
* Inverts the output of an arbitrary boolean-returning function.
|
|
1420
1457
|
*
|
|
1458
|
+
* @dbxUtil
|
|
1459
|
+
* @dbxUtilCategory function
|
|
1460
|
+
* @dbxUtilKind factory
|
|
1461
|
+
* @dbxUtilTags function, boolean, invert, predicate, factory
|
|
1462
|
+
* @dbxUtilRelated decision-function, filter-function
|
|
1463
|
+
*
|
|
1421
1464
|
* @param decisionFn - The function whose boolean return value to invert
|
|
1422
1465
|
* @param invert - Whether to apply the inversion (defaults to true)
|
|
1423
1466
|
* @returns The inverted function, or the original if invert is false
|
|
1467
|
+
* @__NO_SIDE_EFFECTS__
|
|
1424
1468
|
*/ function invertBooleanReturnFunction(decisionFn) {
|
|
1425
1469
|
var invert = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
|
|
1426
1470
|
return invert ? function() {
|
|
@@ -1450,6 +1494,7 @@ function _unsupported_iterable_to_array$y(o, minLen) {
|
|
|
1450
1494
|
* @param decision - Predicate used to test individual elements.
|
|
1451
1495
|
* @param mode - Whether all or any elements must satisfy the predicate.
|
|
1452
1496
|
* @returns A function that evaluates an array against the configured decision criteria.
|
|
1497
|
+
* @__NO_SIDE_EFFECTS__
|
|
1453
1498
|
*/ function arrayDecisionFunction(decision, mode) {
|
|
1454
1499
|
var findFn = mode === 'all' ? invertBooleanReturnFunction(decision) : decision;
|
|
1455
1500
|
return invertBooleanReturnFunction(function(values) {
|
|
@@ -1761,8 +1806,15 @@ function _type_of$l(obj) {
|
|
|
1761
1806
|
/**
|
|
1762
1807
|
* Creates a {@link FilterMaybeArrayFunction} that filters maybe values from an array using the provided filter function.
|
|
1763
1808
|
*
|
|
1809
|
+
* @dbxUtil
|
|
1810
|
+
* @dbxUtilCategory array
|
|
1811
|
+
* @dbxUtilKind factory
|
|
1812
|
+
* @dbxUtilTags array, filter, maybe, factory, predicate
|
|
1813
|
+
* @dbxUtilRelated filter-maybe-array-values
|
|
1814
|
+
*
|
|
1764
1815
|
* @param filterFn - Filter predicate used to determine which values to keep.
|
|
1765
1816
|
* @returns A function that filters maybe values from an optional input array.
|
|
1817
|
+
* @__NO_SIDE_EFFECTS__
|
|
1766
1818
|
*/ function filterMaybeArrayFunction(filterFn) {
|
|
1767
1819
|
return function(values) {
|
|
1768
1820
|
var result;
|
|
@@ -1872,6 +1924,7 @@ function _type_of$l(obj) {
|
|
|
1872
1924
|
* maybeDouble(undefined); // undefined
|
|
1873
1925
|
* maybeDouble(null); // null
|
|
1874
1926
|
* ```
|
|
1927
|
+
* @__NO_SIDE_EFFECTS__
|
|
1875
1928
|
*/ function mapMaybeFunction(mapFunction) {
|
|
1876
1929
|
return function(input) {
|
|
1877
1930
|
var output = isMaybeNot(input) ? input : mapFunction(input);
|
|
@@ -1889,6 +1942,7 @@ function _type_of$l(obj) {
|
|
|
1889
1942
|
*
|
|
1890
1943
|
* @param mapFunction - per-element transformation
|
|
1891
1944
|
* @returns a function that maps entire arrays
|
|
1945
|
+
* @__NO_SIDE_EFFECTS__
|
|
1892
1946
|
*/ function mapArrayFunction(mapFunction) {
|
|
1893
1947
|
return function(input) {
|
|
1894
1948
|
return input.map(mapFunction);
|
|
@@ -1914,15 +1968,27 @@ function _type_of$l(obj) {
|
|
|
1914
1968
|
/**
|
|
1915
1969
|
* Returns the shared {@link MAP_IDENTITY} function cast to the requested type, useful for providing a typed no-op transformation.
|
|
1916
1970
|
*
|
|
1971
|
+
* @dbxUtil
|
|
1972
|
+
* @dbxUtilCategory value
|
|
1973
|
+
* @dbxUtilTags map, identity, no-op, typed
|
|
1974
|
+
* @dbxUtilRelated map-identity, is-map-identity-function
|
|
1975
|
+
*
|
|
1917
1976
|
* @returns the singleton identity function typed as `MapFunction<T, T>`
|
|
1977
|
+
* @__NO_SIDE_EFFECTS__
|
|
1918
1978
|
*/ function mapIdentityFunction() {
|
|
1919
1979
|
return MAP_IDENTITY;
|
|
1920
1980
|
}
|
|
1921
1981
|
/**
|
|
1922
1982
|
* Checks whether the given function is the singleton {@link MAP_IDENTITY} reference.
|
|
1923
1983
|
*
|
|
1984
|
+
* @dbxUtil
|
|
1985
|
+
* @dbxUtilCategory value
|
|
1986
|
+
* @dbxUtilTags map, identity, type-guard, sentinel
|
|
1987
|
+
* @dbxUtilRelated map-identity, map-identity-function
|
|
1988
|
+
*
|
|
1924
1989
|
* @param fn - the function to check
|
|
1925
1990
|
* @returns `true` if the function is the identity singleton
|
|
1991
|
+
* @__NO_SIDE_EFFECTS__
|
|
1926
1992
|
*/ function isMapIdentityFunction(fn) {
|
|
1927
1993
|
return fn === MAP_IDENTITY;
|
|
1928
1994
|
}
|
|
@@ -1990,6 +2056,8 @@ function _type_of$l(obj) {
|
|
|
1990
2056
|
* const result = fnChain('aaaab');
|
|
1991
2057
|
* // result === 'aaaab'
|
|
1992
2058
|
* ```
|
|
2059
|
+
*
|
|
2060
|
+
* @__NO_SIDE_EFFECTS__
|
|
1993
2061
|
*/ function chainMapSameFunctions(input) {
|
|
1994
2062
|
var fns = filterMaybeArrayValues(asArray(input).filter(function(x) {
|
|
1995
2063
|
return !isMapIdentityFunction(x);
|
|
@@ -2127,6 +2195,7 @@ function _unsupported_iterable_to_array$x(o, minLen) {
|
|
|
2127
2195
|
* @param readKey - Function to extract a unique key from each item.
|
|
2128
2196
|
* @param additionalKeysInput - Optional keys or values to pre-seed as already seen, causing them to be excluded.
|
|
2129
2197
|
* @returns A reusable filter function that removes duplicate items from arrays.
|
|
2198
|
+
* @__NO_SIDE_EFFECTS__
|
|
2130
2199
|
*/ function filterUniqueFunction(readKey, additionalKeysInput) {
|
|
2131
2200
|
var baseKeys = readKeysFromFilterUniqueFunctionAdditionalKeysInput(additionalKeysInput, readKey);
|
|
2132
2201
|
function calculateExclude(excludeInput) {
|
|
@@ -2177,6 +2246,7 @@ function _unsupported_iterable_to_array$x(o, minLen) {
|
|
|
2177
2246
|
*
|
|
2178
2247
|
* @param readKey - Function to extract a unique key from each item.
|
|
2179
2248
|
* @returns A decision function that returns true if all items have distinct keys.
|
|
2249
|
+
* @__NO_SIDE_EFFECTS__
|
|
2180
2250
|
*/ function isUniqueKeyedFunction(readKey) {
|
|
2181
2251
|
return function(input) {
|
|
2182
2252
|
var keys = new Set();
|
|
@@ -2302,9 +2372,15 @@ function makeModelMap(input, read) {
|
|
|
2302
2372
|
*
|
|
2303
2373
|
* If multiple models share the same relation key, the last one wins for that key.
|
|
2304
2374
|
*
|
|
2375
|
+
* @dbxUtil
|
|
2376
|
+
* @dbxUtilCategory model
|
|
2377
|
+
* @dbxUtilTags model, map, key, multi, relation, index, lookup
|
|
2378
|
+
* @dbxUtilRelated make-model-map, read-model-key
|
|
2379
|
+
*
|
|
2305
2380
|
* @param input - Array of models to index
|
|
2306
2381
|
* @param read - Function that returns an array of relation keys for each model
|
|
2307
2382
|
* @returns Map from relation key to model
|
|
2383
|
+
* @__NO_SIDE_EFFECTS__
|
|
2308
2384
|
*/ function makeMultiModelKeyMap(input, read) {
|
|
2309
2385
|
var map = new Map();
|
|
2310
2386
|
input.forEach(function(x) {
|
|
@@ -2456,9 +2532,16 @@ function readModelKey(input) {
|
|
|
2456
2532
|
*
|
|
2457
2533
|
* Falls back to the provided default type if the type reader returns a nullish value.
|
|
2458
2534
|
*
|
|
2535
|
+
* @dbxUtil
|
|
2536
|
+
* @dbxUtilCategory model
|
|
2537
|
+
* @dbxUtilKind factory
|
|
2538
|
+
* @dbxUtilTags model, type, pair, factory, wrap
|
|
2539
|
+
* @dbxUtilRelated read-model-key, encode-model-key-type-pair
|
|
2540
|
+
*
|
|
2459
2541
|
* @param typeReader - Function to extract the model type from input data
|
|
2460
2542
|
* @param defaultType - Fallback type string when the reader returns nullish
|
|
2461
2543
|
* @returns Factory function that produces ModelTypeDataPair values
|
|
2544
|
+
* @__NO_SIDE_EFFECTS__
|
|
2462
2545
|
*/ function modelTypeDataPairFactory(typeReader) {
|
|
2463
2546
|
var defaultType = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : DEFAULT_UNKNOWN_MODEL_TYPE_STRING;
|
|
2464
2547
|
return function(data) {
|
|
@@ -2937,6 +3020,7 @@ function reverseCompareFn(compareFn) {
|
|
|
2937
3020
|
* [{ name: 'Bob' }, { name: 'Alice' }].sort(byName);
|
|
2938
3021
|
* // [{ name: 'Alice' }, { name: 'Bob' }]
|
|
2939
3022
|
* ```
|
|
3023
|
+
* @__NO_SIDE_EFFECTS__
|
|
2940
3024
|
*/ function compareWithMappedValuesFunction(mapValue, comparesFunction) {
|
|
2941
3025
|
return function(a, b) {
|
|
2942
3026
|
var vA = mapValue(a);
|
|
@@ -3002,12 +3086,19 @@ function reverseCompareFn(compareFn) {
|
|
|
3002
3086
|
* @param compareFn - Ascending sort comparison function used to determine min/max.
|
|
3003
3087
|
* @returns A function that returns `{ min, max }` or `null` for empty iterables.
|
|
3004
3088
|
*
|
|
3089
|
+
* @dbxUtil
|
|
3090
|
+
* @dbxUtilCategory sort
|
|
3091
|
+
* @dbxUtilKind factory
|
|
3092
|
+
* @dbxUtilTags sort, min, max, factory, iterable, compare
|
|
3093
|
+
* @dbxUtilRelated min-and-max-index-items-function, sort-by-number-function
|
|
3094
|
+
*
|
|
3005
3095
|
* @example
|
|
3006
3096
|
* ```ts
|
|
3007
3097
|
* const fn = minAndMaxFunction<number>((a, b) => a - b);
|
|
3008
3098
|
* fn([3, 1, 4, 1, 5]); // { min: 1, max: 5 }
|
|
3009
3099
|
* fn([]); // null
|
|
3010
3100
|
* ```
|
|
3101
|
+
* @__NO_SIDE_EFFECTS__
|
|
3011
3102
|
*/ function minAndMaxFunction(compareFn) {
|
|
3012
3103
|
return function(values) {
|
|
3013
3104
|
var _firstValueFromIterable;
|
|
@@ -3301,9 +3392,15 @@ function _unsupported_iterable_to_array$t(o, minLen) {
|
|
|
3301
3392
|
/**
|
|
3302
3393
|
* Creates an array of `[key, value]` tuples by extracting a key from each value.
|
|
3303
3394
|
*
|
|
3395
|
+
* @dbxUtil
|
|
3396
|
+
* @dbxUtilCategory grouping
|
|
3397
|
+
* @dbxUtilTags grouping, key, pairs, tuple, array
|
|
3398
|
+
* @dbxUtilRelated group-values, make-values-group-map
|
|
3399
|
+
*
|
|
3304
3400
|
* @param values - Values to create key pairs from.
|
|
3305
3401
|
* @param keyFn - Extracts the key from each value.
|
|
3306
3402
|
* @returns An array of `[key, value]` tuples.
|
|
3403
|
+
* @__NO_SIDE_EFFECTS__
|
|
3307
3404
|
*/ function makeKeyPairs(values, keyFn) {
|
|
3308
3405
|
return values.map(function(x) {
|
|
3309
3406
|
return [
|
|
@@ -3469,8 +3566,15 @@ function _unsupported_iterable_to_array$s(o, minLen) {
|
|
|
3469
3566
|
/**
|
|
3470
3567
|
* Creates a KeyValueMapFactory that maps values by their key using a ReadKeyFunction.
|
|
3471
3568
|
*
|
|
3569
|
+
* @dbxUtil
|
|
3570
|
+
* @dbxUtilCategory value
|
|
3571
|
+
* @dbxUtilKind factory
|
|
3572
|
+
* @dbxUtilTags map, key, factory, lookup, index
|
|
3573
|
+
* @dbxUtilRelated multi-key-value-map-factory, read-keys-to-map
|
|
3574
|
+
*
|
|
3472
3575
|
* @param read - Function that extracts a key from each value
|
|
3473
3576
|
* @returns A factory that creates Maps from arrays of values
|
|
3577
|
+
* @__NO_SIDE_EFFECTS__
|
|
3474
3578
|
*/ function keyValueMapFactory(read) {
|
|
3475
3579
|
return function(values) {
|
|
3476
3580
|
var map = new Map();
|
|
@@ -3496,8 +3600,15 @@ function _unsupported_iterable_to_array$s(o, minLen) {
|
|
|
3496
3600
|
* Creates a KeyValueMapFactory that maps values by multiple keys using a ReadMultipleKeysFunction.
|
|
3497
3601
|
* Each value can appear under multiple keys.
|
|
3498
3602
|
*
|
|
3603
|
+
* @dbxUtil
|
|
3604
|
+
* @dbxUtilCategory value
|
|
3605
|
+
* @dbxUtilKind factory
|
|
3606
|
+
* @dbxUtilTags map, key, multi, factory, lookup, index
|
|
3607
|
+
* @dbxUtilRelated key-value-map-factory, read-multiple-keys-to-map
|
|
3608
|
+
*
|
|
3499
3609
|
* @param read - Function that extracts multiple keys from each value
|
|
3500
3610
|
* @returns A factory that creates Maps from arrays of values
|
|
3611
|
+
* @__NO_SIDE_EFFECTS__
|
|
3501
3612
|
*/ function multiKeyValueMapFactory(read) {
|
|
3502
3613
|
return function(values) {
|
|
3503
3614
|
var map = new Map();
|
|
@@ -3613,8 +3724,15 @@ function _unsupported_iterable_to_array$s(o, minLen) {
|
|
|
3613
3724
|
* Creates an {@link IsSelectedDecisionFunctionFactory} that produces decision functions
|
|
3614
3725
|
* checking whether a value's key is included in a set of selected values.
|
|
3615
3726
|
*
|
|
3727
|
+
* @dbxUtil
|
|
3728
|
+
* @dbxUtilCategory set
|
|
3729
|
+
* @dbxUtilKind factory
|
|
3730
|
+
* @dbxUtilTags set, selection, decision, predicate, factory, key
|
|
3731
|
+
* @dbxUtilRelated is-in-set-decision-function
|
|
3732
|
+
*
|
|
3616
3733
|
* @param config - Configuration with the key reader and default behavior.
|
|
3617
3734
|
* @returns A factory that creates decision functions from a set of selected keys.
|
|
3735
|
+
* @__NO_SIDE_EFFECTS__
|
|
3618
3736
|
*/ function isSelectedDecisionFunctionFactory(config) {
|
|
3619
3737
|
var readKey = config.readKey, _config_defaultIfKeyNull = config.defaultIfKeyNull, defaultIfKeyNull = _config_defaultIfKeyNull === void 0 ? false : _config_defaultIfKeyNull;
|
|
3620
3738
|
return function(selectedValues) {
|
|
@@ -3772,6 +3890,7 @@ function _unsupported_iterable_to_array$s(o, minLen) {
|
|
|
3772
3890
|
*
|
|
3773
3891
|
* @param x - The value to check.
|
|
3774
3892
|
* @returns Whether the value is a non-class function.
|
|
3893
|
+
* @__NO_SIDE_EFFECTS__
|
|
3775
3894
|
*/ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
3776
3895
|
function isNonClassFunction(x) {
|
|
3777
3896
|
var type = getFunctionType(x);
|
|
@@ -3825,6 +3944,7 @@ function getValueFromGetter(input, args) {
|
|
|
3825
3944
|
* @param value - The object to copy
|
|
3826
3945
|
* @param copyFunction - Optional custom copy function (defaults to copyObject)
|
|
3827
3946
|
* @returns A factory that produces copies of the value
|
|
3947
|
+
* @__NO_SIDE_EFFECTS__
|
|
3828
3948
|
*/ function objectCopyFactory(value) {
|
|
3829
3949
|
var copyFunction = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : copyObject;
|
|
3830
3950
|
return function() {
|
|
@@ -3835,17 +3955,31 @@ function getValueFromGetter(input, args) {
|
|
|
3835
3955
|
* Converts the input to an ObjectCopyFactory. If the input is an object, wraps it with objectCopyFactory.
|
|
3836
3956
|
* If it's already a function (Getter), it's returned directly.
|
|
3837
3957
|
*
|
|
3958
|
+
* @dbxUtil
|
|
3959
|
+
* @dbxUtilCategory getter
|
|
3960
|
+
* @dbxUtilKind factory
|
|
3961
|
+
* @dbxUtilTags getter, factory, copy, clone, object, normalize
|
|
3962
|
+
* @dbxUtilRelated object-copy-factory, as-getter
|
|
3963
|
+
*
|
|
3838
3964
|
* @param input - An object value or a getter function
|
|
3839
3965
|
* @param copyFunction - Optional custom copy function
|
|
3840
3966
|
* @returns An ObjectCopyFactory for the input
|
|
3967
|
+
* @__NO_SIDE_EFFECTS__
|
|
3841
3968
|
*/ function asObjectCopyFactory(input, copyFunction) {
|
|
3842
3969
|
return (typeof input === "undefined" ? "undefined" : _type_of$j(input)) === 'object' ? objectCopyFactory(input, copyFunction) : asGetter(input);
|
|
3843
3970
|
}
|
|
3844
3971
|
/**
|
|
3845
3972
|
* Wraps the input value in a Getter function that always returns it.
|
|
3846
3973
|
*
|
|
3974
|
+
* @dbxUtil
|
|
3975
|
+
* @dbxUtilCategory getter
|
|
3976
|
+
* @dbxUtilKind factory
|
|
3977
|
+
* @dbxUtilTags getter, factory, wrap, constant
|
|
3978
|
+
* @dbxUtilRelated as-getter, get-value-from-getter
|
|
3979
|
+
*
|
|
3847
3980
|
* @param input - The value to wrap
|
|
3848
3981
|
* @returns A Getter that returns the input value
|
|
3982
|
+
* @__NO_SIDE_EFFECTS__
|
|
3849
3983
|
*/ function makeGetter(input) {
|
|
3850
3984
|
return function() {
|
|
3851
3985
|
return input;
|
|
@@ -3854,9 +3988,15 @@ function getValueFromGetter(input, args) {
|
|
|
3854
3988
|
/**
|
|
3855
3989
|
* Calls a factory function the specified number of times and returns the results as an array.
|
|
3856
3990
|
*
|
|
3991
|
+
* @dbxUtil
|
|
3992
|
+
* @dbxUtilCategory getter
|
|
3993
|
+
* @dbxUtilTags getter, factory, generate, array, count
|
|
3994
|
+
* @dbxUtilRelated make-with-factory-input, array-factory
|
|
3995
|
+
*
|
|
3857
3996
|
* @param factory - The factory function to call (receives the current index as argument)
|
|
3858
3997
|
* @param count - The number of items to create
|
|
3859
3998
|
* @returns An array of produced values
|
|
3999
|
+
* @__NO_SIDE_EFFECTS__
|
|
3860
4000
|
*/ function makeWithFactory(factory, count) {
|
|
3861
4001
|
var results = [];
|
|
3862
4002
|
for(var i = 0; i < count; i += 1){
|
|
@@ -3873,8 +4013,15 @@ function makeWithFactoryInput(factory, input) {
|
|
|
3873
4013
|
* Wraps a factory so that no arguments are forwarded when it's called.
|
|
3874
4014
|
* Useful for protecting a factory from accidentally receiving arguments.
|
|
3875
4015
|
*
|
|
4016
|
+
* @dbxUtil
|
|
4017
|
+
* @dbxUtilCategory getter
|
|
4018
|
+
* @dbxUtilKind factory
|
|
4019
|
+
* @dbxUtilTags getter, factory, protect, wrap, no-args
|
|
4020
|
+
* @dbxUtilRelated as-getter, make-getter
|
|
4021
|
+
*
|
|
3876
4022
|
* @param factory - The factory to wrap
|
|
3877
4023
|
* @returns A new factory that calls the original with no arguments
|
|
4024
|
+
* @__NO_SIDE_EFFECTS__
|
|
3878
4025
|
*/ function protectedFactory(factory) {
|
|
3879
4026
|
return function() {
|
|
3880
4027
|
return factory();
|
|
@@ -3887,6 +4034,12 @@ function makeWithFactoryInput(factory, input) {
|
|
|
3887
4034
|
* @param config - Configuration with optional `startAt` (default 0) and `increaseBy` (default 1)
|
|
3888
4035
|
* @returns A factory function that returns the next number in the sequence on each call
|
|
3889
4036
|
*
|
|
4037
|
+
* @dbxUtil
|
|
4038
|
+
* @dbxUtilCategory number
|
|
4039
|
+
* @dbxUtilKind factory
|
|
4040
|
+
* @dbxUtilTags number, factory, increment, sequence, counter
|
|
4041
|
+
* @dbxUtilRelated random-number-factory
|
|
4042
|
+
*
|
|
3890
4043
|
* @example
|
|
3891
4044
|
* ```ts
|
|
3892
4045
|
* const factory = incrementingNumberFactory({ startAt: 10, increaseBy: 5 });
|
|
@@ -3894,6 +4047,7 @@ function makeWithFactoryInput(factory, input) {
|
|
|
3894
4047
|
* factory(); // 15
|
|
3895
4048
|
* factory(); // 20
|
|
3896
4049
|
* ```
|
|
4050
|
+
* @__NO_SIDE_EFFECTS__
|
|
3897
4051
|
*/ function incrementingNumberFactory() {
|
|
3898
4052
|
var config = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
3899
4053
|
var initial = config.startAt, inputIncreaseBy = config.increaseBy;
|
|
@@ -3927,6 +4081,7 @@ function makeWithFactoryInput(factory, input) {
|
|
|
3927
4081
|
* @param bounds - The min/max bounds to test against
|
|
3928
4082
|
* @returns A function that returns `true` if the input number is within bounds
|
|
3929
4083
|
* @throws Error if the bounds are invalid (min > max)
|
|
4084
|
+
* @__NO_SIDE_EFFECTS__
|
|
3930
4085
|
*/ function isInNumberBoundFunction(bounds) {
|
|
3931
4086
|
var min = bounds.min, max = bounds.max;
|
|
3932
4087
|
if (!isValidNumberBound(bounds)) {
|
|
@@ -3949,6 +4104,7 @@ function makeWithFactoryInput(factory, input) {
|
|
|
3949
4104
|
*
|
|
3950
4105
|
* @param wrapNumberFunctionConfig - Configuration with min, max, and optional fence post behavior
|
|
3951
4106
|
* @returns A function that wraps input numbers into the bounded range
|
|
4107
|
+
* @__NO_SIDE_EFFECTS__
|
|
3952
4108
|
*/ function wrapNumberFunction(wrapNumberFunctionConfig) {
|
|
3953
4109
|
var min = wrapNumberFunctionConfig.min, max = wrapNumberFunctionConfig.max, _wrapNumberFunctionConfig_fencePosts = wrapNumberFunctionConfig.fencePosts, fencePosts = _wrapNumberFunctionConfig_fencePosts === void 0 ? false : _wrapNumberFunctionConfig_fencePosts;
|
|
3954
4110
|
var distance = max - min;
|
|
@@ -3980,6 +4136,7 @@ function makeWithFactoryInput(factory, input) {
|
|
|
3980
4136
|
*
|
|
3981
4137
|
* @param boundNumberFunctionConfig - Configuration with min, max, and optional wrap behavior
|
|
3982
4138
|
* @returns A function that bounds input numbers into the configured range
|
|
4139
|
+
* @__NO_SIDE_EFFECTS__
|
|
3983
4140
|
*/ function boundNumberFunction(boundNumberFunctionConfig) {
|
|
3984
4141
|
var min = boundNumberFunctionConfig.min, max = boundNumberFunctionConfig.max, wrap = boundNumberFunctionConfig.wrap;
|
|
3985
4142
|
return wrap ? wrapNumberFunction(boundNumberFunctionConfig) : function(input) {
|
|
@@ -4203,6 +4360,7 @@ function _type_of$h(obj) {
|
|
|
4203
4360
|
*
|
|
4204
4361
|
* @param type - The rounding strategy: 'floor', 'ceil', 'round', or 'none'
|
|
4205
4362
|
* @returns The corresponding Math function, or an identity function for 'none'
|
|
4363
|
+
* @__NO_SIDE_EFFECTS__
|
|
4206
4364
|
*/ function roundingFunction(type) {
|
|
4207
4365
|
var fn;
|
|
4208
4366
|
switch(type){
|
|
@@ -4259,9 +4417,16 @@ function _type_of$h(obj) {
|
|
|
4259
4417
|
/**
|
|
4260
4418
|
* Creates a {@link CutValueToPrecisionFunction} that truncates values to the configured precision.
|
|
4261
4419
|
*
|
|
4420
|
+
* @dbxUtil
|
|
4421
|
+
* @dbxUtilCategory number
|
|
4422
|
+
* @dbxUtilKind factory
|
|
4423
|
+
* @dbxUtilTags number, precision, cut, truncate, factory, round
|
|
4424
|
+
* @dbxUtilRelated round-to-precision-function, cut-to-precision
|
|
4425
|
+
*
|
|
4262
4426
|
* @param precision - Number of decimal places to retain
|
|
4263
4427
|
* @param roundingType - Rounding strategy; defaults to 'cut' (truncation)
|
|
4264
4428
|
* @returns A function that accepts a number or string and returns the truncated number
|
|
4429
|
+
* @__NO_SIDE_EFFECTS__
|
|
4265
4430
|
*/ function cutValueToPrecisionFunction(precision) {
|
|
4266
4431
|
var roundingType = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 'cut';
|
|
4267
4432
|
var roundFn = roundToPrecisionFunction(precision, roundingType);
|
|
@@ -4274,9 +4439,16 @@ function _type_of$h(obj) {
|
|
|
4274
4439
|
/**
|
|
4275
4440
|
* Creates a function that rounds numbers to the specified precision using a configurable rounding strategy.
|
|
4276
4441
|
*
|
|
4442
|
+
* @dbxUtil
|
|
4443
|
+
* @dbxUtilCategory number
|
|
4444
|
+
* @dbxUtilKind factory
|
|
4445
|
+
* @dbxUtilTags number, round, precision, factory, decimals
|
|
4446
|
+
* @dbxUtilRelated cut-value-to-precision-function, round-to-precision, cut-to-precision
|
|
4447
|
+
*
|
|
4277
4448
|
* @param precision - Number of decimal places
|
|
4278
4449
|
* @param roundFn - Rounding strategy; defaults to 'round'. Use 'cut' for truncation.
|
|
4279
4450
|
* @returns A function that rounds numbers to the configured precision
|
|
4451
|
+
* @__NO_SIDE_EFFECTS__
|
|
4280
4452
|
*/ function roundToPrecisionFunction(precision) {
|
|
4281
4453
|
var roundFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 'round';
|
|
4282
4454
|
var result;
|
|
@@ -4329,9 +4501,16 @@ function _type_of$h(obj) {
|
|
|
4329
4501
|
*
|
|
4330
4502
|
* Accepts either a step number (uses 'ceil' rounding) or a full config with step, rounding type, and origin.
|
|
4331
4503
|
*
|
|
4504
|
+
* @dbxUtil
|
|
4505
|
+
* @dbxUtilCategory number
|
|
4506
|
+
* @dbxUtilKind factory
|
|
4507
|
+
* @dbxUtilTags number, round, step, factory, multiple, origin
|
|
4508
|
+
* @dbxUtilRelated round-number-up-to-step, round-to-precision-function
|
|
4509
|
+
*
|
|
4332
4510
|
* @param input - Step size or full configuration
|
|
4333
4511
|
* @returns A function that rounds input numbers to the nearest step
|
|
4334
4512
|
* @throws Error if step is 0 or undefined
|
|
4513
|
+
* @__NO_SIDE_EFFECTS__
|
|
4335
4514
|
*/ function roundNumberToStepFunction(input) {
|
|
4336
4515
|
var config = typeof input === 'number' ? {
|
|
4337
4516
|
step: input,
|
|
@@ -4383,8 +4562,15 @@ var DOLLAR_AMOUNT_STRING_REGEX = /^\$?(\d+)\.?(\d\d)$/;
|
|
|
4383
4562
|
/**
|
|
4384
4563
|
* Creates a function that formats dollar amounts as strings with a unit prefix (e.g., "$12.50").
|
|
4385
4564
|
*
|
|
4565
|
+
* @dbxUtil
|
|
4566
|
+
* @dbxUtilCategory number
|
|
4567
|
+
* @dbxUtilKind factory
|
|
4568
|
+
* @dbxUtilTags number, dollar, currency, format, factory, unit
|
|
4569
|
+
* @dbxUtilRelated dollar-amount-string
|
|
4570
|
+
*
|
|
4386
4571
|
* @param unit - The unit prefix to prepend; defaults to "$"
|
|
4387
4572
|
* @returns A function that formats dollar amounts with the configured unit
|
|
4573
|
+
* @__NO_SIDE_EFFECTS__
|
|
4388
4574
|
*/ function dollarAmountStringWithUnitFunction() {
|
|
4389
4575
|
var unit = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : '$';
|
|
4390
4576
|
var fn = function fn(amount) {
|
|
@@ -4408,6 +4594,7 @@ var DOLLAR_AMOUNT_STRING_REGEX = /^\$?(\d+)\.?(\d\d)$/;
|
|
|
4408
4594
|
* @param maxOrArgs - Maximum value (exclusive) or full configuration object
|
|
4409
4595
|
* @param roundingInput - Optional rounding mode override
|
|
4410
4596
|
* @returns A factory function that produces random numbers within the range
|
|
4597
|
+
* @__NO_SIDE_EFFECTS__
|
|
4411
4598
|
*/ function randomNumberFactory(maxOrArgs, roundingInput) {
|
|
4412
4599
|
var config = typeof maxOrArgs === 'number' ? {
|
|
4413
4600
|
min: 0,
|
|
@@ -4453,8 +4640,15 @@ var DOLLAR_AMOUNT_STRING_REGEX = /^\$?(\d+)\.?(\d\d)$/;
|
|
|
4453
4640
|
/**
|
|
4454
4641
|
* Creates a {@link SortCompareFunction} that sorts values in ascending order by a numeric property.
|
|
4455
4642
|
*
|
|
4643
|
+
* @dbxUtil
|
|
4644
|
+
* @dbxUtilCategory number
|
|
4645
|
+
* @dbxUtilKind factory
|
|
4646
|
+
* @dbxUtilTags number, sort, compare, ascending, factory
|
|
4647
|
+
* @dbxUtilRelated sort-numbers-ascending-function, sort-by-string-function
|
|
4648
|
+
*
|
|
4456
4649
|
* @param readNumberFn - Function that extracts the numeric value from each item
|
|
4457
4650
|
* @returns A sort comparator function for ascending numeric order
|
|
4651
|
+
* @__NO_SIDE_EFFECTS__
|
|
4458
4652
|
*/ function sortByNumberFunction(readNumberFn) {
|
|
4459
4653
|
return function(a, b) {
|
|
4460
4654
|
var as = readNumberFn(a);
|
|
@@ -4485,8 +4679,15 @@ var DOLLAR_AMOUNT_STRING_REGEX = /^\$?(\d+)\.?(\d\d)$/;
|
|
|
4485
4679
|
*
|
|
4486
4680
|
* Chains the configured operations in order: custom transform, step rounding, precision cut, then bounds clamping.
|
|
4487
4681
|
*
|
|
4682
|
+
* @dbxUtil
|
|
4683
|
+
* @dbxUtilCategory number
|
|
4684
|
+
* @dbxUtilKind factory
|
|
4685
|
+
* @dbxUtilTags number, transform, factory, round, precision, bounds, chain
|
|
4686
|
+
* @dbxUtilRelated transform-string-function, round-number-to-step-function
|
|
4687
|
+
*
|
|
4488
4688
|
* @param config - Configuration with optional transform, roundToStep, precision, and bounds
|
|
4489
4689
|
* @returns A single function that applies all configured transformations in sequence
|
|
4690
|
+
* @__NO_SIDE_EFFECTS__
|
|
4490
4691
|
*/ function transformNumberFunction(config) {
|
|
4491
4692
|
var transformFunctions = [
|
|
4492
4693
|
config.transform
|
|
@@ -4714,12 +4915,19 @@ function reduceNumbersFn(reduceFn, emptyArrayValue) {
|
|
|
4714
4915
|
*
|
|
4715
4916
|
* @returns a compare function suitable for Array.sort()
|
|
4716
4917
|
*
|
|
4918
|
+
* @dbxUtil
|
|
4919
|
+
* @dbxUtilCategory value
|
|
4920
|
+
* @dbxUtilKind factory
|
|
4921
|
+
* @dbxUtilTags value, index, sort, ascending, factory, ref
|
|
4922
|
+
* @dbxUtilRelated sort-by-index-ascending-compare-function, sort-by-index-range-ascending-compare-function
|
|
4923
|
+
*
|
|
4717
4924
|
* @example
|
|
4718
4925
|
* ```ts
|
|
4719
4926
|
* const items = [{ i: 4 }, { i: 0 }, { i: 2 }];
|
|
4720
4927
|
* items.sort(sortAscendingIndexNumberRefFunction());
|
|
4721
4928
|
* // items[0].i === 0
|
|
4722
4929
|
* ```
|
|
4930
|
+
* @__NO_SIDE_EFFECTS__
|
|
4723
4931
|
*/ function sortAscendingIndexNumberRefFunction() {
|
|
4724
4932
|
return function(a, b) {
|
|
4725
4933
|
return a.i - b.i;
|
|
@@ -4741,6 +4949,12 @@ function reduceNumbersFn(reduceFn, emptyArrayValue) {
|
|
|
4741
4949
|
* @param readIndex - reads an item's index, returning null/undefined for unindexed items
|
|
4742
4950
|
* @returns a function that groups items by their index state
|
|
4743
4951
|
*
|
|
4952
|
+
* @dbxUtil
|
|
4953
|
+
* @dbxUtilCategory value
|
|
4954
|
+
* @dbxUtilKind factory
|
|
4955
|
+
* @dbxUtilTags value, index, delta, group, factory, classify
|
|
4956
|
+
* @dbxUtilRelated separate-values, compute-next-free-index-function
|
|
4957
|
+
*
|
|
4744
4958
|
* @example
|
|
4745
4959
|
* ```ts
|
|
4746
4960
|
* const groupFn = indexDeltaGroupFunction<{ x: string; i?: number }>((x) => x.i);
|
|
@@ -4749,6 +4963,7 @@ function reduceNumbersFn(reduceFn, emptyArrayValue) {
|
|
|
4749
4963
|
* // result.newItems.length === 1 (item without an index)
|
|
4750
4964
|
* // result.currentItems.length === 2 (items with indexes)
|
|
4751
4965
|
* ```
|
|
4966
|
+
* @__NO_SIDE_EFFECTS__
|
|
4752
4967
|
*/ function indexDeltaGroupFunction(readIndex) {
|
|
4753
4968
|
return function(inputItems, previousItems) {
|
|
4754
4969
|
var _separateValues = separateValues(inputItems, function(x) {
|
|
@@ -4786,8 +5001,15 @@ function reduceNumbersFn(reduceFn, emptyArrayValue) {
|
|
|
4786
5001
|
/**
|
|
4787
5002
|
* Creates a SortCompareFunction that sorts items in ascending order using a custom index reader.
|
|
4788
5003
|
*
|
|
5004
|
+
* @dbxUtil
|
|
5005
|
+
* @dbxUtilCategory value
|
|
5006
|
+
* @dbxUtilKind factory
|
|
5007
|
+
* @dbxUtilTags value, index, sort, ascending, factory, compare
|
|
5008
|
+
* @dbxUtilRelated sort-ascending-index-number-ref-function, sort-by-index-range-ascending-compare-function
|
|
5009
|
+
*
|
|
4789
5010
|
* @param readIndex - extracts the index number from each item
|
|
4790
5011
|
* @returns a compare function suitable for Array.sort()
|
|
5012
|
+
* @__NO_SIDE_EFFECTS__
|
|
4791
5013
|
*/ function sortByIndexAscendingCompareFunction(readIndex) {
|
|
4792
5014
|
return function(a, b) {
|
|
4793
5015
|
return readIndex(a) - readIndex(b);
|
|
@@ -4801,12 +5023,19 @@ function reduceNumbersFn(reduceFn, emptyArrayValue) {
|
|
|
4801
5023
|
* @param nextIndex - optional custom function to compute the next index from the max item; defaults to max + 1
|
|
4802
5024
|
* @returns a function that computes the next free index for a given array
|
|
4803
5025
|
*
|
|
5026
|
+
* @dbxUtil
|
|
5027
|
+
* @dbxUtilCategory value
|
|
5028
|
+
* @dbxUtilKind factory
|
|
5029
|
+
* @dbxUtilTags value, index, free, next, factory, max
|
|
5030
|
+
* @dbxUtilRelated compute-next-free-index-on-sorted-values-function, min-and-max-index-function
|
|
5031
|
+
*
|
|
4804
5032
|
* @example
|
|
4805
5033
|
* ```ts
|
|
4806
5034
|
* const fn = computeNextFreeIndexFunction<IndexRef>((x) => x.i);
|
|
4807
5035
|
* const nextIndex = fn([{ i: 0 }, { i: 1 }, { i: 5 }]);
|
|
4808
5036
|
* // nextIndex === 6
|
|
4809
5037
|
* ```
|
|
5038
|
+
* @__NO_SIDE_EFFECTS__
|
|
4810
5039
|
*/ function computeNextFreeIndexFunction(readIndex, nextIndex) {
|
|
4811
5040
|
var findMinMax = minAndMaxIndexItemsFunction(readIndex);
|
|
4812
5041
|
var readNextIndex = nextIndex !== null && nextIndex !== void 0 ? nextIndex : function(x) {
|
|
@@ -4822,9 +5051,16 @@ function reduceNumbersFn(reduceFn, emptyArrayValue) {
|
|
|
4822
5051
|
* Creates a {@link ComputeNextFreeIndexFunction} optimized for pre-sorted input arrays.
|
|
4823
5052
|
* Instead of scanning all items for the maximum, it reads only the last element.
|
|
4824
5053
|
*
|
|
5054
|
+
* @dbxUtil
|
|
5055
|
+
* @dbxUtilCategory value
|
|
5056
|
+
* @dbxUtilKind factory
|
|
5057
|
+
* @dbxUtilTags value, index, free, next, sorted, factory, optimized
|
|
5058
|
+
* @dbxUtilRelated compute-next-free-index-function
|
|
5059
|
+
*
|
|
4825
5060
|
* @param readIndex - extracts the index number from each item
|
|
4826
5061
|
* @param nextIndex - optional custom function to compute the next index from the last item; defaults to last + 1
|
|
4827
5062
|
* @returns a function that computes the next free index from sorted arrays
|
|
5063
|
+
* @__NO_SIDE_EFFECTS__
|
|
4828
5064
|
*/ function computeNextFreeIndexOnSortedValuesFunction(readIndex, nextIndex) {
|
|
4829
5065
|
var readNextIndex = nextIndex !== null && nextIndex !== void 0 ? nextIndex : function(x) {
|
|
4830
5066
|
return readIndex(x) + 1;
|
|
@@ -4840,12 +5076,19 @@ function reduceNumbersFn(reduceFn, emptyArrayValue) {
|
|
|
4840
5076
|
* @param readIndex - extracts the index number from each item
|
|
4841
5077
|
* @returns a function returning the min/max indexes, or null for empty input
|
|
4842
5078
|
*
|
|
5079
|
+
* @dbxUtil
|
|
5080
|
+
* @dbxUtilCategory value
|
|
5081
|
+
* @dbxUtilKind factory
|
|
5082
|
+
* @dbxUtilTags value, index, min, max, factory, range
|
|
5083
|
+
* @dbxUtilRelated min-and-max-index, min-and-max-index-items-function
|
|
5084
|
+
*
|
|
4843
5085
|
* @example
|
|
4844
5086
|
* ```ts
|
|
4845
5087
|
* const fn = minAndMaxIndexFunction<IndexRef>((x) => x.i);
|
|
4846
5088
|
* const result = fn([{ i: 3 }, { i: 0 }, { i: 5 }]);
|
|
4847
5089
|
* // result?.min === 0, result?.max === 5
|
|
4848
5090
|
* ```
|
|
5091
|
+
* @__NO_SIDE_EFFECTS__
|
|
4849
5092
|
*/ function minAndMaxIndexFunction(readIndex) {
|
|
4850
5093
|
var minAndMaxItems = minAndMaxIndexItemsFunction(readIndex);
|
|
4851
5094
|
var fn = function fn(values) {
|
|
@@ -4871,8 +5114,15 @@ function reduceNumbersFn(reduceFn, emptyArrayValue) {
|
|
|
4871
5114
|
* Creates a {@link MinAndMaxIndexItemsFunction} that returns the actual items (not just index numbers)
|
|
4872
5115
|
* with the minimum and maximum index values.
|
|
4873
5116
|
*
|
|
5117
|
+
* @dbxUtil
|
|
5118
|
+
* @dbxUtilCategory value
|
|
5119
|
+
* @dbxUtilKind factory
|
|
5120
|
+
* @dbxUtilTags value, index, min, max, items, factory
|
|
5121
|
+
* @dbxUtilRelated min-and-max-index-function, min-and-max-function
|
|
5122
|
+
*
|
|
4874
5123
|
* @param readIndex - extracts the index number from each item
|
|
4875
5124
|
* @returns a function returning the min/max items, or null for empty input
|
|
5125
|
+
* @__NO_SIDE_EFFECTS__
|
|
4876
5126
|
*/ function minAndMaxIndexItemsFunction(readIndex) {
|
|
4877
5127
|
var fn = minAndMaxFunction(readIndex);
|
|
4878
5128
|
fn._readIndex = readIndex;
|
|
@@ -4927,6 +5177,14 @@ function reduceNumbersFn(reduceFn, emptyArrayValue) {
|
|
|
4927
5177
|
* fn({ i: 6 }); // returns { i: 5 }
|
|
4928
5178
|
* fn({ i: 11 }); // returns { i: 10 }
|
|
4929
5179
|
* ```
|
|
5180
|
+
*
|
|
5181
|
+
* @dbxUtil
|
|
5182
|
+
* @dbxUtilCategory value
|
|
5183
|
+
* @dbxUtilKind factory
|
|
5184
|
+
* @dbxUtilTags value, index, match, find, factory, lookup
|
|
5185
|
+
* @dbxUtilRelated find-best-index-match, safe-find-best-index-match
|
|
5186
|
+
*
|
|
5187
|
+
* @__NO_SIDE_EFFECTS__
|
|
4930
5188
|
*/ function findBestIndexMatchFunction(items) {
|
|
4931
5189
|
// reverse the order so we can return the first item that is less than or equal to the input i
|
|
4932
5190
|
var bestMatchArray = iterableToArray(items, false).sort(reverseCompareFn(sortAscendingIndexNumberRefFunction()));
|
|
@@ -4977,8 +5235,15 @@ function reduceNumbersFn(reduceFn, emptyArrayValue) {
|
|
|
4977
5235
|
* Creates a SortCompareFunction that sorts items by their IndexRange in ascending order.
|
|
4978
5236
|
* Sorts by minIndex first, then by maxIndex for items with equal minIndex values.
|
|
4979
5237
|
*
|
|
5238
|
+
* @dbxUtil
|
|
5239
|
+
* @dbxUtilCategory value
|
|
5240
|
+
* @dbxUtilKind factory
|
|
5241
|
+
* @dbxUtilTags value, index-range, sort, ascending, factory, compare
|
|
5242
|
+
* @dbxUtilRelated sort-by-index-ascending-compare-function, index-range-reader-pair-factory
|
|
5243
|
+
*
|
|
4980
5244
|
* @param readIndexRange - extracts the IndexRange from each item
|
|
4981
5245
|
* @returns a compare function suitable for Array.sort()
|
|
5246
|
+
* @__NO_SIDE_EFFECTS__
|
|
4982
5247
|
*/ function sortByIndexRangeAscendingCompareFunction(readIndexRange) {
|
|
4983
5248
|
return function(a, b) {
|
|
4984
5249
|
var ra = readIndexRange(a);
|
|
@@ -4990,8 +5255,15 @@ function reduceNumbersFn(reduceFn, emptyArrayValue) {
|
|
|
4990
5255
|
/**
|
|
4991
5256
|
* Creates a new {@link IndexRangeReaderPairFactory} that pairs each value with its computed IndexRange.
|
|
4992
5257
|
*
|
|
5258
|
+
* @dbxUtil
|
|
5259
|
+
* @dbxUtilCategory value
|
|
5260
|
+
* @dbxUtilKind factory
|
|
5261
|
+
* @dbxUtilTags value, index-range, pair, factory, reader
|
|
5262
|
+
* @dbxUtilRelated sort-by-index-range-ascending-compare-function
|
|
5263
|
+
*
|
|
4993
5264
|
* @param reader - reads the IndexRange from the input value
|
|
4994
5265
|
* @returns a factory that creates IndexRangeReaderPair instances
|
|
5266
|
+
* @__NO_SIDE_EFFECTS__
|
|
4995
5267
|
*/ function indexRangeReaderPairFactory(reader) {
|
|
4996
5268
|
return function(value) {
|
|
4997
5269
|
var range = reader(value);
|
|
@@ -5016,8 +5288,15 @@ function reduceNumbersFn(reduceFn, emptyArrayValue) {
|
|
|
5016
5288
|
/**
|
|
5017
5289
|
* Creates a {@link FitToIndexRangeFunction} that clamps index numbers to the given range boundaries.
|
|
5018
5290
|
*
|
|
5291
|
+
* @dbxUtil
|
|
5292
|
+
* @dbxUtilCategory value
|
|
5293
|
+
* @dbxUtilKind factory
|
|
5294
|
+
* @dbxUtilTags value, index, clamp, range, factory, fit
|
|
5295
|
+
* @dbxUtilRelated wrap-index-range-function, bound-number-function
|
|
5296
|
+
*
|
|
5019
5297
|
* @param input - the range to clamp to
|
|
5020
5298
|
* @returns a function that clamps any index to the range
|
|
5299
|
+
* @__NO_SIDE_EFFECTS__
|
|
5021
5300
|
*/ function fitToIndexRangeFunction(input) {
|
|
5022
5301
|
var min = input.minIndex, maxIndex = input.maxIndex;
|
|
5023
5302
|
var max = maxIndex - 1;
|
|
@@ -5035,12 +5314,19 @@ function reduceNumbersFn(reduceFn, emptyArrayValue) {
|
|
|
5035
5314
|
* @param fencePosts - whether to use fencepost semantics (maxIndex is exclusive); defaults to true
|
|
5036
5315
|
* @returns a function that wraps any index into the range
|
|
5037
5316
|
*
|
|
5317
|
+
* @dbxUtil
|
|
5318
|
+
* @dbxUtilCategory value
|
|
5319
|
+
* @dbxUtilKind factory
|
|
5320
|
+
* @dbxUtilTags value, index, wrap, range, factory, modular
|
|
5321
|
+
* @dbxUtilRelated fit-to-index-range-function, wrap-number-function
|
|
5322
|
+
*
|
|
5038
5323
|
* @example
|
|
5039
5324
|
* ```ts
|
|
5040
5325
|
* const wrap = wrapIndexRangeFunction({ minIndex: 0, maxIndex: 6 });
|
|
5041
5326
|
* wrap(6); // 0 (wraps from positive side)
|
|
5042
5327
|
* wrap(-1); // 5 (wraps from negative side)
|
|
5043
5328
|
* ```
|
|
5329
|
+
* @__NO_SIDE_EFFECTS__
|
|
5044
5330
|
*/ function wrapIndexRangeFunction(input) {
|
|
5045
5331
|
var fencePosts = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
|
|
5046
5332
|
var min = input.minIndex, maxIndex = input.maxIndex;
|
|
@@ -5088,8 +5374,15 @@ function indexRangeCheckFunctionConfigToIndexRange(param) {
|
|
|
5088
5374
|
* Creates an {@link IndexRangeCheckFunction} that tests whether an index number falls within the configured range.
|
|
5089
5375
|
* The min is inclusive and the max is exclusive by default unless `inclusiveMaxIndex` is set.
|
|
5090
5376
|
*
|
|
5377
|
+
* @dbxUtil
|
|
5378
|
+
* @dbxUtilCategory value
|
|
5379
|
+
* @dbxUtilKind factory
|
|
5380
|
+
* @dbxUtilTags value, index, range, check, factory, predicate
|
|
5381
|
+
* @dbxUtilRelated index-range-check-reader-function, is-index-number-in-index-range-function
|
|
5382
|
+
*
|
|
5091
5383
|
* @param input - the range or range config to check against
|
|
5092
5384
|
* @returns a predicate function for index numbers
|
|
5385
|
+
* @__NO_SIDE_EFFECTS__
|
|
5093
5386
|
*/ function indexRangeCheckFunction(input) {
|
|
5094
5387
|
var _indexRangeCheckFunctionConfigToIndexRange = indexRangeCheckFunctionConfigToIndexRange(asIndexRangeCheckFunctionConfig(input)), minIndex = _indexRangeCheckFunctionConfigToIndexRange.minIndex, maxIndex = _indexRangeCheckFunctionConfigToIndexRange.maxIndex;
|
|
5095
5388
|
return function(i) {
|
|
@@ -5113,8 +5406,15 @@ function indexRangeCheckFunctionConfigToIndexRange(param) {
|
|
|
5113
5406
|
/**
|
|
5114
5407
|
* Creates an {@link IsIndexNumberInIndexRangeFunction} bound to the given range configuration.
|
|
5115
5408
|
*
|
|
5409
|
+
* @dbxUtil
|
|
5410
|
+
* @dbxUtilCategory value
|
|
5411
|
+
* @dbxUtilKind factory
|
|
5412
|
+
* @dbxUtilTags value, index, range, check, factory, predicate
|
|
5413
|
+
* @dbxUtilRelated is-index-number-in-index-range, index-range-check-function
|
|
5414
|
+
*
|
|
5116
5415
|
* @param input - the range or range config to bind
|
|
5117
5416
|
* @returns a predicate that tests index numbers against the bound range
|
|
5417
|
+
* @__NO_SIDE_EFFECTS__
|
|
5118
5418
|
*/ function isIndexNumberInIndexRangeFunction(input) {
|
|
5119
5419
|
var _indexRangeCheckFunctionConfigToIndexRange = indexRangeCheckFunctionConfigToIndexRange(asIndexRangeCheckFunctionConfig(input)), minIndex = _indexRangeCheckFunctionConfigToIndexRange.minIndex, maxIndex = _indexRangeCheckFunctionConfigToIndexRange.maxIndex;
|
|
5120
5420
|
return function(index) {
|
|
@@ -5133,8 +5433,15 @@ function indexRangeCheckFunctionConfigToIndexRange(param) {
|
|
|
5133
5433
|
/**
|
|
5134
5434
|
* Creates an {@link IsIndexRangeInIndexRangeFunction} bound to the given range configuration.
|
|
5135
5435
|
*
|
|
5436
|
+
* @dbxUtil
|
|
5437
|
+
* @dbxUtilCategory value
|
|
5438
|
+
* @dbxUtilKind factory
|
|
5439
|
+
* @dbxUtilTags value, index-range, contains, decision, factory, predicate
|
|
5440
|
+
* @dbxUtilRelated is-index-range-in-index-range, index-range-overlaps-index-range-function
|
|
5441
|
+
*
|
|
5136
5442
|
* @param input - the bounding range or range config to bind
|
|
5137
5443
|
* @returns a predicate that tests whether index ranges are fully contained
|
|
5444
|
+
* @__NO_SIDE_EFFECTS__
|
|
5138
5445
|
*/ function isIndexRangeInIndexRangeFunction(input) {
|
|
5139
5446
|
var _indexRangeCheckFunctionConfigToIndexRange = indexRangeCheckFunctionConfigToIndexRange(asIndexRangeCheckFunctionConfig(input)), minIndex = _indexRangeCheckFunctionConfigToIndexRange.minIndex, maxIndex = _indexRangeCheckFunctionConfigToIndexRange.maxIndex;
|
|
5140
5447
|
return function(input) {
|
|
@@ -5153,8 +5460,15 @@ function indexRangeCheckFunctionConfigToIndexRange(param) {
|
|
|
5153
5460
|
/**
|
|
5154
5461
|
* Creates an {@link IndexRangeOverlapsIndexRangeFunction} bound to the given range configuration.
|
|
5155
5462
|
*
|
|
5463
|
+
* @dbxUtil
|
|
5464
|
+
* @dbxUtilCategory value
|
|
5465
|
+
* @dbxUtilKind factory
|
|
5466
|
+
* @dbxUtilTags value, index-range, overlap, decision, factory, predicate
|
|
5467
|
+
* @dbxUtilRelated is-index-range-in-index-range-function, index-range-check-function
|
|
5468
|
+
*
|
|
5156
5469
|
* @param input - the reference range or range config to bind
|
|
5157
5470
|
* @returns a predicate that tests for overlap with the bound range
|
|
5471
|
+
* @__NO_SIDE_EFFECTS__
|
|
5158
5472
|
*/ function indexRangeOverlapsIndexRangeFunction(input) {
|
|
5159
5473
|
var _indexRangeCheckFunctionConfigToIndexRange = indexRangeCheckFunctionConfigToIndexRange(asIndexRangeCheckFunctionConfig(input)), minIndex = _indexRangeCheckFunctionConfigToIndexRange.minIndex, maxIndex = _indexRangeCheckFunctionConfigToIndexRange.maxIndex;
|
|
5160
5474
|
return function(input) {
|
|
@@ -5173,8 +5487,15 @@ function indexRangeCheckFunctionConfigToIndexRange(param) {
|
|
|
5173
5487
|
* Creates a {@link StepsFromIndexFunction} that computes the next index after stepping from a start position.
|
|
5174
5488
|
* Returns undefined when the result falls outside the range (unless wrapping or fitting is enabled).
|
|
5175
5489
|
*
|
|
5490
|
+
* @dbxUtil
|
|
5491
|
+
* @dbxUtilCategory value
|
|
5492
|
+
* @dbxUtilKind factory
|
|
5493
|
+
* @dbxUtilTags value, index, step, range, factory, wrap, navigation
|
|
5494
|
+
* @dbxUtilRelated wrap-index-range-function, fit-to-index-range-function
|
|
5495
|
+
*
|
|
5176
5496
|
* @param config - stepping behavior configuration
|
|
5177
5497
|
* @returns a function that computes the stepped index
|
|
5498
|
+
* @__NO_SIDE_EFFECTS__
|
|
5178
5499
|
*/ function stepsFromIndexFunction(config) {
|
|
5179
5500
|
var range = config.range, _config_fitToRange = config.fitToRange, fitToRange = _config_fitToRange === void 0 ? false : _config_fitToRange, _config_fencePosts = config.fencePosts, fencePosts = _config_fencePosts === void 0 ? true : _config_fencePosts, tmp = config.wrapAround, defaultWrapAround = tmp === void 0 ? false : tmp, tmp1 = config.steps, defaultStep = tmp1 === void 0 ? 1 : tmp1;
|
|
5180
5501
|
var wrapNumber = wrapIndexRangeFunction(range, fencePosts);
|
|
@@ -5314,8 +5635,15 @@ function stepsFromIndex(range, startIndex) {
|
|
|
5314
5635
|
/**
|
|
5315
5636
|
* Creates a {@link SliceIndexRangeFunction} that slices the specified index range from any input array.
|
|
5316
5637
|
*
|
|
5638
|
+
* @dbxUtil
|
|
5639
|
+
* @dbxUtilCategory array
|
|
5640
|
+
* @dbxUtilKind factory
|
|
5641
|
+
* @dbxUtilTags array, slice, index, range, factory
|
|
5642
|
+
* @dbxUtilRelated index-range, find-to-index-set
|
|
5643
|
+
*
|
|
5317
5644
|
* @param inputRange - the index range configuration to use for slicing
|
|
5318
5645
|
* @returns a function that slices the configured range from an input array
|
|
5646
|
+
* @__NO_SIDE_EFFECTS__
|
|
5319
5647
|
*/ function sliceIndexRangeFunction(inputRange) {
|
|
5320
5648
|
var range = indexRange(inputRange);
|
|
5321
5649
|
return function(input) {
|
|
@@ -5327,15 +5655,39 @@ function stepsFromIndex(range, startIndex) {
|
|
|
5327
5655
|
* Filters the input values by distance while maintaining the original order of elements.
|
|
5328
5656
|
* Values that are too close to each other (based on the minDistance parameter) will be filtered out.
|
|
5329
5657
|
*
|
|
5658
|
+
* Items whose extracted value is null are excluded from the result.
|
|
5659
|
+
*
|
|
5330
5660
|
* If order is irrelevant, use filterValuesByDistanceNoOrder() instead.
|
|
5331
5661
|
*
|
|
5332
|
-
* @param
|
|
5333
|
-
* @param
|
|
5334
|
-
* @param
|
|
5335
|
-
* @returns A filtered array with only values that are at least minDistance apart
|
|
5336
|
-
*/ function filterValuesByDistance(
|
|
5337
|
-
//
|
|
5338
|
-
|
|
5662
|
+
* @param input - The array of values to filter
|
|
5663
|
+
* @param minDistance - The minimum distance required between values (inclusive)
|
|
5664
|
+
* @param getValue - Function that extracts a numeric value from each item for distance comparison
|
|
5665
|
+
* @returns A filtered array with only values that are at least minDistance apart, in their original input order
|
|
5666
|
+
*/ function filterValuesByDistance(input, minDistance, getValue) {
|
|
5667
|
+
// Tag each non-null value with its original index so we can restore order after the distance filter.
|
|
5668
|
+
var tagged = [];
|
|
5669
|
+
for(var i = 0, n = input.length; i < n; i += 1){
|
|
5670
|
+
var item = input[i];
|
|
5671
|
+
var value = getValue(item);
|
|
5672
|
+
if (value != null) {
|
|
5673
|
+
tagged.push([
|
|
5674
|
+
{
|
|
5675
|
+
item: item,
|
|
5676
|
+
index: i
|
|
5677
|
+
},
|
|
5678
|
+
value
|
|
5679
|
+
]);
|
|
5680
|
+
}
|
|
5681
|
+
}
|
|
5682
|
+
var kept = _filterValuesByDistance(tagged, minDistance, function(x) {
|
|
5683
|
+
return x[0];
|
|
5684
|
+
});
|
|
5685
|
+
kept.sort(function(a, b) {
|
|
5686
|
+
return a.index - b.index;
|
|
5687
|
+
});
|
|
5688
|
+
return kept.map(function(x) {
|
|
5689
|
+
return x.item;
|
|
5690
|
+
});
|
|
5339
5691
|
}
|
|
5340
5692
|
/**
|
|
5341
5693
|
* Filters the input values by an arbitrary "distance"/difference from each other and returns the values sorted by their determined distance.
|
|
@@ -5399,14 +5751,17 @@ function stepsFromIndex(range, startIndex) {
|
|
|
5399
5751
|
/**
|
|
5400
5752
|
* Same as applyBestFit, but returns a new array, rather than modifying the existing array.
|
|
5401
5753
|
*
|
|
5402
|
-
* @
|
|
5403
|
-
* @
|
|
5404
|
-
* @
|
|
5405
|
-
* @
|
|
5406
|
-
*
|
|
5407
|
-
|
|
5408
|
-
|
|
5409
|
-
|
|
5754
|
+
* @dbxUtil
|
|
5755
|
+
* @dbxUtilCategory array
|
|
5756
|
+
* @dbxUtilTags array, best-fit, filter, sort, immutable
|
|
5757
|
+
* @dbxUtilRelated apply-best-fit, find-best-index-set-pair
|
|
5758
|
+
*
|
|
5759
|
+
* @param input - The array to filter for the best fit.
|
|
5760
|
+
* @param config - The best-fit strategy ({@link BestFitConfig}).
|
|
5761
|
+
* @returns A new array with only the best fit item and transformed non-best-fit items.
|
|
5762
|
+
* @__NO_SIDE_EFFECTS__
|
|
5763
|
+
*/ function makeBestFit(input, config) {
|
|
5764
|
+
return applyBestFit(copyArray(input), config);
|
|
5410
5765
|
}
|
|
5411
5766
|
/**
|
|
5412
5767
|
* Used for updating an array so that a single element becomes the "best fit" in whatever context is provided.
|
|
@@ -5414,13 +5769,16 @@ function makeBestFit(input, filter, compare, updateNonBestFit) {
|
|
|
5414
5769
|
* For instance, if two items are selected but only one can be selected by design, this function can be used to
|
|
5415
5770
|
* pick the best fit, and update the input array.
|
|
5416
5771
|
*
|
|
5417
|
-
* @
|
|
5418
|
-
* @
|
|
5419
|
-
* @
|
|
5420
|
-
* @
|
|
5421
|
-
*
|
|
5422
|
-
|
|
5423
|
-
|
|
5772
|
+
* @dbxUtil
|
|
5773
|
+
* @dbxUtilCategory array
|
|
5774
|
+
* @dbxUtilTags array, best-fit, filter, sort, mutable, in-place
|
|
5775
|
+
* @dbxUtilRelated make-best-fit, find-best-index-set-pair
|
|
5776
|
+
*
|
|
5777
|
+
* @param input - The array to modify in-place.
|
|
5778
|
+
* @param config - The best-fit strategy ({@link BestFitConfig}).
|
|
5779
|
+
* @returns The modified input array with only the best fit item and transformed non-best-fit items.
|
|
5780
|
+
*/ function applyBestFit(input, config) {
|
|
5781
|
+
var filter = config.filter, compare = config.compare, updateNonBestFit = config.updateNonBestFit;
|
|
5424
5782
|
var matchIndexSet = findToIndexSet(input, filter);
|
|
5425
5783
|
if (matchIndexSet.length > 1) {
|
|
5426
5784
|
var expansion = expandIndexSet(input, matchIndexSet);
|
|
@@ -5438,9 +5796,16 @@ function applyBestFit(input, filter, compare, updateNonBestFit) {
|
|
|
5438
5796
|
* Creates a function that filters the input values and maps all matching values to a new value.
|
|
5439
5797
|
* This is a higher-order function that combines filtering and mapping operations.
|
|
5440
5798
|
*
|
|
5799
|
+
* @dbxUtil
|
|
5800
|
+
* @dbxUtilCategory array
|
|
5801
|
+
* @dbxUtilKind factory
|
|
5802
|
+
* @dbxUtilTags array, filter, map, transform, factory, iterable
|
|
5803
|
+
* @dbxUtilRelated array-decision-function
|
|
5804
|
+
*
|
|
5441
5805
|
* @param decisionFunction - Function that determines which items to include in the result
|
|
5442
5806
|
* @param mapFunction - Function that transforms each included item
|
|
5443
5807
|
* @returns A function that takes an iterable of input values and returns an array of transformed values
|
|
5808
|
+
* @__NO_SIDE_EFFECTS__
|
|
5444
5809
|
*/ function filterAndMapFunction(decisionFunction, mapFunction) {
|
|
5445
5810
|
return function(values) {
|
|
5446
5811
|
var result = [];
|
|
@@ -5464,6 +5829,7 @@ function applyBestFit(input, filter, compare, updateNonBestFit) {
|
|
|
5464
5829
|
*
|
|
5465
5830
|
* @param factory - The factory function used to generate each item
|
|
5466
5831
|
* @returns A function that takes a count parameter and returns an array of generated items
|
|
5832
|
+
* @__NO_SIDE_EFFECTS__
|
|
5467
5833
|
*/ function arrayFactory(factory) {
|
|
5468
5834
|
return function(count) {
|
|
5469
5835
|
return makeWithFactory(factory, count);
|
|
@@ -5480,6 +5846,7 @@ function applyBestFit(input, filter, compare, updateNonBestFit) {
|
|
|
5480
5846
|
*
|
|
5481
5847
|
* @param factory - The factory function used to transform each input value
|
|
5482
5848
|
* @returns A function that takes an array of input values and returns an array of output values
|
|
5849
|
+
* @__NO_SIDE_EFFECTS__
|
|
5483
5850
|
*/ function arrayInputFactory(factory) {
|
|
5484
5851
|
return function(input) {
|
|
5485
5852
|
return makeWithFactoryInput(factory, input);
|
|
@@ -5564,8 +5931,15 @@ function getArrayNextIndex(array, index) {
|
|
|
5564
5931
|
*
|
|
5565
5932
|
* Each accessor maps an index to the value whose range contains that index, or undefined if no range matches.
|
|
5566
5933
|
*
|
|
5934
|
+
* @dbxUtil
|
|
5935
|
+
* @dbxUtilCategory array
|
|
5936
|
+
* @dbxUtilKind factory
|
|
5937
|
+
* @dbxUtilTags array, indexed, range, accessor, factory, lookup
|
|
5938
|
+
* @dbxUtilRelated indexed-values-array-accessor-factory, ranged-indexed-values-array-accessor-info-factory
|
|
5939
|
+
*
|
|
5567
5940
|
* @param readIndexRange - Function that reads the index range from each value.
|
|
5568
5941
|
* @returns A factory that creates ranged accessors from arrays of values.
|
|
5942
|
+
* @__NO_SIDE_EFFECTS__
|
|
5569
5943
|
*/ function rangedIndexedValuesArrayAccessorFactory(readIndexRange) {
|
|
5570
5944
|
var readInfoFactory = rangedIndexedValuesArrayAccessorInfoFactory({
|
|
5571
5945
|
readIndexRange: readIndexRange
|
|
@@ -5584,9 +5958,16 @@ function getArrayNextIndex(array, index) {
|
|
|
5584
5958
|
* Each accessor maps an index to the matching value, falling back to the previous value, then the next value.
|
|
5585
5959
|
* This guarantees a value is always returned.
|
|
5586
5960
|
*
|
|
5961
|
+
* @dbxUtil
|
|
5962
|
+
* @dbxUtilCategory array
|
|
5963
|
+
* @dbxUtilKind factory
|
|
5964
|
+
* @dbxUtilTags array, indexed, range, accessor, factory, fallback
|
|
5965
|
+
* @dbxUtilRelated ranged-indexed-values-array-accessor-factory, ranged-indexed-values-array-accessor-info-factory
|
|
5966
|
+
*
|
|
5587
5967
|
* @param readIndexRange - Function that reads the index range from each value.
|
|
5588
5968
|
* @returns A factory that creates indexed accessors from arrays of values.
|
|
5589
5969
|
* @throws Error if the provided values array is empty.
|
|
5970
|
+
* @__NO_SIDE_EFFECTS__
|
|
5590
5971
|
*/ function indexedValuesArrayAccessorFactory(readIndexRange) {
|
|
5591
5972
|
var readInfoFactory = rangedIndexedValuesArrayAccessorInfoFactory({
|
|
5592
5973
|
readIndexRange: readIndexRange
|
|
@@ -5610,8 +5991,15 @@ function getArrayNextIndex(array, index) {
|
|
|
5610
5991
|
* Each accessor sorts the values by their index ranges in ascending order, then for a given index
|
|
5611
5992
|
* returns the matching value along with its previous and next neighbors.
|
|
5612
5993
|
*
|
|
5994
|
+
* @dbxUtil
|
|
5995
|
+
* @dbxUtilCategory array
|
|
5996
|
+
* @dbxUtilKind factory
|
|
5997
|
+
* @dbxUtilTags array, indexed, range, accessor, info, factory, neighbors
|
|
5998
|
+
* @dbxUtilRelated ranged-indexed-values-array-accessor-factory, indexed-values-array-accessor-factory
|
|
5999
|
+
*
|
|
5613
6000
|
* @param config - Configuration containing the index range reader function.
|
|
5614
6001
|
* @returns A factory that creates ranged info accessors from arrays of values.
|
|
6002
|
+
* @__NO_SIDE_EFFECTS__
|
|
5615
6003
|
*/ function rangedIndexedValuesArrayAccessorInfoFactory(config) {
|
|
5616
6004
|
var pairFactory = indexRangeReaderPairFactory(config.readIndexRange);
|
|
5617
6005
|
return function(values) {
|
|
@@ -5677,8 +6065,15 @@ function limitArray(array, inputConfig) {
|
|
|
5677
6065
|
/**
|
|
5678
6066
|
* Creates a factory function that generates arrays of a random length populated with items from a make function.
|
|
5679
6067
|
*
|
|
6068
|
+
* @dbxUtil
|
|
6069
|
+
* @dbxUtilCategory array
|
|
6070
|
+
* @dbxUtilKind factory
|
|
6071
|
+
* @dbxUtilTags array, random, factory, generate, make
|
|
6072
|
+
* @dbxUtilRelated array-factory, random-number-factory
|
|
6073
|
+
*
|
|
5680
6074
|
* @param config - configuration containing the make function and random number source
|
|
5681
6075
|
* @returns a factory that produces arrays of random length, optionally accepting a specific count override
|
|
6076
|
+
* @__NO_SIDE_EFFECTS__
|
|
5682
6077
|
*/ function randomArrayFactory(config) {
|
|
5683
6078
|
var randomFn = typeof config.random === 'function' ? config.random : randomNumberFactory(config.random);
|
|
5684
6079
|
var nextRandomCount = function nextRandomCount() {
|
|
@@ -5745,6 +6140,7 @@ function generateIfDoesNotExist(keys, existing, readKey, generateFn) {
|
|
|
5745
6140
|
* @param values - array of values to randomly pick from
|
|
5746
6141
|
* @returns a callable factory that returns a random value from the array on each invocation
|
|
5747
6142
|
* @throws Error if the input array is empty
|
|
6143
|
+
* @__NO_SIDE_EFFECTS__
|
|
5748
6144
|
*/ function randomPickFactory(values) {
|
|
5749
6145
|
if (values.length === 0) {
|
|
5750
6146
|
throw new Error('randomPickFactory() cannot use an empty array.');
|
|
@@ -6054,6 +6450,7 @@ function caseInsensitiveString(input) {
|
|
|
6054
6450
|
*
|
|
6055
6451
|
* @param config - configuration controlling max length and end text behavior
|
|
6056
6452
|
* @returns a reusable function that truncates input strings
|
|
6453
|
+
* @__NO_SIDE_EFFECTS__
|
|
6057
6454
|
*/ function cutStringFunction(config) {
|
|
6058
6455
|
var inputMaxLength = config.maxLength, maxLengthIncludesEndText = config.maxLengthIncludesEndText, inputEndText = config.endText;
|
|
6059
6456
|
var endText = inputEndText === undefined ? DEFAULT_CUT_STRING_END_TEXT : '';
|
|
@@ -6170,24 +6567,42 @@ function caseInsensitiveString(input) {
|
|
|
6170
6567
|
/**
|
|
6171
6568
|
* Trims leading and trailing whitespace from a string.
|
|
6172
6569
|
*
|
|
6570
|
+
* @dbxUtil
|
|
6571
|
+
* @dbxUtilCategory string
|
|
6572
|
+
* @dbxUtilTags string, trim, whitespace, transform
|
|
6573
|
+
* @dbxUtilRelated transform-string-function
|
|
6574
|
+
*
|
|
6173
6575
|
* @param input The string to trim.
|
|
6174
6576
|
* @returns The trimmed string.
|
|
6577
|
+
* @__NO_SIDE_EFFECTS__
|
|
6175
6578
|
*/ function stringTrimFunction(input) {
|
|
6176
6579
|
return input.trim();
|
|
6177
6580
|
}
|
|
6178
6581
|
/**
|
|
6179
6582
|
* Converts a string to uppercase.
|
|
6180
6583
|
*
|
|
6584
|
+
* @dbxUtil
|
|
6585
|
+
* @dbxUtilCategory string
|
|
6586
|
+
* @dbxUtilTags string, uppercase, case, transform
|
|
6587
|
+
* @dbxUtilRelated string-to-lowercase-function, transform-string-function
|
|
6588
|
+
*
|
|
6181
6589
|
* @param input The string to convert.
|
|
6182
6590
|
* @returns The uppercase string.
|
|
6591
|
+
* @__NO_SIDE_EFFECTS__
|
|
6183
6592
|
*/ function stringToUppercaseFunction(input) {
|
|
6184
6593
|
return input.toUpperCase();
|
|
6185
6594
|
}
|
|
6186
6595
|
/**
|
|
6187
6596
|
* Converts a string to lowercase.
|
|
6188
6597
|
*
|
|
6598
|
+
* @dbxUtil
|
|
6599
|
+
* @dbxUtilCategory string
|
|
6600
|
+
* @dbxUtilTags string, lowercase, case, transform
|
|
6601
|
+
* @dbxUtilRelated string-to-uppercase-function, transform-string-function
|
|
6602
|
+
*
|
|
6189
6603
|
* @param input The string to convert.
|
|
6190
6604
|
* @returns The lowercase string.
|
|
6605
|
+
* @__NO_SIDE_EFFECTS__
|
|
6191
6606
|
*/ function stringToLowercaseFunction(input) {
|
|
6192
6607
|
return input.toLowerCase();
|
|
6193
6608
|
}
|
|
@@ -6214,9 +6629,16 @@ function caseInsensitiveString(input) {
|
|
|
6214
6629
|
* 4. Lowercase conversion (if `config.toLowercase` is true and no `config.transform` or `config.toUppercase`).
|
|
6215
6630
|
* If no transformations are specified, the identity function is returned.
|
|
6216
6631
|
*
|
|
6632
|
+
* @dbxUtil
|
|
6633
|
+
* @dbxUtilCategory string
|
|
6634
|
+
* @dbxUtilKind factory
|
|
6635
|
+
* @dbxUtilTags string, transform, trim, case, slice, factory
|
|
6636
|
+
* @dbxUtilRelated string-trim-function, string-to-uppercase-function, string-to-lowercase-function, slice-string-function
|
|
6637
|
+
*
|
|
6217
6638
|
* @template S The specific string type, defaults to `string`.
|
|
6218
6639
|
* @param config The `TransformStringFunctionConfig` detailing the transformations.
|
|
6219
6640
|
* @returns A `TransformStringFunction` that applies the configured transformations.
|
|
6641
|
+
* @__NO_SIDE_EFFECTS__
|
|
6220
6642
|
*/ function transformStringFunction(config) {
|
|
6221
6643
|
var baseTransform;
|
|
6222
6644
|
if (config.transform) {
|
|
@@ -6262,8 +6684,15 @@ function caseInsensitiveString(input) {
|
|
|
6262
6684
|
/**
|
|
6263
6685
|
* Creates a function that adds a configured prefix to the input string if it does not exist on that string.
|
|
6264
6686
|
*
|
|
6687
|
+
* @dbxUtil
|
|
6688
|
+
* @dbxUtilCategory string
|
|
6689
|
+
* @dbxUtilKind factory
|
|
6690
|
+
* @dbxUtilTags string, prefix, add, factory
|
|
6691
|
+
* @dbxUtilRelated add-prefix, add-suffix-function
|
|
6692
|
+
*
|
|
6265
6693
|
* @param prefix The prefix to add.
|
|
6266
6694
|
* @returns A function that adds the prefix to a string.
|
|
6695
|
+
* @__NO_SIDE_EFFECTS__
|
|
6267
6696
|
*/ function addPrefixFunction(prefix) {
|
|
6268
6697
|
return function(input) {
|
|
6269
6698
|
return input.startsWith(prefix) ? input : prefix + input;
|
|
@@ -6281,8 +6710,15 @@ function caseInsensitiveString(input) {
|
|
|
6281
6710
|
/**
|
|
6282
6711
|
* Creates a function that adds a configured suffix to the input string if it does not exist on that string.
|
|
6283
6712
|
*
|
|
6713
|
+
* @dbxUtil
|
|
6714
|
+
* @dbxUtilCategory string
|
|
6715
|
+
* @dbxUtilKind factory
|
|
6716
|
+
* @dbxUtilTags string, suffix, add, factory
|
|
6717
|
+
* @dbxUtilRelated add-suffix, add-prefix-function
|
|
6718
|
+
*
|
|
6284
6719
|
* @param suffix The suffix to add.
|
|
6285
6720
|
* @returns A function that adds the suffix to a string.
|
|
6721
|
+
* @__NO_SIDE_EFFECTS__
|
|
6286
6722
|
*/ function addSuffixFunction(suffix) {
|
|
6287
6723
|
return function(input) {
|
|
6288
6724
|
return input.endsWith(suffix) ? input : input + suffix;
|
|
@@ -6291,9 +6727,16 @@ function caseInsensitiveString(input) {
|
|
|
6291
6727
|
/**
|
|
6292
6728
|
* Pads the start of a string to a minimum length.
|
|
6293
6729
|
*
|
|
6730
|
+
* @dbxUtil
|
|
6731
|
+
* @dbxUtilCategory string
|
|
6732
|
+
* @dbxUtilKind factory
|
|
6733
|
+
* @dbxUtilTags string, pad, start, factory, minimum-length
|
|
6734
|
+
* @dbxUtilRelated transform-string-function
|
|
6735
|
+
*
|
|
6294
6736
|
* @param minLength The minimum length of the string.
|
|
6295
6737
|
* @param padCharacter The character to use for padding.
|
|
6296
6738
|
* @returns A function that pads the start of a string.
|
|
6739
|
+
* @__NO_SIDE_EFFECTS__
|
|
6297
6740
|
*/ function padStartFunction(minLength, padCharacter) {
|
|
6298
6741
|
return function(input) {
|
|
6299
6742
|
return input.padStart(minLength, padCharacter);
|
|
@@ -6302,8 +6745,15 @@ function caseInsensitiveString(input) {
|
|
|
6302
6745
|
/**
|
|
6303
6746
|
* Creates a function that slices and concats parts of a string based on the configuration.
|
|
6304
6747
|
*
|
|
6748
|
+
* @dbxUtil
|
|
6749
|
+
* @dbxUtilCategory string
|
|
6750
|
+
* @dbxUtilKind factory
|
|
6751
|
+
* @dbxUtilTags string, slice, take, factory, from-start, from-end
|
|
6752
|
+
* @dbxUtilRelated transform-string-function
|
|
6753
|
+
*
|
|
6305
6754
|
* @param config The configuration for the slice function.
|
|
6306
6755
|
* @returns A SliceStringFunction.
|
|
6756
|
+
* @__NO_SIDE_EFFECTS__
|
|
6307
6757
|
*/ function sliceStringFunction(config) {
|
|
6308
6758
|
var fromStart = config.fromStart, fromEnd = config.fromEnd;
|
|
6309
6759
|
var takeFromStart = Math.abs(fromStart !== null && fromStart !== void 0 ? fromStart : 0);
|
|
@@ -6851,8 +7301,15 @@ function _object_spread$f(target) {
|
|
|
6851
7301
|
* The merged function returns true only if all individual filters pass (AND logic).
|
|
6852
7302
|
* Null/undefined filters are ignored.
|
|
6853
7303
|
*
|
|
7304
|
+
* @dbxUtil
|
|
7305
|
+
* @dbxUtilCategory value
|
|
7306
|
+
* @dbxUtilKind factory
|
|
7307
|
+
* @dbxUtilTags filter, merge, compose, factory, and
|
|
7308
|
+
* @dbxUtilRelated invert-filter, invert-boolean-return-function
|
|
7309
|
+
*
|
|
6854
7310
|
* @param inputFilters - The filter functions to merge
|
|
6855
7311
|
* @returns A single FilterFunction that applies all filters
|
|
7312
|
+
* @__NO_SIDE_EFFECTS__
|
|
6856
7313
|
*/ function mergeFilterFunctions() {
|
|
6857
7314
|
for(var _len = arguments.length, inputFilters = new Array(_len), _key = 0; _key < _len; _key++){
|
|
6858
7315
|
inputFilters[_key] = arguments[_key];
|
|
@@ -6989,6 +7446,14 @@ function _unsupported_iterable_to_array$r(o, minLen) {
|
|
|
6989
7446
|
* const tuples = getDefinedTuples({ a: 1, b: undefined, c: 'hello' });
|
|
6990
7447
|
* // tuples: [['a', 1], ['c', 'hello']]
|
|
6991
7448
|
* ```
|
|
7449
|
+
*
|
|
7450
|
+
* @dbxUtil
|
|
7451
|
+
* @dbxUtilCategory object
|
|
7452
|
+
* @dbxUtilKind factory
|
|
7453
|
+
* @dbxUtilTags object, tuples, filter, factory, key-value
|
|
7454
|
+
* @dbxUtilRelated filter-key-value-tuple-function, for-each-key-value
|
|
7455
|
+
*
|
|
7456
|
+
* @__NO_SIDE_EFFECTS__
|
|
6992
7457
|
*/ function filterKeyValueTuplesFunction(filter) {
|
|
6993
7458
|
var result;
|
|
6994
7459
|
if (filter != null) {
|
|
@@ -7073,6 +7538,14 @@ function _unsupported_iterable_to_array$r(o, minLen) {
|
|
|
7073
7538
|
* isNotNull(['a', 1], 0); // true
|
|
7074
7539
|
* isNotNull(['b', null], 0); // false
|
|
7075
7540
|
* ```
|
|
7541
|
+
*
|
|
7542
|
+
* @dbxUtil
|
|
7543
|
+
* @dbxUtilCategory object
|
|
7544
|
+
* @dbxUtilKind factory
|
|
7545
|
+
* @dbxUtilTags object, tuple, filter, predicate, factory, key-value
|
|
7546
|
+
* @dbxUtilRelated filter-key-value-tuples-function
|
|
7547
|
+
*
|
|
7548
|
+
* @__NO_SIDE_EFFECTS__
|
|
7076
7549
|
*/ function filterKeyValueTupleFunction(inputFilter) {
|
|
7077
7550
|
var filter = filterKeyValueTuplesInputToFilter(inputFilter);
|
|
7078
7551
|
var tmp = filter.valueFilter, type = tmp === void 0 ? KeyValueTypleValueFilter.UNDEFINED : tmp, tmp1 = filter.invertFilter, inverseFilter = tmp1 === void 0 ? false : tmp1, keysFilter = filter.keysFilter;
|
|
@@ -7143,8 +7616,15 @@ function _unsupported_iterable_to_array$r(o, minLen) {
|
|
|
7143
7616
|
/**
|
|
7144
7617
|
* Creates a factory that returns a random element from the given array on each call.
|
|
7145
7618
|
*
|
|
7619
|
+
* @dbxUtil
|
|
7620
|
+
* @dbxUtilCategory getter
|
|
7621
|
+
* @dbxUtilKind factory
|
|
7622
|
+
* @dbxUtilTags getter, factory, random, array, sample
|
|
7623
|
+
* @dbxUtilRelated random-number-factory, random-array-factory
|
|
7624
|
+
*
|
|
7146
7625
|
* @param values - The array of values to randomly select from
|
|
7147
7626
|
* @returns A factory that returns a random element from the array
|
|
7627
|
+
* @__NO_SIDE_EFFECTS__
|
|
7148
7628
|
*/ function randomFromArrayFactory(values) {
|
|
7149
7629
|
var randomIndex = randomNumberFactory({
|
|
7150
7630
|
min: 0,
|
|
@@ -7196,8 +7676,15 @@ function cachedGetter(factory) {
|
|
|
7196
7676
|
/**
|
|
7197
7677
|
* Creates a factory that wraps Getters with a mapping function.
|
|
7198
7678
|
*
|
|
7679
|
+
* @dbxUtil
|
|
7680
|
+
* @dbxUtilCategory getter
|
|
7681
|
+
* @dbxUtilKind factory
|
|
7682
|
+
* @dbxUtilTags getter, map, transform, factory
|
|
7683
|
+
* @dbxUtilRelated map-getter
|
|
7684
|
+
*
|
|
7199
7685
|
* @param mapFn - The mapping function to apply
|
|
7200
7686
|
* @returns A factory that transforms Getters of type I to Getters of type O
|
|
7687
|
+
* @__NO_SIDE_EFFECTS__
|
|
7201
7688
|
*/ function mapGetterFactory(mapFn) {
|
|
7202
7689
|
return function(getter) {
|
|
7203
7690
|
return function() {
|
|
@@ -7295,12 +7782,19 @@ function _unsupported_iterable_to_array$q(o, minLen) {
|
|
|
7295
7782
|
* @param copy - When true (default), the returned function shallow-copies the input before filtering instead of mutating it.
|
|
7296
7783
|
* @returns A function that returns the stripped object, or `undefined` when filtering removed every key.
|
|
7297
7784
|
*
|
|
7785
|
+
* @dbxUtil
|
|
7786
|
+
* @dbxUtilCategory object
|
|
7787
|
+
* @dbxUtilKind factory
|
|
7788
|
+
* @dbxUtilTags object, strip, filter, factory, undefined, empty
|
|
7789
|
+
* @dbxUtilRelated strip-object, filter-from-pojo-function
|
|
7790
|
+
*
|
|
7298
7791
|
* @example
|
|
7299
7792
|
* ```ts
|
|
7300
7793
|
* const stripUndef = stripObjectFunction(KeyValueTypleValueFilter.UNDEFINED);
|
|
7301
7794
|
* stripUndef({ a: 1, b: undefined }); // { a: 1 }
|
|
7302
7795
|
* stripUndef({ a: undefined }); // undefined
|
|
7303
7796
|
* ```
|
|
7797
|
+
* @__NO_SIDE_EFFECTS__
|
|
7304
7798
|
*/ function stripObjectFunction(filter) {
|
|
7305
7799
|
var copy = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
|
|
7306
7800
|
var filterFn = filterFromPOJOFunction({
|
|
@@ -7389,6 +7883,14 @@ function _unsupported_iterable_to_array$q(o, minLen) {
|
|
|
7389
7883
|
* const result = overrideFn({ color: 'blue', size: 5 });
|
|
7390
7884
|
* // result is { color: 'red', size: 10 } (a new copy)
|
|
7391
7885
|
* ```
|
|
7886
|
+
*
|
|
7887
|
+
* @dbxUtil
|
|
7888
|
+
* @dbxUtilCategory object
|
|
7889
|
+
* @dbxUtilKind factory
|
|
7890
|
+
* @dbxUtilTags object, override, factory, merge, template, cached
|
|
7891
|
+
* @dbxUtilRelated override-in-object, merge-objects-function, filter-from-pojo-function
|
|
7892
|
+
*
|
|
7893
|
+
* @__NO_SIDE_EFFECTS__
|
|
7392
7894
|
*/ function overrideInObjectFunctionFactory(param) {
|
|
7393
7895
|
var filter = param.filter, copy = param.copy, _param_dynamic = param.dynamic, dynamic = _param_dynamic === void 0 ? false : _param_dynamic;
|
|
7394
7896
|
var filterToRelevantValuesObject = filter != null ? filterFromPOJOFunction({
|
|
@@ -7458,6 +7960,14 @@ function _unsupported_iterable_to_array$q(o, minLen) {
|
|
|
7458
7960
|
* // With null filter to also exclude null values:
|
|
7459
7961
|
* const mergeNoNulls = mergeObjectsFunction(KeyValueTypleValueFilter.NULL);
|
|
7460
7962
|
* ```
|
|
7963
|
+
*
|
|
7964
|
+
* @dbxUtil
|
|
7965
|
+
* @dbxUtilCategory object
|
|
7966
|
+
* @dbxUtilKind factory
|
|
7967
|
+
* @dbxUtilTags object, merge, factory, filter
|
|
7968
|
+
* @dbxUtilRelated merge-objects, override-in-object-function-factory
|
|
7969
|
+
*
|
|
7970
|
+
* @__NO_SIDE_EFFECTS__
|
|
7461
7971
|
*/ function mergeObjectsFunction(filter) {
|
|
7462
7972
|
var overrideFn = overrideInObjectFunctionFactory({
|
|
7463
7973
|
filter: filter,
|
|
@@ -7622,6 +8132,14 @@ function _unsupported_iterable_to_array$q(o, minLen) {
|
|
|
7622
8132
|
* findDefinedKeys({ a: 1, b: undefined, c: 'hello' });
|
|
7623
8133
|
* // ['a', 'c']
|
|
7624
8134
|
* ```
|
|
8135
|
+
*
|
|
8136
|
+
* @dbxUtil
|
|
8137
|
+
* @dbxUtilCategory object
|
|
8138
|
+
* @dbxUtilKind factory
|
|
8139
|
+
* @dbxUtilTags object, pojo, keys, find, factory, filter
|
|
8140
|
+
* @dbxUtilRelated find-pojo-keys, count-pojo-keys-function, for-each-key-value-on-pojo-function
|
|
8141
|
+
*
|
|
8142
|
+
* @__NO_SIDE_EFFECTS__
|
|
7625
8143
|
*/ function findPOJOKeysFunction(filter) {
|
|
7626
8144
|
var findEachMatchingKeyOnTarget = forEachKeyValueOnPOJOFunction({
|
|
7627
8145
|
filter: filter,
|
|
@@ -7675,6 +8193,14 @@ function _unsupported_iterable_to_array$q(o, minLen) {
|
|
|
7675
8193
|
* countDefined({ a: 1, b: undefined, c: 'test' });
|
|
7676
8194
|
* // 2
|
|
7677
8195
|
* ```
|
|
8196
|
+
*
|
|
8197
|
+
* @dbxUtil
|
|
8198
|
+
* @dbxUtilCategory object
|
|
8199
|
+
* @dbxUtilKind factory
|
|
8200
|
+
* @dbxUtilTags object, pojo, keys, count, factory, filter
|
|
8201
|
+
* @dbxUtilRelated count-pojo-keys, find-pojo-keys-function
|
|
8202
|
+
*
|
|
8203
|
+
* @__NO_SIDE_EFFECTS__
|
|
7678
8204
|
*/ function countPOJOKeysFunction() {
|
|
7679
8205
|
var filter = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : KeyValueTypleValueFilter.UNDEFINED;
|
|
7680
8206
|
var countEachMatchingKeyOnTarget = forEachKeyValueOnPOJOFunction({
|
|
@@ -7741,6 +8267,14 @@ function _unsupported_iterable_to_array$q(o, minLen) {
|
|
|
7741
8267
|
* const result = filterNulls({ a: 1, b: null, c: undefined });
|
|
7742
8268
|
* // result is { a: 1 }, original is unchanged
|
|
7743
8269
|
* ```
|
|
8270
|
+
*
|
|
8271
|
+
* @dbxUtil
|
|
8272
|
+
* @dbxUtilCategory object
|
|
8273
|
+
* @dbxUtilKind factory
|
|
8274
|
+
* @dbxUtilTags object, pojo, filter, factory, remove, copy
|
|
8275
|
+
* @dbxUtilRelated filter-from-pojo, strip-object-function, assign-values-to-pojo-function
|
|
8276
|
+
*
|
|
8277
|
+
* @__NO_SIDE_EFFECTS__
|
|
7744
8278
|
*/ function filterFromPOJOFunction() {
|
|
7745
8279
|
var _ref = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {}, _ref_copy = _ref.copy, copy = _ref_copy === void 0 ? false : _ref_copy, tmp = _ref.filter, inputFilter = tmp === void 0 ? {
|
|
7746
8280
|
valueFilter: KeyValueTypleValueFilter.UNDEFINED
|
|
@@ -7818,6 +8352,14 @@ function _unsupported_iterable_to_array$q(o, minLen) {
|
|
|
7818
8352
|
* // With NULL filter and no copy:
|
|
7819
8353
|
* const assignNoNulls = assignValuesToPOJOFunction({ valueFilter: KeyValueTypleValueFilter.NULL, copy: false });
|
|
7820
8354
|
* ```
|
|
8355
|
+
*
|
|
8356
|
+
* @dbxUtil
|
|
8357
|
+
* @dbxUtilCategory object
|
|
8358
|
+
* @dbxUtilKind factory
|
|
8359
|
+
* @dbxUtilTags object, pojo, assign, factory, filter, copy
|
|
8360
|
+
* @dbxUtilRelated assign-values-to-pojo, filter-from-pojo-function
|
|
8361
|
+
*
|
|
8362
|
+
* @__NO_SIDE_EFFECTS__
|
|
7821
8363
|
*/ function assignValuesToPOJOFunction() {
|
|
7822
8364
|
var input = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : KeyValueTypleValueFilter.UNDEFINED;
|
|
7823
8365
|
var _ref;
|
|
@@ -7883,6 +8425,14 @@ function _unsupported_iterable_to_array$q(o, minLen) {
|
|
|
7883
8425
|
* getNonNullValues({ a: 1, b: null, c: undefined });
|
|
7884
8426
|
* // [1]
|
|
7885
8427
|
* ```
|
|
8428
|
+
*
|
|
8429
|
+
* @dbxUtil
|
|
8430
|
+
* @dbxUtilCategory object
|
|
8431
|
+
* @dbxUtilKind factory
|
|
8432
|
+
* @dbxUtilTags object, pojo, values, factory, filter, extract
|
|
8433
|
+
* @dbxUtilRelated values-from-pojo, find-pojo-keys-function
|
|
8434
|
+
*
|
|
8435
|
+
* @__NO_SIDE_EFFECTS__
|
|
7886
8436
|
*/ function valuesFromPOJOFunction() {
|
|
7887
8437
|
var filter = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : KeyValueTypleValueFilter.UNDEFINED;
|
|
7888
8438
|
var addValuesFromObjectToContext = forEachKeyValueOnPOJOFunction({
|
|
@@ -7922,6 +8472,14 @@ function _unsupported_iterable_to_array$q(o, minLen) {
|
|
|
7922
8472
|
* omitAB({ a: 1, b: 2, c: 3 });
|
|
7923
8473
|
* // { c: 3 }
|
|
7924
8474
|
* ```
|
|
8475
|
+
*
|
|
8476
|
+
* @dbxUtil
|
|
8477
|
+
* @dbxUtilCategory object
|
|
8478
|
+
* @dbxUtilKind factory
|
|
8479
|
+
* @dbxUtilTags object, pojo, keys, filter, pick, omit, factory
|
|
8480
|
+
* @dbxUtilRelated filter-tuples-on-pojo-function, filter-from-pojo-function
|
|
8481
|
+
*
|
|
8482
|
+
* @__NO_SIDE_EFFECTS__
|
|
7925
8483
|
*/ function filterKeysOnPOJOFunction(keysToFilter) {
|
|
7926
8484
|
var invertFilter = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
7927
8485
|
var keysSet = new Set(keysToFilter);
|
|
@@ -7946,6 +8504,14 @@ function _unsupported_iterable_to_array$q(o, minLen) {
|
|
|
7946
8504
|
* keepStrings({ a: 'hello', b: 42, c: 'world' });
|
|
7947
8505
|
* // { a: 'hello', c: 'world' }
|
|
7948
8506
|
* ```
|
|
8507
|
+
*
|
|
8508
|
+
* @dbxUtil
|
|
8509
|
+
* @dbxUtilCategory object
|
|
8510
|
+
* @dbxUtilKind factory
|
|
8511
|
+
* @dbxUtilTags object, pojo, tuples, filter, predicate, factory
|
|
8512
|
+
* @dbxUtilRelated filter-keys-on-pojo-function, filter-from-pojo-function
|
|
8513
|
+
*
|
|
8514
|
+
* @__NO_SIDE_EFFECTS__
|
|
7949
8515
|
*/ function filterTuplesOnPOJOFunction(filterTupleOnObject) {
|
|
7950
8516
|
return function(input) {
|
|
7951
8517
|
var result = {};
|
|
@@ -7980,6 +8546,14 @@ function _unsupported_iterable_to_array$q(o, minLen) {
|
|
|
7980
8546
|
* logDefined({ a: 1, b: undefined, c: 'test' });
|
|
7981
8547
|
* // logs: 'a' 1, 'c' 'test'
|
|
7982
8548
|
* ```
|
|
8549
|
+
*
|
|
8550
|
+
* @dbxUtil
|
|
8551
|
+
* @dbxUtilCategory object
|
|
8552
|
+
* @dbxUtilKind factory
|
|
8553
|
+
* @dbxUtilTags object, pojo, for-each, iterate, factory, callback
|
|
8554
|
+
* @dbxUtilRelated find-pojo-keys-function, count-pojo-keys-function, filter-key-value-tuples-function
|
|
8555
|
+
*
|
|
8556
|
+
* @__NO_SIDE_EFFECTS__
|
|
7983
8557
|
*/ function forEachKeyValueOnPOJOFunction(param) {
|
|
7984
8558
|
var forEach = param.forEach, filter = param.filter;
|
|
7985
8559
|
var filterKeyValues = filterKeyValueTuplesFunction(filter);
|
|
@@ -8039,8 +8613,15 @@ function isInSetDecisionFunction(set, inputReadValue) {
|
|
|
8039
8613
|
* Creates a {@link SetDeltaFunction} that computes the differences between two iterables,
|
|
8040
8614
|
* identifying which items were added, removed, or unchanged.
|
|
8041
8615
|
*
|
|
8616
|
+
* @dbxUtil
|
|
8617
|
+
* @dbxUtilCategory set
|
|
8618
|
+
* @dbxUtilKind factory
|
|
8619
|
+
* @dbxUtilTags set, delta, diff, factory, change, added, removed
|
|
8620
|
+
* @dbxUtilRelated index-delta-group-function, set-has-value-function
|
|
8621
|
+
*
|
|
8042
8622
|
* @param config - Configuration with the key reader and optional modification detector.
|
|
8043
8623
|
* @returns A function that compares two iterables and returns an array of change pairs.
|
|
8624
|
+
* @__NO_SIDE_EFFECTS__
|
|
8044
8625
|
*/ function setDeltaFunction(config) {
|
|
8045
8626
|
var readKey = config.readKey, _config_isModifiedFunction = config.isModifiedFunction, isModifiedFunction = _config_isModifiedFunction === void 0 ? function() {
|
|
8046
8627
|
return undefined;
|
|
@@ -8187,9 +8768,16 @@ var AUTH_ROLE_CLAIMS_DEFAULT_EMPTY_VALUE = null;
|
|
|
8187
8768
|
* Each key in the config maps a claim key to role(s). Simple entries map a claim value to one or more roles,
|
|
8188
8769
|
* while encode/decode entries allow custom bidirectional conversion logic.
|
|
8189
8770
|
*
|
|
8771
|
+
* @dbxUtil
|
|
8772
|
+
* @dbxUtilCategory auth
|
|
8773
|
+
* @dbxUtilKind factory
|
|
8774
|
+
* @dbxUtilTags auth, role, claims, jwt, factory, bidirectional
|
|
8775
|
+
* @dbxUtilRelated auth-role
|
|
8776
|
+
*
|
|
8190
8777
|
* @param config - Mapping of claim keys to their role configuration entries (or null to ignore)
|
|
8191
8778
|
* @param defaults - Optional default values for claim presence and absence
|
|
8192
8779
|
* @returns A service with `toClaims` and `toRoles` conversion functions
|
|
8780
|
+
* @__NO_SIDE_EFFECTS__
|
|
8193
8781
|
*/ function authRoleClaimsService(config) {
|
|
8194
8782
|
var defaults = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
8195
8783
|
var _ref, _ref1;
|
|
@@ -9897,9 +10485,16 @@ function _unsupported_iterable_to_array$o(o, minLen) {
|
|
|
9897
10485
|
* Creates a function that replaces the last character of a string with the replacement string
|
|
9898
10486
|
* if that character matches any of the specified values.
|
|
9899
10487
|
*
|
|
10488
|
+
* @dbxUtil
|
|
10489
|
+
* @dbxUtilCategory string
|
|
10490
|
+
* @dbxUtilKind factory
|
|
10491
|
+
* @dbxUtilTags string, replace, last, character, conditional, factory
|
|
10492
|
+
* @dbxUtilRelated replace-last-character-if, replace-character-at-index-if
|
|
10493
|
+
*
|
|
9900
10494
|
* @param replacement - string to substitute for the last character
|
|
9901
10495
|
* @param is - character(s) that trigger the replacement
|
|
9902
10496
|
* @returns a function that conditionally replaces the last character
|
|
10497
|
+
* @__NO_SIDE_EFFECTS__
|
|
9903
10498
|
*/ function replaceLastCharacterIfIsFunction(replacement, is) {
|
|
9904
10499
|
var matches = new Set(is);
|
|
9905
10500
|
return function(input) {
|
|
@@ -10069,8 +10664,15 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10069
10664
|
/**
|
|
10070
10665
|
* Creates a function that replaces all occurrences of the configured target strings with a replacement value.
|
|
10071
10666
|
*
|
|
10667
|
+
* @dbxUtil
|
|
10668
|
+
* @dbxUtilCategory string
|
|
10669
|
+
* @dbxUtilKind factory
|
|
10670
|
+
* @dbxUtilTags string, replace, regex, substitute, factory
|
|
10671
|
+
* @dbxUtilRelated find-strings-regex-string, escape-string-for-regex
|
|
10672
|
+
*
|
|
10072
10673
|
* @param config - Configuration specifying strings to find and the replacement value.
|
|
10073
10674
|
* @returns A function that performs the configured replacements on an input string.
|
|
10675
|
+
* @__NO_SIDE_EFFECTS__
|
|
10074
10676
|
*/ function replaceStringsFunction(config) {
|
|
10075
10677
|
var replaceInput = config.replace, replaceWith = config.replaceWith;
|
|
10076
10678
|
var replaceRegexString = findStringsRegexString(replaceInput);
|
|
@@ -10103,6 +10705,11 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10103
10705
|
/**
|
|
10104
10706
|
* Creates an escaped regex string that matches any of the input values, joined with the OR (`|`) operator.
|
|
10105
10707
|
*
|
|
10708
|
+
* @dbxUtil
|
|
10709
|
+
* @dbxUtilCategory string
|
|
10710
|
+
* @dbxUtilTags string, regex, escape, alternation, pattern
|
|
10711
|
+
* @dbxUtilRelated escape-string-for-regex, replace-strings-function
|
|
10712
|
+
*
|
|
10106
10713
|
* @param find - One or more strings to create a matching regex pattern for.
|
|
10107
10714
|
* @returns A regex-compatible string with special characters escaped and values joined by `|`.
|
|
10108
10715
|
*/ function findStringsRegexString(find) {
|
|
@@ -10113,8 +10720,15 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10113
10720
|
/**
|
|
10114
10721
|
* Creates an {@link EscapeStringCharactersFunction} that escapes specific characters in a string using the configured escape strategy.
|
|
10115
10722
|
*
|
|
10723
|
+
* @dbxUtil
|
|
10724
|
+
* @dbxUtilCategory string
|
|
10725
|
+
* @dbxUtilKind factory
|
|
10726
|
+
* @dbxUtilTags string, escape, characters, factory, transform
|
|
10727
|
+
* @dbxUtilRelated escape-string-for-regex, find-all-character-occurences-function
|
|
10728
|
+
*
|
|
10116
10729
|
* @param config - Configuration specifying which characters to escape and how to escape them.
|
|
10117
10730
|
* @returns A function that escapes the configured characters in any input string.
|
|
10731
|
+
* @__NO_SIDE_EFFECTS__
|
|
10118
10732
|
*/ function escapeStringCharactersFunction(config) {
|
|
10119
10733
|
var inputEscapeTargets = config.escapeTargets, escapeCharacter = config.escapeCharacter;
|
|
10120
10734
|
var escapeTargets = _instanceof$3(inputEscapeTargets, Set) ? inputEscapeTargets : new Set(inputEscapeTargets);
|
|
@@ -10162,6 +10776,12 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10162
10776
|
*
|
|
10163
10777
|
* For instance, `'hello.world'` will be escaped to `'hello\\.world'`.
|
|
10164
10778
|
*
|
|
10779
|
+
* @dbxUtil
|
|
10780
|
+
* @dbxUtilCategory string
|
|
10781
|
+
* @dbxUtilKind const
|
|
10782
|
+
* @dbxUtilTags string, regex, escape, sanitize, pattern
|
|
10783
|
+
* @dbxUtilRelated escape-string-characters-function, find-strings-regex-string
|
|
10784
|
+
*
|
|
10165
10785
|
* @param input - The string to escape for regex use.
|
|
10166
10786
|
* @returns The escaped string with all regex special characters prefixed with a backslash.
|
|
10167
10787
|
*/ var escapeStringForRegex = escapeStringCharactersFunction({
|
|
@@ -10173,8 +10793,15 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10173
10793
|
/**
|
|
10174
10794
|
* Creates a {@link FindAllCharacterOccurencesFunction} that searches for characters from the given set.
|
|
10175
10795
|
*
|
|
10796
|
+
* @dbxUtil
|
|
10797
|
+
* @dbxUtilCategory string
|
|
10798
|
+
* @dbxUtilKind factory
|
|
10799
|
+
* @dbxUtilTags string, search, characters, indices, factory, occurrences
|
|
10800
|
+
* @dbxUtilRelated find-all-character-occurences, find-first-character-occurence
|
|
10801
|
+
*
|
|
10176
10802
|
* @param characterSet - The set of characters to search for.
|
|
10177
10803
|
* @returns A function that finds all occurrences of the configured characters in an input string.
|
|
10804
|
+
* @__NO_SIDE_EFFECTS__
|
|
10178
10805
|
*/ function findAllCharacterOccurencesFunction(characterSet) {
|
|
10179
10806
|
return function(input, maxToReturn) {
|
|
10180
10807
|
var max = maxToReturn !== null && maxToReturn !== void 0 ? maxToReturn : Number.MAX_SAFE_INTEGER;
|
|
@@ -10211,6 +10838,11 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10211
10838
|
/**
|
|
10212
10839
|
* Finds all indices of characters from the set that appear in the input string.
|
|
10213
10840
|
*
|
|
10841
|
+
* @dbxUtil
|
|
10842
|
+
* @dbxUtilCategory string
|
|
10843
|
+
* @dbxUtilTags string, search, characters, indices, occurrences
|
|
10844
|
+
* @dbxUtilRelated find-all-character-occurences-function, find-first-character-occurence
|
|
10845
|
+
*
|
|
10214
10846
|
* @param set - The set of characters to search for.
|
|
10215
10847
|
* @param input - The string to search through.
|
|
10216
10848
|
* @param max - Optional maximum number of occurrences to return.
|
|
@@ -10221,6 +10853,11 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10221
10853
|
/**
|
|
10222
10854
|
* Finds the index of the first occurrence of any character from the set in the input string.
|
|
10223
10855
|
*
|
|
10856
|
+
* @dbxUtil
|
|
10857
|
+
* @dbxUtilCategory string
|
|
10858
|
+
* @dbxUtilTags string, search, characters, first, index, occurrence
|
|
10859
|
+
* @dbxUtilRelated find-all-character-occurences, find-all-character-occurences-function
|
|
10860
|
+
*
|
|
10224
10861
|
* @param set - The set of characters to search for.
|
|
10225
10862
|
* @param input - The string to search through.
|
|
10226
10863
|
* @returns The zero-based index of the first matching character, or `undefined` if none found.
|
|
@@ -10230,8 +10867,15 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10230
10867
|
/**
|
|
10231
10868
|
* Creates a function that splits a string into two parts at the first occurrence of any character in the configured set.
|
|
10232
10869
|
*
|
|
10870
|
+
* @dbxUtil
|
|
10871
|
+
* @dbxUtilCategory string
|
|
10872
|
+
* @dbxUtilKind factory
|
|
10873
|
+
* @dbxUtilTags string, split, characters, occurrence, factory
|
|
10874
|
+
* @dbxUtilRelated split-string-at-first-character-occurence, keep-characters-after-first-character-occurence-function
|
|
10875
|
+
*
|
|
10233
10876
|
* @param splitAt - A single character or set of characters to split on.
|
|
10234
10877
|
* @returns A function that splits input strings at the first matching character.
|
|
10878
|
+
* @__NO_SIDE_EFFECTS__
|
|
10235
10879
|
*/ function splitStringAtFirstCharacterOccurenceFunction(splitAt) {
|
|
10236
10880
|
return function(input) {
|
|
10237
10881
|
var splitSet = typeof splitAt === 'string' ? new Set([
|
|
@@ -10253,6 +10897,11 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10253
10897
|
/**
|
|
10254
10898
|
* Splits the input string into two parts at the first occurrence of any character in the split set.
|
|
10255
10899
|
*
|
|
10900
|
+
* @dbxUtil
|
|
10901
|
+
* @dbxUtilCategory string
|
|
10902
|
+
* @dbxUtilTags string, split, characters, occurrence, tuple
|
|
10903
|
+
* @dbxUtilRelated split-string-at-first-character-occurence-function, find-first-character-occurence
|
|
10904
|
+
*
|
|
10256
10905
|
* @param input - The string to split.
|
|
10257
10906
|
* @param splitAt - A single character or set of characters to split on.
|
|
10258
10907
|
* @returns A tuple of [before, after], where `after` is `undefined` if no split character was found.
|
|
@@ -10262,8 +10911,15 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10262
10911
|
/**
|
|
10263
10912
|
* Creates a function that returns only the characters after the first occurrence of any character in the configured set.
|
|
10264
10913
|
*
|
|
10914
|
+
* @dbxUtil
|
|
10915
|
+
* @dbxUtilCategory string
|
|
10916
|
+
* @dbxUtilKind factory
|
|
10917
|
+
* @dbxUtilTags string, keep, after, occurrence, factory, suffix
|
|
10918
|
+
* @dbxUtilRelated keep-characters-after-first-character-occurence, remove-characters-after-first-character-occurence-function
|
|
10919
|
+
*
|
|
10265
10920
|
* @param findCharacters - A single character or set of characters to search for.
|
|
10266
10921
|
* @returns A function that extracts the substring after the first matching character, or an empty string if none found.
|
|
10922
|
+
* @__NO_SIDE_EFFECTS__
|
|
10267
10923
|
*/ function keepCharactersAfterFirstCharacterOccurenceFunction(findCharacters) {
|
|
10268
10924
|
var splitStringAtFirstCharacterOccurence = splitStringAtFirstCharacterOccurenceFunction(findCharacters);
|
|
10269
10925
|
return function(input) {
|
|
@@ -10274,6 +10930,11 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10274
10930
|
/**
|
|
10275
10931
|
* Returns only the characters after the first occurrence of any character from the find set.
|
|
10276
10932
|
*
|
|
10933
|
+
* @dbxUtil
|
|
10934
|
+
* @dbxUtilCategory string
|
|
10935
|
+
* @dbxUtilTags string, keep, after, occurrence, suffix
|
|
10936
|
+
* @dbxUtilRelated keep-characters-after-first-character-occurence-function, remove-characters-after-first-character-occurence
|
|
10937
|
+
*
|
|
10277
10938
|
* @param input - The string to search through.
|
|
10278
10939
|
* @param findCharacters - A single character or set of characters to search for.
|
|
10279
10940
|
* @returns The substring after the first matching character, or an empty string if none found.
|
|
@@ -10283,8 +10944,15 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10283
10944
|
/**
|
|
10284
10945
|
* Creates a function that removes all characters after (and including) the first occurrence of any character in the configured set.
|
|
10285
10946
|
*
|
|
10947
|
+
* @dbxUtil
|
|
10948
|
+
* @dbxUtilCategory string
|
|
10949
|
+
* @dbxUtilKind factory
|
|
10950
|
+
* @dbxUtilTags string, remove, truncate, occurrence, factory, prefix
|
|
10951
|
+
* @dbxUtilRelated remove-characters-after-first-character-occurence, keep-characters-after-first-character-occurence-function
|
|
10952
|
+
*
|
|
10286
10953
|
* @param findCharacters - A single character or set of characters to search for.
|
|
10287
10954
|
* @returns A function that truncates input strings at the first matching character.
|
|
10955
|
+
* @__NO_SIDE_EFFECTS__
|
|
10288
10956
|
*/ function removeCharactersAfterFirstCharacterOccurenceFunction(findCharacters) {
|
|
10289
10957
|
var splitStringAtFirstCharacterOccurence = splitStringAtFirstCharacterOccurenceFunction(findCharacters);
|
|
10290
10958
|
return function(input) {
|
|
@@ -10294,6 +10962,11 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10294
10962
|
/**
|
|
10295
10963
|
* Removes all characters after (and including) the first occurrence of any character from the find set.
|
|
10296
10964
|
*
|
|
10965
|
+
* @dbxUtil
|
|
10966
|
+
* @dbxUtilCategory string
|
|
10967
|
+
* @dbxUtilTags string, remove, truncate, occurrence, prefix
|
|
10968
|
+
* @dbxUtilRelated remove-characters-after-first-character-occurence-function, keep-characters-after-first-character-occurence
|
|
10969
|
+
*
|
|
10297
10970
|
* @param input - The string to truncate.
|
|
10298
10971
|
* @param findCharacters - A single character or set of characters to search for.
|
|
10299
10972
|
* @returns The substring before the first matching character, or the full string if none found.
|
|
@@ -10443,6 +11116,7 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10443
11116
|
* const alwaysTrue = decisionFunction(true);
|
|
10444
11117
|
* alwaysTrue('anything'); // true
|
|
10445
11118
|
* ```
|
|
11119
|
+
* @__NO_SIDE_EFFECTS__
|
|
10446
11120
|
*/ function decisionFunction(decision) {
|
|
10447
11121
|
return function() {
|
|
10448
11122
|
return decision;
|
|
@@ -10485,6 +11159,8 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10485
11159
|
* const fn2 = asDecisionFunction(undefined, false);
|
|
10486
11160
|
* fn2('anything'); // false
|
|
10487
11161
|
* ```
|
|
11162
|
+
*
|
|
11163
|
+
* @__NO_SIDE_EFFECTS__
|
|
10488
11164
|
*/ function asDecisionFunction(valueOrFunction) {
|
|
10489
11165
|
var defaultIfUndefined = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
|
|
10490
11166
|
var input = valueOrFunction !== null && valueOrFunction !== void 0 ? valueOrFunction : defaultIfUndefined;
|
|
@@ -10749,6 +11425,7 @@ function _unsupported_iterable_to_array$m(o, minLen) {
|
|
|
10749
11425
|
*
|
|
10750
11426
|
* @param type - The start type to enforce.
|
|
10751
11427
|
* @returns A function that transforms paths to the specified start type.
|
|
11428
|
+
* @__NO_SIDE_EFFECTS__
|
|
10752
11429
|
*/ function slashPathStartTypeFactory(type) {
|
|
10753
11430
|
var fn;
|
|
10754
11431
|
switch(type){
|
|
@@ -10795,6 +11472,7 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
10795
11472
|
*
|
|
10796
11473
|
* @param config Configuration options for the factory.
|
|
10797
11474
|
* @returns A SlashPathFolderFactory.
|
|
11475
|
+
* @__NO_SIDE_EFFECTS__
|
|
10798
11476
|
*/ function slashPathFolderFactory() {
|
|
10799
11477
|
var config = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
10800
11478
|
var startType = config.startType, validationConfig = config.validationConfig, inputInvalidPathValue = config.invalidPathValue, treatUntypedFilesAsFolders = config.treatUntypedFilesAsFolders;
|
|
@@ -10964,6 +11642,7 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
10964
11642
|
* @param input
|
|
10965
11643
|
* @param replaceWith
|
|
10966
11644
|
* @returns
|
|
11645
|
+
* @__NO_SIDE_EFFECTS__
|
|
10967
11646
|
*/ function replaceInvalidFilePathTypeSeparatorsInSlashPathFunction() {
|
|
10968
11647
|
var replaceWith = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : DEFAULT_SLASH_PATH_ILLEGAL_CHARACTER_REPLACEMENT;
|
|
10969
11648
|
return function(input) {
|
|
@@ -11009,6 +11688,7 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
11009
11688
|
*
|
|
11010
11689
|
* @param config - Configuration for validation behavior.
|
|
11011
11690
|
* @returns A function that validates and fixes a slash path.
|
|
11691
|
+
* @__NO_SIDE_EFFECTS__
|
|
11012
11692
|
*/ function slashPathValidationFactory(config) {
|
|
11013
11693
|
var _ref = config !== null && config !== void 0 ? config : {}, _ref_illegalStrings = _ref.illegalStrings, illegalStrings = _ref_illegalStrings === void 0 ? DEFAULT_SLASH_PATH_ILLEGAL_CHARACTERS : _ref_illegalStrings, tmp = _ref.replaceIllegalCharacters, inputReplaceIllegalCharacters = tmp === void 0 ? true : tmp, tmp1 = _ref.replaceIllegalDots, inputReplaceIllegalDots = tmp1 === void 0 ? true : tmp1, throwError = _ref.throwError;
|
|
11014
11694
|
var fns = [];
|
|
@@ -11040,6 +11720,7 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
11040
11720
|
*
|
|
11041
11721
|
* @param config - Configuration for path generation.
|
|
11042
11722
|
* @returns A factory function that merges input paths into a single validated slash path.
|
|
11723
|
+
* @__NO_SIDE_EFFECTS__
|
|
11043
11724
|
*/ function slashPathFactory(config) {
|
|
11044
11725
|
var _ref = config !== null && config !== void 0 ? config : {}, tmp = _ref.startType, type = tmp === void 0 ? 'any' : tmp, inputBasePaths = _ref.basePath, _ref_validate = _ref.validate, validate = _ref_validate === void 0 ? true : _ref_validate;
|
|
11045
11726
|
var basePath = inputBasePaths ? mergeSlashPaths(asArray(inputBasePaths)) : undefined;
|
|
@@ -11106,6 +11787,7 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
11106
11787
|
*
|
|
11107
11788
|
* @param config - Configuration with range, optional start type, and file mode.
|
|
11108
11789
|
* @returns A function that isolates path segments within the configured range.
|
|
11790
|
+
* @__NO_SIDE_EFFECTS__
|
|
11109
11791
|
*/ function isolateSlashPathFunction(config) {
|
|
11110
11792
|
var startType = config.startType, asFile = config.asFile;
|
|
11111
11793
|
var range = indexRange(config.range);
|
|
@@ -11208,6 +11890,7 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
11208
11890
|
*
|
|
11209
11891
|
* @param path - Matcher path parts to expand into decision functions.
|
|
11210
11892
|
* @returns Array of decision functions for each path part.
|
|
11893
|
+
* @__NO_SIDE_EFFECTS__
|
|
11211
11894
|
*/ function expandSlashPathPathMatcherPartToDecisionFunctions(path) {
|
|
11212
11895
|
var targetPathPartsInput = asArray(path);
|
|
11213
11896
|
var indexMatchingDecisionFunctions = [];
|
|
@@ -11290,6 +11973,7 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
11290
11973
|
*
|
|
11291
11974
|
* @param input - the matcher configuration, which may be a target path string, an array of path parts, or a full config object
|
|
11292
11975
|
* @returns The matcher.
|
|
11976
|
+
* @__NO_SIDE_EFFECTS__
|
|
11293
11977
|
*/ function slashPathPathMatcher(input) {
|
|
11294
11978
|
var _config_matchRemaining, _config_nonMatchingFillValue;
|
|
11295
11979
|
var config = slashPathPathMatcherConfig(input);
|
|
@@ -11351,6 +12035,7 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
11351
12035
|
*
|
|
11352
12036
|
* @param config The configuration for the matcher.
|
|
11353
12037
|
* @returns The matcher.
|
|
12038
|
+
* @__NO_SIDE_EFFECTS__
|
|
11354
12039
|
*/ function slashPathSubPathMatcher(config) {
|
|
11355
12040
|
var targetPathIndexMatchingDecisionFunctions = expandSlashPathPathMatcherPartToDecisionFunctions(config.basePath);
|
|
11356
12041
|
var basePathPartsCount = targetPathIndexMatchingDecisionFunctions.length;
|
|
@@ -11604,8 +12289,15 @@ function _unsupported_iterable_to_array$l(o, minLen) {
|
|
|
11604
12289
|
/**
|
|
11605
12290
|
* Creates an {@link IsolateWebsitePathFunction} that extracts and transforms a path from a website URL based on the configuration.
|
|
11606
12291
|
*
|
|
12292
|
+
* @dbxUtil
|
|
12293
|
+
* @dbxUtilCategory string
|
|
12294
|
+
* @dbxUtilKind factory
|
|
12295
|
+
* @dbxUtilTags string, url, path, isolate, transform, factory, query
|
|
12296
|
+
* @dbxUtilRelated website-path-from-website-url, website-path-and-query-pair, fix-extra-query-parameters
|
|
12297
|
+
*
|
|
11607
12298
|
* @param config - Configuration for path isolation, including base path removal, component range, query handling, and trailing slash behavior.
|
|
11608
12299
|
* @returns A function that isolates the configured portion of a website path.
|
|
12300
|
+
* @__NO_SIDE_EFFECTS__
|
|
11609
12301
|
*/ function isolateWebsitePathFunction() {
|
|
11610
12302
|
var config = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
11611
12303
|
var removeQueryParameters = config.removeQueryParameters, ignoredBasePath = config.ignoredBasePath, isolatePathComponents = config.isolatePathComponents, removeTrailingSlash = config.removeTrailingSlash;
|
|
@@ -11985,8 +12677,15 @@ function _unsupported_iterable_to_array$k(o, minLen) {
|
|
|
11985
12677
|
/**
|
|
11986
12678
|
* Creates a factory that generates random email addresses using configurable prefixes, domains, and number generators.
|
|
11987
12679
|
*
|
|
12680
|
+
* @dbxUtil
|
|
12681
|
+
* @dbxUtilCategory contact
|
|
12682
|
+
* @dbxUtilKind factory
|
|
12683
|
+
* @dbxUtilTags contact, email, random, factory, generate
|
|
12684
|
+
* @dbxUtilRelated random-phone-number-factory, incrementing-number-factory
|
|
12685
|
+
*
|
|
11988
12686
|
* @param inputConfig - Optional configuration overrides
|
|
11989
12687
|
* @returns A factory function that produces random email address strings
|
|
12688
|
+
* @__NO_SIDE_EFFECTS__
|
|
11990
12689
|
*/ function randomEmailFactory(inputConfig) {
|
|
11991
12690
|
var _config_prefixes, _config_domains;
|
|
11992
12691
|
var config = mergeObjects([
|
|
@@ -12022,8 +12721,15 @@ function _unsupported_iterable_to_array$k(o, minLen) {
|
|
|
12022
12721
|
/**
|
|
12023
12722
|
* Creates a factory that generates random E.164 phone numbers using configurable area codes and number generators.
|
|
12024
12723
|
*
|
|
12724
|
+
* @dbxUtil
|
|
12725
|
+
* @dbxUtilCategory contact
|
|
12726
|
+
* @dbxUtilKind factory
|
|
12727
|
+
* @dbxUtilTags contact, phone, e164, random, factory, generate
|
|
12728
|
+
* @dbxUtilRelated random-email-factory, random-number-factory
|
|
12729
|
+
*
|
|
12025
12730
|
* @param inputConfig - Optional configuration overrides
|
|
12026
12731
|
* @returns A factory function that produces random E.164 phone number strings
|
|
12732
|
+
* @__NO_SIDE_EFFECTS__
|
|
12027
12733
|
*/ function randomPhoneNumberFactory(inputConfig) {
|
|
12028
12734
|
var _config_internationalAreaCodes;
|
|
12029
12735
|
var config = mergeObjects([
|
|
@@ -12310,8 +13016,15 @@ function toReadableError(inputError) {
|
|
|
12310
13016
|
/**
|
|
12311
13017
|
* Creates a function that checks if an error's message contains the target string.
|
|
12312
13018
|
*
|
|
13019
|
+
* @dbxUtil
|
|
13020
|
+
* @dbxUtilCategory error
|
|
13021
|
+
* @dbxUtilKind factory
|
|
13022
|
+
* @dbxUtilTags error, message, contains, factory, predicate, regex
|
|
13023
|
+
* @dbxUtilRelated escape-string-for-regex
|
|
13024
|
+
*
|
|
12313
13025
|
* @param target - The string to search for
|
|
12314
13026
|
* @returns A function that checks error messages for the target string
|
|
13027
|
+
* @__NO_SIDE_EFFECTS__
|
|
12315
13028
|
*/ function errorMessageContainsStringFunction(target) {
|
|
12316
13029
|
var regex = new RegExp(escapeStringForRegex(target));
|
|
12317
13030
|
return function(input) {
|
|
@@ -12425,8 +13138,15 @@ function _unsupported_iterable_to_array$j(o, minLen) {
|
|
|
12425
13138
|
*
|
|
12426
13139
|
* Useful for late-binding or circular dependency resolution.
|
|
12427
13140
|
*
|
|
13141
|
+
* @dbxUtil
|
|
13142
|
+
* @dbxUtilCategory function
|
|
13143
|
+
* @dbxUtilKind factory
|
|
13144
|
+
* @dbxUtilTags function, forward, late-binding, factory, lazy
|
|
13145
|
+
* @dbxUtilRelated default-forward-function-factory
|
|
13146
|
+
*
|
|
12428
13147
|
* @param getter - A Getter that provides the target function
|
|
12429
13148
|
* @returns A forwarding function with the same signature as the target
|
|
13149
|
+
* @__NO_SIDE_EFFECTS__
|
|
12430
13150
|
*/ function forwardFunction(getter) {
|
|
12431
13151
|
return function() {
|
|
12432
13152
|
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
@@ -12440,8 +13160,15 @@ function _unsupported_iterable_to_array$j(o, minLen) {
|
|
|
12440
13160
|
* Creates a factory that produces forwarding functions which use the provided function
|
|
12441
13161
|
* or fall back to the default function when not provided.
|
|
12442
13162
|
*
|
|
13163
|
+
* @dbxUtil
|
|
13164
|
+
* @dbxUtilCategory function
|
|
13165
|
+
* @dbxUtilKind factory
|
|
13166
|
+
* @dbxUtilTags function, forward, factory, default, fallback
|
|
13167
|
+
* @dbxUtilRelated forward-function
|
|
13168
|
+
*
|
|
12443
13169
|
* @param defaultFn - The default function to use as fallback
|
|
12444
13170
|
* @returns A factory that wraps optional functions with a default fallback
|
|
13171
|
+
* @__NO_SIDE_EFFECTS__
|
|
12445
13172
|
*/ function defaultForwardFunctionFactory(defaultFn) {
|
|
12446
13173
|
return function(fn) {
|
|
12447
13174
|
return forwardFunction(function() {
|
|
@@ -12977,9 +13704,16 @@ function _ts_generator$8(thisArg, body) {
|
|
|
12977
13704
|
* The factory generates identifiers in batches, filters them for uniqueness, and verifies each batch
|
|
12978
13705
|
* using the configured verifier. Throws if uniqueness generation fails repeatedly (after 20 attempts).
|
|
12979
13706
|
*
|
|
13707
|
+
* @dbxUtil
|
|
13708
|
+
* @dbxUtilCategory model
|
|
13709
|
+
* @dbxUtilKind factory
|
|
13710
|
+
* @dbxUtilTags model, id, batch, factory, async, unique, identifier
|
|
13711
|
+
* @dbxUtilRelated sequential-incrementing-number-string-model-id-factory
|
|
13712
|
+
*
|
|
12980
13713
|
* @param config - Configuration with the base factory for generating candidates and the verifier for validating them
|
|
12981
13714
|
* @returns An async factory function that produces the requested number of valid identifiers
|
|
12982
13715
|
* @throws Error if the factory cannot produce enough unique values after repeated attempts
|
|
13716
|
+
* @__NO_SIDE_EFFECTS__
|
|
12983
13717
|
*/ function idBatchFactory(config) {
|
|
12984
13718
|
var factory = config.factory, verifier = config.verifier;
|
|
12985
13719
|
var tagsToGeneratePerBatch = verifier.maxBatchSize, _verifier_filterUnique = verifier.filterUnique, filterUnique = _verifier_filterUnique === void 0 ? function(x) {
|
|
@@ -13186,9 +13920,16 @@ function _unsupported_iterable_to_array$g(o, minLen) {
|
|
|
13186
13920
|
* Creates a new {@link PrimativeKeyDencoderFunction} that can bidirectionally encode/decode
|
|
13187
13921
|
* primitive key values based on the configured value pairs.
|
|
13188
13922
|
*
|
|
13923
|
+
* @dbxUtil
|
|
13924
|
+
* @dbxUtilCategory string
|
|
13925
|
+
* @dbxUtilKind factory
|
|
13926
|
+
* @dbxUtilTags string, encode, decode, dencoder, bidirectional, factory, primitive
|
|
13927
|
+
* @dbxUtilRelated primative-key-dencoder-map, primative-key-string-dencoder
|
|
13928
|
+
*
|
|
13189
13929
|
* @param config - configuration with value pairs and optional default fallback
|
|
13190
13930
|
* @returns a function that encodes or decodes single values or arrays
|
|
13191
13931
|
* @throws Error if a single value lookup produces a null result and no default handles it
|
|
13932
|
+
* @__NO_SIDE_EFFECTS__
|
|
13192
13933
|
*/ function primativeKeyDencoder(config) {
|
|
13193
13934
|
var _config_defaultValue = config.defaultValue, defaultValue = _config_defaultValue === void 0 ? PRIMATIVE_KEY_DENCODER_VALUE : _config_defaultValue;
|
|
13194
13935
|
var map = primativeKeyDencoderMap(config.values);
|
|
@@ -13217,9 +13958,16 @@ function _unsupported_iterable_to_array$g(o, minLen) {
|
|
|
13217
13958
|
* When no splitter is defined, all encoded values must be exactly one character long so the string
|
|
13218
13959
|
* can be split character-by-character.
|
|
13219
13960
|
*
|
|
13961
|
+
* @dbxUtil
|
|
13962
|
+
* @dbxUtilCategory string
|
|
13963
|
+
* @dbxUtilKind factory
|
|
13964
|
+
* @dbxUtilTags string, encode, decode, dencoder, splitter, factory, primitive
|
|
13965
|
+
* @dbxUtilRelated primative-key-dencoder, primative-key-dencoder-map
|
|
13966
|
+
*
|
|
13220
13967
|
* @param config - configuration with dencoder and optional splitter
|
|
13221
13968
|
* @returns a bidirectional function for string-to-array and array-to-string conversion
|
|
13222
13969
|
* @throws Error if encoded values contain the splitter character, or if values exceed one character when no splitter is defined
|
|
13970
|
+
* @__NO_SIDE_EFFECTS__
|
|
13223
13971
|
*/ function primativeKeyStringDencoder(config) {
|
|
13224
13972
|
var dencoder = typeof config.dencoder === 'function' ? config.dencoder : primativeKeyDencoder(config.dencoder);
|
|
13225
13973
|
var splitter = config.splitter;
|
|
@@ -13324,8 +14072,15 @@ function _unsupported_iterable_to_array$g(o, minLen) {
|
|
|
13324
14072
|
* Creates a {@link NumberStringDencoderFunction} from the given dencoder.
|
|
13325
14073
|
* The returned function auto-detects the input type: numbers are encoded, strings are decoded.
|
|
13326
14074
|
*
|
|
14075
|
+
* @dbxUtil
|
|
14076
|
+
* @dbxUtilCategory string
|
|
14077
|
+
* @dbxUtilKind factory
|
|
14078
|
+
* @dbxUtilTags string, number, encode, decode, dencoder, bidirectional, factory
|
|
14079
|
+
* @dbxUtilRelated number-string-dencoder, number-string-dencoder-encoded-string-value-function, number-string-dencoder-decoded-number-value-function
|
|
14080
|
+
*
|
|
13327
14081
|
* @param dencoder - the NumberStringDencoder to wrap
|
|
13328
14082
|
* @returns a bidirectional encode/decode function
|
|
14083
|
+
* @__NO_SIDE_EFFECTS__
|
|
13329
14084
|
*/ function numberStringDencoderFunction(dencoder) {
|
|
13330
14085
|
var fn = function fn(input) {
|
|
13331
14086
|
var result = typeof input === 'number' ? dencoder.encodeNumber(input) : dencoder.decodeNumber(input);
|
|
@@ -13337,8 +14092,15 @@ function _unsupported_iterable_to_array$g(o, minLen) {
|
|
|
13337
14092
|
* Creates a function that always returns the encoded string form of the input.
|
|
13338
14093
|
* Numbers are encoded; strings are passed through as-is.
|
|
13339
14094
|
*
|
|
14095
|
+
* @dbxUtil
|
|
14096
|
+
* @dbxUtilCategory string
|
|
14097
|
+
* @dbxUtilKind factory
|
|
14098
|
+
* @dbxUtilTags string, number, encode, normalize, factory
|
|
14099
|
+
* @dbxUtilRelated number-string-dencoder-function, number-string-dencoder-decoded-number-value-function
|
|
14100
|
+
*
|
|
13340
14101
|
* @param dencoder - the NumberStringDencoder to use for encoding
|
|
13341
14102
|
* @returns a function that normalizes input to an encoded string
|
|
14103
|
+
* @__NO_SIDE_EFFECTS__
|
|
13342
14104
|
*/ function numberStringDencoderEncodedStringValueFunction(dencoder) {
|
|
13343
14105
|
return function(input) {
|
|
13344
14106
|
return typeof input === 'number' ? dencoder.encodeNumber(input) : input;
|
|
@@ -13348,8 +14110,15 @@ function _unsupported_iterable_to_array$g(o, minLen) {
|
|
|
13348
14110
|
* Creates a function that always returns the decoded number form of the input.
|
|
13349
14111
|
* Strings are decoded; numbers are passed through as-is.
|
|
13350
14112
|
*
|
|
14113
|
+
* @dbxUtil
|
|
14114
|
+
* @dbxUtilCategory string
|
|
14115
|
+
* @dbxUtilKind factory
|
|
14116
|
+
* @dbxUtilTags string, number, decode, normalize, factory
|
|
14117
|
+
* @dbxUtilRelated number-string-dencoder-function, number-string-dencoder-encoded-string-value-function
|
|
14118
|
+
*
|
|
13351
14119
|
* @param dencoder - the NumberStringDencoder to use for decoding
|
|
13352
14120
|
* @returns a function that normalizes input to a decoded number
|
|
14121
|
+
* @__NO_SIDE_EFFECTS__
|
|
13353
14122
|
*/ function numberStringDencoderDecodedNumberValueFunction(dencoder) {
|
|
13354
14123
|
return function(input) {
|
|
13355
14124
|
return typeof input === 'number' ? input : dencoder.decodeNumber(input);
|
|
@@ -13474,12 +14243,19 @@ function _unsupported_iterable_to_array$g(o, minLen) {
|
|
|
13474
14243
|
* @param minSize - the minimum dimensions to enforce
|
|
13475
14244
|
* @returns a resize function that clamps each axis to the specified minimum
|
|
13476
14245
|
*
|
|
14246
|
+
* @dbxUtil
|
|
14247
|
+
* @dbxUtilCategory value
|
|
14248
|
+
* @dbxUtilKind factory
|
|
14249
|
+
* @dbxUtilTags value, vector, resize, minimum, factory, clamp
|
|
14250
|
+
* @dbxUtilRelated vector
|
|
14251
|
+
*
|
|
13477
14252
|
* @example
|
|
13478
14253
|
* ```ts
|
|
13479
14254
|
* const resize = vectorMinimumSizeResizeFunction({ x: 5 });
|
|
13480
14255
|
* resize({ x: 3, y: 10 });
|
|
13481
14256
|
* // { x: 5, y: 10 }
|
|
13482
14257
|
* ```
|
|
14258
|
+
* @__NO_SIDE_EFFECTS__
|
|
13483
14259
|
*/ function vectorMinimumSizeResizeFunction(minSize) {
|
|
13484
14260
|
return function(input) {
|
|
13485
14261
|
return {
|
|
@@ -13951,8 +14727,15 @@ function _wrap_reg_exp(re, groups, source) {
|
|
|
13951
14727
|
* Creates a {@link LatLngTupleFunction} that converts various input formats into `[lat, lng]` tuples,
|
|
13952
14728
|
* applying optional precision configuration.
|
|
13953
14729
|
*
|
|
14730
|
+
* @dbxUtil
|
|
14731
|
+
* @dbxUtilCategory value
|
|
14732
|
+
* @dbxUtilKind factory
|
|
14733
|
+
* @dbxUtilTags value, lat-lng, tuple, factory, geographic, normalize
|
|
14734
|
+
* @dbxUtilRelated lat-lng-point-function, lat-lng-string-function
|
|
14735
|
+
*
|
|
13954
14736
|
* @param config - optional configuration for precision and wrapping behavior
|
|
13955
14737
|
* @returns a function that produces lat/lng tuples from flexible inputs
|
|
14738
|
+
* @__NO_SIDE_EFFECTS__
|
|
13956
14739
|
*/ function latLngTupleFunction(config) {
|
|
13957
14740
|
var fn = latLngPointFunction(config);
|
|
13958
14741
|
return function(lat, lng) {
|
|
@@ -14035,9 +14818,16 @@ function latLngString(lat, lng) {
|
|
|
14035
14818
|
* Creates a {@link LatLngPointPrecisionFunction} that rounds both lat and lng values
|
|
14036
14819
|
* to the specified number of decimal places.
|
|
14037
14820
|
*
|
|
14821
|
+
* @dbxUtil
|
|
14822
|
+
* @dbxUtilCategory value
|
|
14823
|
+
* @dbxUtilKind factory
|
|
14824
|
+
* @dbxUtilTags value, lat-lng, precision, round, factory, geographic
|
|
14825
|
+
* @dbxUtilRelated lat-lng-point-function, cut-value-to-precision-function
|
|
14826
|
+
*
|
|
14038
14827
|
* @param precision - number of decimal places to retain
|
|
14039
14828
|
* @param precisionRounding - optional rounding strategy (e.g., floor, ceil, round)
|
|
14040
14829
|
* @returns a function that rounds points to the given precision
|
|
14830
|
+
* @__NO_SIDE_EFFECTS__
|
|
14041
14831
|
*/ function latLngPointPrecisionFunction(precision, precisionRounding) {
|
|
14042
14832
|
var precisionFunction = cutValueToPrecisionFunction(precision, precisionRounding);
|
|
14043
14833
|
return function(latLng) {
|
|
@@ -14054,8 +14844,15 @@ function latLngString(lat, lng) {
|
|
|
14054
14844
|
* Creates a {@link LatLngStringFunction} that converts various input formats into comma-separated lat/lng strings,
|
|
14055
14845
|
* applying optional precision configuration.
|
|
14056
14846
|
*
|
|
14847
|
+
* @dbxUtil
|
|
14848
|
+
* @dbxUtilCategory value
|
|
14849
|
+
* @dbxUtilKind factory
|
|
14850
|
+
* @dbxUtilTags value, lat-lng, string, factory, geographic, normalize
|
|
14851
|
+
* @dbxUtilRelated lat-lng-point-function, lat-lng-tuple-function
|
|
14852
|
+
*
|
|
14057
14853
|
* @param config - optional configuration for precision and wrapping behavior
|
|
14058
14854
|
* @returns a function that produces lat/lng strings from flexible inputs
|
|
14855
|
+
* @__NO_SIDE_EFFECTS__
|
|
14059
14856
|
*/ function latLngStringFunction(config) {
|
|
14060
14857
|
var fn = latLngPointFunction(config);
|
|
14061
14858
|
return function(lat, lng) {
|
|
@@ -14086,12 +14883,19 @@ function latLngString(lat, lng) {
|
|
|
14086
14883
|
* @returns a function that produces points from flexible inputs
|
|
14087
14884
|
* @throws {Error} when the input cannot be parsed into a valid point
|
|
14088
14885
|
*
|
|
14886
|
+
* @dbxUtil
|
|
14887
|
+
* @dbxUtilCategory value
|
|
14888
|
+
* @dbxUtilKind factory
|
|
14889
|
+
* @dbxUtilTags value, lat-lng, point, factory, geographic, normalize
|
|
14890
|
+
* @dbxUtilRelated lat-lng-point, lat-lng-tuple-function, lat-lng-string-function, lat-lng-point-precision-function
|
|
14891
|
+
*
|
|
14089
14892
|
* @example
|
|
14090
14893
|
* ```ts
|
|
14091
14894
|
* const fn = latLngPointFunction({ precision: 3 });
|
|
14092
14895
|
* const result = fn(30.59929, -96.38315);
|
|
14093
14896
|
* // result.lat === 30.599, result.lng === -96.383
|
|
14094
14897
|
* ```
|
|
14898
|
+
* @__NO_SIDE_EFFECTS__
|
|
14095
14899
|
*/ function latLngPointFunction(config) {
|
|
14096
14900
|
var _ref = config !== null && config !== void 0 ? config : {}, validate = _ref.validate, wrap = _ref.wrap, defaultValue = _ref.default, _ref_precision = _ref.precision, precision = _ref_precision === void 0 ? LAT_LONG_1MM_PRECISION : _ref_precision, readLonLatTuples = _ref.readLonLatTuples, precisionRounding = _ref.precisionRounding;
|
|
14097
14901
|
var precisionFunction = precision != null ? latLngPointPrecisionFunction(precision, precisionRounding) : mapIdentityFunction();
|
|
@@ -14162,8 +14966,15 @@ function latLngString(lat, lng) {
|
|
|
14162
14966
|
/**
|
|
14163
14967
|
* Creates a {@link ValidLatLngPointFunction} that returns the input point when valid, or a default point otherwise.
|
|
14164
14968
|
*
|
|
14969
|
+
* @dbxUtil
|
|
14970
|
+
* @dbxUtilCategory value
|
|
14971
|
+
* @dbxUtilKind factory
|
|
14972
|
+
* @dbxUtilTags value, lat-lng, validate, fallback, factory, geographic
|
|
14973
|
+
* @dbxUtilRelated valid-lat-lng-point, is-valid-lat-lng-point
|
|
14974
|
+
*
|
|
14165
14975
|
* @param defaultValue - factory for the fallback point; defaults to `defaultLatLngPoint`
|
|
14166
14976
|
* @returns a validation function
|
|
14977
|
+
* @__NO_SIDE_EFFECTS__
|
|
14167
14978
|
*/ function validLatLngPointFunction() {
|
|
14168
14979
|
var defaultValue = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : defaultLatLngPoint;
|
|
14169
14980
|
return function(latLngPoint) {
|
|
@@ -14173,8 +14984,15 @@ function latLngString(lat, lng) {
|
|
|
14173
14984
|
/**
|
|
14174
14985
|
* Creates a {@link LatLngDataPointFunction} that wraps a {@link LatLngRef} object with its resolved point coordinates.
|
|
14175
14986
|
*
|
|
14987
|
+
* @dbxUtil
|
|
14988
|
+
* @dbxUtilCategory value
|
|
14989
|
+
* @dbxUtilKind factory
|
|
14990
|
+
* @dbxUtilTags value, lat-lng, data-point, factory, geographic, ref
|
|
14991
|
+
* @dbxUtilRelated lat-lng-point-function
|
|
14992
|
+
*
|
|
14176
14993
|
* @param config - optional configuration for precision and wrapping behavior
|
|
14177
14994
|
* @returns a function that produces data points from lat/lng references
|
|
14995
|
+
* @__NO_SIDE_EFFECTS__
|
|
14178
14996
|
*/ function latLngDataPointFunction(config) {
|
|
14179
14997
|
var fn = latLngPointFunction(config);
|
|
14180
14998
|
return function(data) {
|
|
@@ -14189,8 +15007,15 @@ function latLngString(lat, lng) {
|
|
|
14189
15007
|
* Creates a {@link RandomLatLngFactory} that generates random points within the specified bounding box.
|
|
14190
15008
|
* The bounding box corners are capped/wrapped to valid coordinate ranges.
|
|
14191
15009
|
*
|
|
15010
|
+
* @dbxUtil
|
|
15011
|
+
* @dbxUtilCategory value
|
|
15012
|
+
* @dbxUtilKind factory
|
|
15013
|
+
* @dbxUtilTags value, lat-lng, random, factory, geographic, bounding-box
|
|
15014
|
+
* @dbxUtilRelated random-lat-lng-from-center-factory, random-number-factory
|
|
15015
|
+
*
|
|
14192
15016
|
* @param config - optional bounding box and precision configuration
|
|
14193
15017
|
* @returns a factory that produces random points within the bounds
|
|
15018
|
+
* @__NO_SIDE_EFFECTS__
|
|
14194
15019
|
*/ function randomLatLngFactory(config) {
|
|
14195
15020
|
var _$_object_spread_props = _object_spread_props$4(_object_spread$8({}, config), {
|
|
14196
15021
|
sw: _object_spread$8({
|
|
@@ -14222,8 +15047,15 @@ function latLngString(lat, lng) {
|
|
|
14222
15047
|
* Creates a {@link RandomLatLngFactory} that generates random points within a rectangle
|
|
14223
15048
|
* centered on the given point, extending by `latDistance` and `lngDistance` in each direction.
|
|
14224
15049
|
*
|
|
15050
|
+
* @dbxUtil
|
|
15051
|
+
* @dbxUtilCategory value
|
|
15052
|
+
* @dbxUtilKind factory
|
|
15053
|
+
* @dbxUtilTags value, lat-lng, random, factory, geographic, center
|
|
15054
|
+
* @dbxUtilRelated random-lat-lng-factory, random-number-factory
|
|
15055
|
+
*
|
|
14225
15056
|
* @param config - center point, distances, and optional precision
|
|
14226
15057
|
* @returns a factory that produces random points near the center
|
|
15058
|
+
* @__NO_SIDE_EFFECTS__
|
|
14227
15059
|
*/ function randomLatLngFromCenterFactory(config) {
|
|
14228
15060
|
var center = config.center, latDistance = config.latDistance, lngDistance = config.lngDistance, precision = config.precision;
|
|
14229
15061
|
var sw = {
|
|
@@ -14475,8 +15307,15 @@ function _unsupported_iterable_to_array$e(o, minLen) {
|
|
|
14475
15307
|
* Creates a {@link LatLngBoundTupleFunction} that converts various bound inputs into a `[sw, ne]` tuple,
|
|
14476
15308
|
* applying optional precision to the resulting points.
|
|
14477
15309
|
*
|
|
15310
|
+
* @dbxUtil
|
|
15311
|
+
* @dbxUtilCategory value
|
|
15312
|
+
* @dbxUtilKind factory
|
|
15313
|
+
* @dbxUtilTags value, lat-lng, bound, tuple, factory, geographic
|
|
15314
|
+
* @dbxUtilRelated lat-lng-bound-function, lat-lng-bound
|
|
15315
|
+
*
|
|
14478
15316
|
* @param config - optional configuration for point precision
|
|
14479
15317
|
* @returns a function that produces bound tuples from flexible inputs
|
|
15318
|
+
* @__NO_SIDE_EFFECTS__
|
|
14480
15319
|
*/ function latLngBoundTupleFunction(config) {
|
|
14481
15320
|
var fn = latLngBoundFunction(config);
|
|
14482
15321
|
return function(input, inputNe) {
|
|
@@ -14513,12 +15352,19 @@ function _unsupported_iterable_to_array$e(o, minLen) {
|
|
|
14513
15352
|
* @returns a function that produces bounds from flexible inputs
|
|
14514
15353
|
* @throws {Error} when the input cannot be parsed into a valid bound
|
|
14515
15354
|
*
|
|
15355
|
+
* @dbxUtil
|
|
15356
|
+
* @dbxUtilCategory value
|
|
15357
|
+
* @dbxUtilKind factory
|
|
15358
|
+
* @dbxUtilTags value, lat-lng, bound, factory, geographic, normalize
|
|
15359
|
+
* @dbxUtilRelated lat-lng-bound, lat-lng-bound-tuple-function, lat-lng-point-function
|
|
15360
|
+
*
|
|
14516
15361
|
* @example
|
|
14517
15362
|
* ```ts
|
|
14518
15363
|
* const fn = latLngBoundFunction({ precision: 3 });
|
|
14519
15364
|
* const result = fn([{ lat: 20, lng: 20 }, { lat: 30, lng: 30 }]);
|
|
14520
15365
|
* // result.sw.lat === 20, result.ne.lat === 30
|
|
14521
15366
|
* ```
|
|
15367
|
+
* @__NO_SIDE_EFFECTS__
|
|
14522
15368
|
*/ function latLngBoundFunction(config) {
|
|
14523
15369
|
var _ref = config !== null && config !== void 0 ? config : {}, pointFunction = _ref.pointFunction, precision = _ref.precision;
|
|
14524
15370
|
var latLngPoint = pointFunction !== null && pointFunction !== void 0 ? pointFunction : latLngPointFunction({
|
|
@@ -14640,8 +15486,15 @@ function _unsupported_iterable_to_array$e(o, minLen) {
|
|
|
14640
15486
|
* falls entirely within the specified bound. Points are checked directly; bounds require
|
|
14641
15487
|
* both corners to be within.
|
|
14642
15488
|
*
|
|
15489
|
+
* @dbxUtil
|
|
15490
|
+
* @dbxUtilCategory value
|
|
15491
|
+
* @dbxUtilKind factory
|
|
15492
|
+
* @dbxUtilTags value, lat-lng, bound, contains, decision, factory, geographic
|
|
15493
|
+
* @dbxUtilRelated overlaps-lat-lng-bound-function, is-lat-lng-point-within-lat-lng-bound
|
|
15494
|
+
*
|
|
14643
15495
|
* @param bound - the reference bound to check containment against
|
|
14644
15496
|
* @returns a function that returns `true` if the input is within the reference bound
|
|
15497
|
+
* @__NO_SIDE_EFFECTS__
|
|
14645
15498
|
*/ function isWithinLatLngBoundFunction(bound) {
|
|
14646
15499
|
var fn = function fn(boundOrPoint) {
|
|
14647
15500
|
return isLatLngPoint(boundOrPoint) ? isLatLngPointWithinLatLngBound(boundOrPoint, bound) : isLatLngBoundWithinLatLngBound(boundOrPoint, bound);
|
|
@@ -14699,8 +15552,15 @@ function _unsupported_iterable_to_array$e(o, minLen) {
|
|
|
14699
15552
|
* overlaps the reference bound. Internally converts bounds to rectangles for overlap detection,
|
|
14700
15553
|
* handling antimeridian wrapping.
|
|
14701
15554
|
*
|
|
15555
|
+
* @dbxUtil
|
|
15556
|
+
* @dbxUtilCategory value
|
|
15557
|
+
* @dbxUtilKind factory
|
|
15558
|
+
* @dbxUtilTags value, lat-lng, bound, overlap, decision, factory, geographic
|
|
15559
|
+
* @dbxUtilRelated is-within-lat-lng-bound-function, lat-lng-bound-overlaps-lat-lng-bound
|
|
15560
|
+
*
|
|
14702
15561
|
* @param bound - the reference bound to check overlap against
|
|
14703
15562
|
* @returns a function that returns `true` if the input overlaps the reference bound
|
|
15563
|
+
* @__NO_SIDE_EFFECTS__
|
|
14704
15564
|
*/ function overlapsLatLngBoundFunction(bound) {
|
|
14705
15565
|
var a = boundToRectangle(bound);
|
|
14706
15566
|
var fn = function fn(boundOrPoint) {
|
|
@@ -14772,6 +15632,7 @@ function _unsupported_iterable_to_array$e(o, minLen) {
|
|
|
14772
15632
|
* safeCompare(null, null); // true
|
|
14773
15633
|
* safeCompare(null, undefined); // false
|
|
14774
15634
|
* ```
|
|
15635
|
+
* @__NO_SIDE_EFFECTS__
|
|
14775
15636
|
*/ function safeEqualityComparatorFunction(compare) {
|
|
14776
15637
|
return function(a, b) {
|
|
14777
15638
|
return a != null && b != null ? compare(a, b) : a === b;
|
|
@@ -14810,9 +15671,16 @@ function _unsupported_iterable_to_array$e(o, minLen) {
|
|
|
14810
15671
|
* This is a convenience wrapper around {@link compareEqualityWithValueFromItemsFunctionFactory} that
|
|
14811
15672
|
* accepts both the value reader and comparator in a single call.
|
|
14812
15673
|
*
|
|
15674
|
+
* @dbxUtil
|
|
15675
|
+
* @dbxUtilCategory value
|
|
15676
|
+
* @dbxUtilKind factory
|
|
15677
|
+
* @dbxUtilTags value, comparator, equality, factory, read
|
|
15678
|
+
* @dbxUtilRelated compare-equality-with-value-from-items-function-factory, safe-equality-comparator-function
|
|
15679
|
+
*
|
|
14813
15680
|
* @param readValues - extracts the comparable value from each item
|
|
14814
15681
|
* @param equalityComparator - compares the extracted values for equality
|
|
14815
15682
|
* @returns a function that compares two items by their extracted values
|
|
15683
|
+
* @__NO_SIDE_EFFECTS__
|
|
14816
15684
|
*/ function compareEqualityWithValueFromItemsFunction(readValues, equalityComparator) {
|
|
14817
15685
|
return compareEqualityWithValueFromItemsFunctionFactory(readValues)(equalityComparator);
|
|
14818
15686
|
}
|
|
@@ -14835,6 +15703,14 @@ function _unsupported_iterable_to_array$e(o, minLen) {
|
|
|
14835
15703
|
* fn(undefined, undefined); // true
|
|
14836
15704
|
* fn(0, 1); // false
|
|
14837
15705
|
* ```
|
|
15706
|
+
*
|
|
15707
|
+
* @dbxUtil
|
|
15708
|
+
* @dbxUtilCategory value
|
|
15709
|
+
* @dbxUtilKind factory
|
|
15710
|
+
* @dbxUtilTags value, comparator, equality, factory, read, reuse
|
|
15711
|
+
* @dbxUtilRelated compare-equality-with-value-from-items-function, safe-equality-comparator-function
|
|
15712
|
+
*
|
|
15713
|
+
* @__NO_SIDE_EFFECTS__
|
|
14838
15714
|
*/ function compareEqualityWithValueFromItemsFunctionFactory(readValues) {
|
|
14839
15715
|
var fn = function fn(equalityComparator) {
|
|
14840
15716
|
var fn = safeEqualityComparatorFunction(function(a, b) {
|
|
@@ -15134,8 +16010,14 @@ function dateFromDateOrTimeMillisecondsNumber(input) {
|
|
|
15134
16010
|
/**
|
|
15135
16011
|
* Converts a MonthOfYear (1-12) to a JavaScript Date month (0-11).
|
|
15136
16012
|
*
|
|
16013
|
+
* @dbxUtil
|
|
16014
|
+
* @dbxUtilCategory date
|
|
16015
|
+
* @dbxUtilTags date, month, convert, javascript
|
|
16016
|
+
* @dbxUtilRelated month-of-year-from-date-month
|
|
16017
|
+
*
|
|
15137
16018
|
* @param monthOfYear - Month of year (1-12)
|
|
15138
16019
|
* @returns JavaScript Date month (0-11)
|
|
16020
|
+
* @__NO_SIDE_EFFECTS__
|
|
15139
16021
|
*/ function makeDateMonthForMonthOfYear(monthOfYear) {
|
|
15140
16022
|
return monthOfYear - 1;
|
|
15141
16023
|
}
|
|
@@ -15364,6 +16246,7 @@ var MINUTE_OF_DAY_MAXMIMUM = MINUTES_IN_DAY - 1;
|
|
|
15364
16246
|
* context(0); // true
|
|
15365
16247
|
* context(10); // false
|
|
15366
16248
|
* ```
|
|
16249
|
+
* @__NO_SIDE_EFFECTS__
|
|
15367
16250
|
*/ function isEqualContext(contextValue, fn) {
|
|
15368
16251
|
return function(value) {
|
|
15369
16252
|
return fn(contextValue, value);
|
|
@@ -15393,6 +16276,7 @@ var MINUTE_OF_DAY_MAXMIMUM = MINUTES_IN_DAY - 1;
|
|
|
15393
16276
|
* context([0, 0, 0]); // true
|
|
15394
16277
|
* context([0, 1, 2]); // false
|
|
15395
16278
|
* ```
|
|
16279
|
+
* @__NO_SIDE_EFFECTS__
|
|
15396
16280
|
*/ function areEqualContext(contextValue, fn) {
|
|
15397
16281
|
var isEqual = isEqualContext(contextValue, fn);
|
|
15398
16282
|
return function(input) {
|
|
@@ -15561,6 +16445,13 @@ var MINUTE_OF_DAY_MAXMIMUM = MINUTES_IN_DAY - 1;
|
|
|
15561
16445
|
* fn(obj);
|
|
15562
16446
|
* // obj.x === 1
|
|
15563
16447
|
* ```
|
|
16448
|
+
*
|
|
16449
|
+
* @dbxUtil
|
|
16450
|
+
* @dbxUtilCategory value
|
|
16451
|
+
* @dbxUtilTags modifier, map, factory, compose
|
|
16452
|
+
* @dbxUtilRelated maybe-modifier-map-to-function, modifier
|
|
16453
|
+
*
|
|
16454
|
+
* @__NO_SIDE_EFFECTS__
|
|
15564
16455
|
*/ function modifierMapToFunction(map) {
|
|
15565
16456
|
var _maybeModifierMapToFunction;
|
|
15566
16457
|
return (_maybeModifierMapToFunction = maybeModifierMapToFunction(map)) !== null && _maybeModifierMapToFunction !== void 0 ? _maybeModifierMapToFunction : NOOP_MODIFIER;
|
|
@@ -15570,8 +16461,14 @@ var MINUTE_OF_DAY_MAXMIMUM = MINUTES_IN_DAY - 1;
|
|
|
15570
16461
|
*
|
|
15571
16462
|
* Returns undefined if no map is provided, allowing callers to distinguish "no modifiers" from "empty modifiers".
|
|
15572
16463
|
*
|
|
16464
|
+
* @dbxUtil
|
|
16465
|
+
* @dbxUtilCategory value
|
|
16466
|
+
* @dbxUtilTags modifier, map, factory, compose, optional
|
|
16467
|
+
* @dbxUtilRelated modifier-map-to-function, modifier
|
|
16468
|
+
*
|
|
15573
16469
|
* @param map - the modifier map to convert
|
|
15574
16470
|
* @returns a composed modifier function, or `undefined` if no map is provided
|
|
16471
|
+
* @__NO_SIDE_EFFECTS__
|
|
15575
16472
|
*/ function maybeModifierMapToFunction(map) {
|
|
15576
16473
|
var fn;
|
|
15577
16474
|
if (map != null) {
|
|
@@ -15843,6 +16740,14 @@ function _ts_generator$7(thisArg, body) {
|
|
|
15843
16740
|
* const fallback = mappedUseFn(undefined, () => 'wrong', 'default');
|
|
15844
16741
|
* // fallback === 'default'
|
|
15845
16742
|
* ```
|
|
16743
|
+
*
|
|
16744
|
+
* @dbxUtil
|
|
16745
|
+
* @dbxUtilCategory value
|
|
16746
|
+
* @dbxUtilKind factory
|
|
16747
|
+
* @dbxUtilTags value, use, map, factory, optional, fallback
|
|
16748
|
+
* @dbxUtilRelated wrap-use-function, use-context-function
|
|
16749
|
+
*
|
|
16750
|
+
* @__NO_SIDE_EFFECTS__
|
|
15846
16751
|
*/ function mappedUseFunction(map) {
|
|
15847
16752
|
return wrapUseFunction(useValue, map);
|
|
15848
16753
|
}
|
|
@@ -15850,9 +16755,16 @@ function _ts_generator$7(thisArg, body) {
|
|
|
15850
16755
|
* Wraps an existing {@link MappedUseFunction} with an additional mapping step, allowing further transformation
|
|
15851
16756
|
* of the intermediate value before it reaches the consumer.
|
|
15852
16757
|
*
|
|
16758
|
+
* @dbxUtil
|
|
16759
|
+
* @dbxUtilCategory value
|
|
16760
|
+
* @dbxUtilKind factory
|
|
16761
|
+
* @dbxUtilTags value, use, map, wrap, compose, factory
|
|
16762
|
+
* @dbxUtilRelated mapped-use-function, use-value
|
|
16763
|
+
*
|
|
15853
16764
|
* @param mappedUseFn - the existing mapped use function to wrap
|
|
15854
16765
|
* @param map - additional transformation applied to the intermediate value
|
|
15855
16766
|
* @returns a new MappedUseFunction with the extra mapping layer
|
|
16767
|
+
* @__NO_SIDE_EFFECTS__
|
|
15856
16768
|
*/ function wrapUseFunction(mappedUseFn, map) {
|
|
15857
16769
|
return function(input, useFn, defaultValue) {
|
|
15858
16770
|
return mappedUseFn(input, function(value) {
|
|
@@ -15864,9 +16776,16 @@ function _ts_generator$7(thisArg, body) {
|
|
|
15864
16776
|
* Creates a {@link UseContextFunction} by binding a consumer and optional default value, so callers
|
|
15865
16777
|
* only need to supply the input.
|
|
15866
16778
|
*
|
|
16779
|
+
* @dbxUtil
|
|
16780
|
+
* @dbxUtilCategory value
|
|
16781
|
+
* @dbxUtilKind factory
|
|
16782
|
+
* @dbxUtilTags value, use, context, factory, bind, default
|
|
16783
|
+
* @dbxUtilRelated use-value, mapped-use-function
|
|
16784
|
+
*
|
|
15867
16785
|
* @param use - the consumer function to bind
|
|
15868
16786
|
* @param defaultValue - fallback when input is null/undefined
|
|
15869
16787
|
* @returns a single-argument function that applies the bound consumer
|
|
16788
|
+
* @__NO_SIDE_EFFECTS__
|
|
15870
16789
|
*/ function useContextFunction(use, defaultValue) {
|
|
15871
16790
|
return function(input) {
|
|
15872
16791
|
var result;
|
|
@@ -15938,6 +16857,14 @@ function _ts_generator$7(thisArg, body) {
|
|
|
15938
16857
|
* const result = await mappedUseAsyncFn(1, () => Promise.resolve('hello'));
|
|
15939
16858
|
* // result === 'hello'
|
|
15940
16859
|
* ```
|
|
16860
|
+
*
|
|
16861
|
+
* @dbxUtil
|
|
16862
|
+
* @dbxUtilCategory value
|
|
16863
|
+
* @dbxUtilKind factory
|
|
16864
|
+
* @dbxUtilTags value, use, async, map, factory, promise
|
|
16865
|
+
* @dbxUtilRelated wrap-use-async-function, mapped-use-function
|
|
16866
|
+
*
|
|
16867
|
+
* @__NO_SIDE_EFFECTS__
|
|
15941
16868
|
*/ function mappedUseAsyncFunction(map) {
|
|
15942
16869
|
return wrapUseAsyncFunction(useAsync, map);
|
|
15943
16870
|
}
|
|
@@ -15945,9 +16872,16 @@ function _ts_generator$7(thisArg, body) {
|
|
|
15945
16872
|
* Wraps an existing {@link MappedUseAsyncFunction} with an additional async-capable mapping step,
|
|
15946
16873
|
* allowing further transformation of the intermediate value before it reaches the consumer.
|
|
15947
16874
|
*
|
|
16875
|
+
* @dbxUtil
|
|
16876
|
+
* @dbxUtilCategory value
|
|
16877
|
+
* @dbxUtilKind factory
|
|
16878
|
+
* @dbxUtilTags value, use, async, map, wrap, compose, factory, promise
|
|
16879
|
+
* @dbxUtilRelated mapped-use-async-function, wrap-use-function
|
|
16880
|
+
*
|
|
15948
16881
|
* @param mappedUsePromiseFn - the existing async mapped use function to wrap
|
|
15949
16882
|
* @param map - additional transformation (sync or async) applied to the intermediate value
|
|
15950
16883
|
* @returns a new MappedUseAsyncFunction with the extra mapping layer
|
|
16884
|
+
* @__NO_SIDE_EFFECTS__
|
|
15951
16885
|
*/ function wrapUseAsyncFunction(mappedUsePromiseFn, map) {
|
|
15952
16886
|
return function(input, useFn, defaultValue) {
|
|
15953
16887
|
return mappedUsePromiseFn(input, function(value) {
|
|
@@ -15986,12 +16920,19 @@ function _ts_generator$7(thisArg, body) {
|
|
|
15986
16920
|
* @returns A factory function that returns the next encoded string identifier on each call
|
|
15987
16921
|
* @throws Error if `increaseBy` is 0
|
|
15988
16922
|
*
|
|
16923
|
+
* @dbxUtil
|
|
16924
|
+
* @dbxUtilCategory model
|
|
16925
|
+
* @dbxUtilKind factory
|
|
16926
|
+
* @dbxUtilTags model, id, factory, sequential, incrementing, dencoder
|
|
16927
|
+
* @dbxUtilRelated id-batch-factory, number-string-dencoder-function
|
|
16928
|
+
*
|
|
15989
16929
|
* @example
|
|
15990
16930
|
* ```ts
|
|
15991
16931
|
* const factory = sequentialIncrementingNumberStringModelIdFactory({ startAt: 0 });
|
|
15992
16932
|
* const first = factory(); // encoded representation of 0
|
|
15993
16933
|
* const second = factory(); // encoded representation of 1
|
|
15994
16934
|
* ```
|
|
16935
|
+
* @__NO_SIDE_EFFECTS__
|
|
15995
16936
|
*/ function sequentialIncrementingNumberStringModelIdFactory() {
|
|
15996
16937
|
var config = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
15997
16938
|
var inputTranformFunction = config.transform, inputDencoder = config.dencoder, currentIndex = config.currentIndex, inputStartAt = config.startAt, inputIncreaseBy = config.increaseBy;
|
|
@@ -16046,8 +16987,15 @@ function _unsupported_iterable_to_array$c(o, minLen) {
|
|
|
16046
16987
|
* The first object is stored fully. Subsequent objects store only fields that changed from the previous entry.
|
|
16047
16988
|
* Null in a delta entry means the field was cleared. Undefined (missing key) means no change.
|
|
16048
16989
|
*
|
|
16990
|
+
* @dbxUtil
|
|
16991
|
+
* @dbxUtilCategory object
|
|
16992
|
+
* @dbxUtilKind factory
|
|
16993
|
+
* @dbxUtilTags object, delta, array, compress, expand, factory
|
|
16994
|
+
* @dbxUtilRelated equality-comparator-function, object-keys-equality-comparator-function
|
|
16995
|
+
*
|
|
16049
16996
|
* @param config - Configuration with the equality checker that defines which fields to track
|
|
16050
16997
|
* @returns A compressor with `compress` and `expand` methods
|
|
16998
|
+
* @__NO_SIDE_EFFECTS__
|
|
16051
16999
|
*/ function objectDeltaArrayCompressor(config) {
|
|
16052
17000
|
var _equalityChecker = config.equalityChecker;
|
|
16053
17001
|
var assignKnownValuesToCopy = assignValuesToPOJOFunction({
|
|
@@ -16690,8 +17638,15 @@ function _unsupported_iterable_to_array$b(o, minLen) {
|
|
|
16690
17638
|
/**
|
|
16691
17639
|
* Creates a function that returns the name for a given DayOfWeek.
|
|
16692
17640
|
*
|
|
17641
|
+
* @dbxUtil
|
|
17642
|
+
* @dbxUtilCategory date
|
|
17643
|
+
* @dbxUtilKind factory
|
|
17644
|
+
* @dbxUtilTags date, week, day-of-week, name, factory, format
|
|
17645
|
+
* @dbxUtilRelated days-of-week-name-map
|
|
17646
|
+
*
|
|
16693
17647
|
* @param transform - Optional configuration for abbreviation and casing
|
|
16694
17648
|
* @returns A function that maps DayOfWeek values to name strings
|
|
17649
|
+
* @__NO_SIDE_EFFECTS__
|
|
16695
17650
|
*/ function daysOfWeekNameFunction(transform) {
|
|
16696
17651
|
var map = daysOfWeekNameMap(transform);
|
|
16697
17652
|
return function(dayOfWeek) {
|
|
@@ -17209,9 +18164,16 @@ function _object_spread_props$3(target, source) {
|
|
|
17209
18164
|
/**
|
|
17210
18165
|
* Wraps an existing factory with a {@link ToStringFunction} to produce strings from the factory's output.
|
|
17211
18166
|
*
|
|
18167
|
+
* @dbxUtil
|
|
18168
|
+
* @dbxUtilCategory string
|
|
18169
|
+
* @dbxUtilKind factory
|
|
18170
|
+
* @dbxUtilTags string, factory, wrap, transform, to-string
|
|
18171
|
+
* @dbxUtilRelated string-from-date-factory, string-from-time-factory
|
|
18172
|
+
*
|
|
17212
18173
|
* @param factory - the original value factory
|
|
17213
18174
|
* @param toStringFunction - function to convert the factory's output to a string
|
|
17214
18175
|
* @returns a new factory that produces string values
|
|
18176
|
+
* @__NO_SIDE_EFFECTS__
|
|
17215
18177
|
*/ function stringFactoryFromFactory(factory, toStringFunction) {
|
|
17216
18178
|
return function() {
|
|
17217
18179
|
return toStringFunction(factory());
|
|
@@ -17219,9 +18181,16 @@ function _object_spread_props$3(target, source) {
|
|
|
17219
18181
|
}
|
|
17220
18182
|
/**
|
|
17221
18183
|
* Creates a factory that returns a string based on the input date.
|
|
17222
|
-
|
|
18184
|
+
*
|
|
18185
|
+
* @dbxUtil
|
|
18186
|
+
* @dbxUtilCategory string
|
|
18187
|
+
* @dbxUtilKind factory
|
|
18188
|
+
* @dbxUtilTags string, date, factory, transform, slice
|
|
18189
|
+
* @dbxUtilRelated string-from-time-factory, string-factory-from-factory, transform-string-function
|
|
18190
|
+
*
|
|
17223
18191
|
* @param config Configuration for the factory.
|
|
17224
18192
|
* @returns A factory that returns a string based on the input date.
|
|
18193
|
+
* @__NO_SIDE_EFFECTS__
|
|
17225
18194
|
*/ function stringFromDateFactory(config) {
|
|
17226
18195
|
var _ref;
|
|
17227
18196
|
var takeFromEnd = config.takeFromEnd, transformStringConfig = config.transformStringConfig, dateToString = config.dateToString;
|
|
@@ -17239,8 +18208,15 @@ function _object_spread_props$3(target, source) {
|
|
|
17239
18208
|
/**
|
|
17240
18209
|
* Creates a factory that returns a string based on the Unix timestamp of the input date.
|
|
17241
18210
|
*
|
|
18211
|
+
* @dbxUtil
|
|
18212
|
+
* @dbxUtilCategory string
|
|
18213
|
+
* @dbxUtilKind factory
|
|
18214
|
+
* @dbxUtilTags string, date, time, timestamp, factory, suffix
|
|
18215
|
+
* @dbxUtilRelated string-from-date-factory
|
|
18216
|
+
*
|
|
17242
18217
|
* @param digitsFromEnd The number of digits to return from the end of the generated string. Defaults to 7.
|
|
17243
18218
|
* @returns A StringFromDateFactory.
|
|
18219
|
+
* @__NO_SIDE_EFFECTS__
|
|
17244
18220
|
*/ function stringFromTimeFactory() {
|
|
17245
18221
|
var digitsFromEnd = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 7;
|
|
17246
18222
|
return stringFromDateFactory({
|
|
@@ -17848,8 +18824,15 @@ function _performAsyncTask(_0, _1) {
|
|
|
17848
18824
|
* Creates a reusable function that performs tasks in parallel with optional concurrency limits
|
|
17849
18825
|
* and non-concurrent task key constraints.
|
|
17850
18826
|
*
|
|
18827
|
+
* @dbxUtil
|
|
18828
|
+
* @dbxUtilCategory promise
|
|
18829
|
+
* @dbxUtilKind factory
|
|
18830
|
+
* @dbxUtilTags promise, parallel, factory, concurrency, async, tasks
|
|
18831
|
+
* @dbxUtilRelated perform-tasks-in-parallel, perform-async-tasks-function
|
|
18832
|
+
*
|
|
17851
18833
|
* @param config - Configuration for task factory, parallelism limits, and concurrency keys.
|
|
17852
18834
|
* @returns A function that accepts an array of inputs and returns a Promise resolving when all tasks complete.
|
|
18835
|
+
* @__NO_SIDE_EFFECTS__
|
|
17853
18836
|
*/ function performTasksInParallelFunction(config) {
|
|
17854
18837
|
var taskFactory = config.taskFactory, sequential = config.sequential, nonConcurrentTaskKeyFactory = config.nonConcurrentTaskKeyFactory, inputMaxParallelTasks = config.maxParallelTasks; config.waitBetweenTasks;
|
|
17855
18838
|
var defaultNonConcurrentTaskKeyFactory = makeDefaultNonConcurrentTaskKeyFactory();
|
|
@@ -17891,8 +18874,15 @@ function _performAsyncTask(_0, _1) {
|
|
|
17891
18874
|
* Creates a function that pulls task inputs from a factory and executes them in parallel
|
|
17892
18875
|
* with configurable concurrency limits and non-concurrent key constraints.
|
|
17893
18876
|
*
|
|
18877
|
+
* @dbxUtil
|
|
18878
|
+
* @dbxUtilCategory promise
|
|
18879
|
+
* @dbxUtilKind factory
|
|
18880
|
+
* @dbxUtilTags promise, parallel, factory, concurrency, async, pull-tasks
|
|
18881
|
+
* @dbxUtilRelated perform-tasks-in-parallel-function
|
|
18882
|
+
*
|
|
17894
18883
|
* @param config - Configuration for the task factory, parallelism, and concurrency behavior.
|
|
17895
18884
|
* @returns a function that accepts a task input factory and returns a Promise that resolves when all tasks complete
|
|
18885
|
+
* @__NO_SIDE_EFFECTS__
|
|
17896
18886
|
*/ function performTasksFromFactoryInParallelFunction(config) {
|
|
17897
18887
|
/**
|
|
17898
18888
|
* @returns null
|
|
@@ -18158,7 +19148,14 @@ function _performAsyncTask(_0, _1) {
|
|
|
18158
19148
|
/**
|
|
18159
19149
|
* Creates a default non-concurrent task key factory that generates unique incrementing number strings.
|
|
18160
19150
|
*
|
|
19151
|
+
* @dbxUtil
|
|
19152
|
+
* @dbxUtilCategory promise
|
|
19153
|
+
* @dbxUtilKind factory
|
|
19154
|
+
* @dbxUtilTags promise, parallel, key, factory, unique, incrementing
|
|
19155
|
+
* @dbxUtilRelated perform-tasks-in-parallel-function, incrementing-number-factory
|
|
19156
|
+
*
|
|
18161
19157
|
* @returns A {@link StringFactory} that produces unique keys for identifying non-concurrent tasks.
|
|
19158
|
+
* @__NO_SIDE_EFFECTS__
|
|
18162
19159
|
*/ function makeDefaultNonConcurrentTaskKeyFactory() {
|
|
18163
19160
|
return stringFactoryFromFactory(incrementingNumberFactory(), function(x) {
|
|
18164
19161
|
return x.toString();
|
|
@@ -18521,8 +19518,15 @@ function _ts_generator$3(thisArg, body) {
|
|
|
18521
19518
|
* Creates a {@link TryWithPromiseFactoriesFunction} that sequentially tries each promise factory
|
|
18522
19519
|
* until one returns a non-null value (or a Maybe value if `successOnMaybe` is true).
|
|
18523
19520
|
*
|
|
19521
|
+
* @dbxUtil
|
|
19522
|
+
* @dbxUtilCategory promise
|
|
19523
|
+
* @dbxUtilKind factory
|
|
19524
|
+
* @dbxUtilTags promise, factory, try, sequential, fallback, async
|
|
19525
|
+
* @dbxUtilRelated run-named-async-tasks-function
|
|
19526
|
+
*
|
|
18524
19527
|
* @param config - Configuration including the array of promise factories and default behavior options.
|
|
18525
19528
|
* @returns A function that tries each factory in order for a given input.
|
|
19529
|
+
* @__NO_SIDE_EFFECTS__
|
|
18526
19530
|
*/ function tryWithPromiseFactoriesFunction(config) {
|
|
18527
19531
|
var promiseFactories = config.promiseFactories, defaultSuccessOnMaybe = config.successOnMaybe, defaultThrowErrors = config.throwErrors;
|
|
18528
19532
|
return function(input, config) {
|
|
@@ -18852,8 +19856,15 @@ function _ts_generator$2(thisArg, body) {
|
|
|
18852
19856
|
/**
|
|
18853
19857
|
* Creates a new RunNamedAsyncTasksFunction.
|
|
18854
19858
|
*
|
|
19859
|
+
* @dbxUtil
|
|
19860
|
+
* @dbxUtilCategory promise
|
|
19861
|
+
* @dbxUtilKind factory
|
|
19862
|
+
* @dbxUtilTags promise, async, task, factory, named, parallel
|
|
19863
|
+
* @dbxUtilRelated try-with-promise-factories-function
|
|
19864
|
+
*
|
|
18855
19865
|
* @param config Optional configuration.
|
|
18856
19866
|
* @returns A new RunNamedAsyncTasksFunction.
|
|
19867
|
+
* @__NO_SIDE_EFFECTS__
|
|
18857
19868
|
*/ function runNamedAsyncTasksFunction(config) {
|
|
18858
19869
|
var _ref = config !== null && config !== void 0 ? config : {}, onTaskSuccess = _ref.onTaskSuccess, onTaskFailure = _ref.onTaskFailure;
|
|
18859
19870
|
return function(inputTasks, options) {
|
|
@@ -19076,9 +20087,16 @@ function _is_native_reflect_construct$2() {
|
|
|
19076
20087
|
/**
|
|
19077
20088
|
* Creates a new Timer from the input duration.
|
|
19078
20089
|
*
|
|
20090
|
+
* @dbxUtil
|
|
20091
|
+
* @dbxUtilCategory date
|
|
20092
|
+
* @dbxUtilKind factory
|
|
20093
|
+
* @dbxUtilTags date, time, timer, factory, duration
|
|
20094
|
+
* @dbxUtilRelated timer
|
|
20095
|
+
*
|
|
19079
20096
|
* @param duration - The duration of the timer.
|
|
19080
20097
|
* @param startImmediately - Whether the timer should start immediately. Defaults to true.
|
|
19081
20098
|
* @returns The new Timer.
|
|
20099
|
+
* @__NO_SIDE_EFFECTS__
|
|
19082
20100
|
*/ function makeTimer(duration) {
|
|
19083
20101
|
var startImmediately = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
|
|
19084
20102
|
var createdAt = new Date();
|
|
@@ -19570,8 +20588,15 @@ function _compareObjects(a, b, pojoFilter) {
|
|
|
19570
20588
|
*
|
|
19571
20589
|
* Fields can be specified as simple field names (using the default `===` comparator) or as config objects with custom comparators.
|
|
19572
20590
|
*
|
|
20591
|
+
* @dbxUtil
|
|
20592
|
+
* @dbxUtilCategory object
|
|
20593
|
+
* @dbxUtilKind factory
|
|
20594
|
+
* @dbxUtilTags object, equality, fields, comparator, factory
|
|
20595
|
+
* @dbxUtilRelated object-keys-equality-comparator-function, object-key-equality-comparator-function
|
|
20596
|
+
*
|
|
19573
20597
|
* @param config - Configuration with the fields to compare and an optional default equality function
|
|
19574
20598
|
* @returns A function that compares two objects and reports which fields are equal/unequal
|
|
20599
|
+
* @__NO_SIDE_EFFECTS__
|
|
19575
20600
|
*/ function objectFieldEqualityChecker(config) {
|
|
19576
20601
|
var fields = config.fields, _config_defaultEqualityFunction = config.defaultEqualityFunction, defaultEqualityFunction = _config_defaultEqualityFunction === void 0 ? function(a, b) {
|
|
19577
20602
|
return a === b;
|
|
@@ -19619,8 +20644,15 @@ function _compareObjects(a, b, pojoFilter) {
|
|
|
19619
20644
|
* Returns `true` if both arrays have the same length and produce identical key sets.
|
|
19620
20645
|
* Handles `null`/`undefined` inputs via {@link safeEqualityComparatorFunction}.
|
|
19621
20646
|
*
|
|
20647
|
+
* @dbxUtil
|
|
20648
|
+
* @dbxUtilCategory object
|
|
20649
|
+
* @dbxUtilKind factory
|
|
20650
|
+
* @dbxUtilTags object, key, equality, comparator, factory, array
|
|
20651
|
+
* @dbxUtilRelated object-key-equality-comparator-function, safe-equality-comparator-function
|
|
20652
|
+
*
|
|
19622
20653
|
* @param readKey - Function to extract one or more keys from each object
|
|
19623
20654
|
* @returns An equality comparator for arrays of keyed objects
|
|
20655
|
+
* @__NO_SIDE_EFFECTS__
|
|
19624
20656
|
*/ function objectKeysEqualityComparatorFunction(readKey) {
|
|
19625
20657
|
var readKeysSet = readKeysSetFunction(readKey);
|
|
19626
20658
|
var readKeysArray = readKeysFunction(readKey);
|
|
@@ -19644,8 +20676,15 @@ function _compareObjects(a, b, pojoFilter) {
|
|
|
19644
20676
|
*
|
|
19645
20677
|
* Handles `null`/`undefined` inputs via {@link safeEqualityComparatorFunction}.
|
|
19646
20678
|
*
|
|
20679
|
+
* @dbxUtil
|
|
20680
|
+
* @dbxUtilCategory object
|
|
20681
|
+
* @dbxUtilKind factory
|
|
20682
|
+
* @dbxUtilTags object, key, equality, comparator, factory
|
|
20683
|
+
* @dbxUtilRelated object-keys-equality-comparator-function, safe-equality-comparator-function
|
|
20684
|
+
*
|
|
19647
20685
|
* @param readKey - Function to extract the key from an object
|
|
19648
20686
|
* @returns An equality comparator for keyed objects
|
|
20687
|
+
* @__NO_SIDE_EFFECTS__
|
|
19649
20688
|
*/ function objectKeyEqualityComparatorFunction(readKey) {
|
|
19650
20689
|
return safeEqualityComparatorFunction(function(a, b) {
|
|
19651
20690
|
return readKey(a) === readKey(b);
|
|
@@ -19709,8 +20748,15 @@ function _unsupported_iterable_to_array$7(o, minLen) {
|
|
|
19709
20748
|
/**
|
|
19710
20749
|
* Creates a reusable {@link MapObjectMapFunction} that applies {@link mapObjectMap} with the given mapping function.
|
|
19711
20750
|
*
|
|
20751
|
+
* @dbxUtil
|
|
20752
|
+
* @dbxUtilCategory object
|
|
20753
|
+
* @dbxUtilKind factory
|
|
20754
|
+
* @dbxUtilTags object, map, transform, factory, values
|
|
20755
|
+
* @dbxUtilRelated map-object-map, map-object-keys-function
|
|
20756
|
+
*
|
|
19712
20757
|
* @param mapFn - Function that transforms each value (receives value and key)
|
|
19713
20758
|
* @returns A function that maps all values in an input object map
|
|
20759
|
+
* @__NO_SIDE_EFFECTS__
|
|
19714
20760
|
*/ function mapObjectMapFunction(mapFn) {
|
|
19715
20761
|
return function(object) {
|
|
19716
20762
|
return mapObjectMap(object, mapFn);
|
|
@@ -19744,8 +20790,15 @@ function _unsupported_iterable_to_array$7(o, minLen) {
|
|
|
19744
20790
|
/**
|
|
19745
20791
|
* Creates a reusable {@link MapObjectKeysFunction} that transforms the keys of an input object using the given mapping function.
|
|
19746
20792
|
*
|
|
20793
|
+
* @dbxUtil
|
|
20794
|
+
* @dbxUtilCategory object
|
|
20795
|
+
* @dbxUtilKind factory
|
|
20796
|
+
* @dbxUtilTags object, map, keys, transform, factory, rename
|
|
20797
|
+
* @dbxUtilRelated map-object-map-function, map-object-keys-to-lowercase
|
|
20798
|
+
*
|
|
19747
20799
|
* @param mapKeyFn - Function that computes the new key from the old key and its value
|
|
19748
20800
|
* @returns A function that remaps keys on any input object
|
|
20801
|
+
* @__NO_SIDE_EFFECTS__
|
|
19749
20802
|
*/ function mapObjectKeysFunction(mapKeyFn) {
|
|
19750
20803
|
return function(object) {
|
|
19751
20804
|
var target = {};
|
|
@@ -19863,9 +20916,16 @@ function _type_of$2(obj) {
|
|
|
19863
20916
|
* If the field does not exist on the source but a default is configured, the default is used.
|
|
19864
20917
|
* Otherwise, the target is left unchanged.
|
|
19865
20918
|
*
|
|
20919
|
+
* @dbxUtil
|
|
20920
|
+
* @dbxUtilCategory model
|
|
20921
|
+
* @dbxUtilKind factory
|
|
20922
|
+
* @dbxUtilTags model, copy, field, factory, default
|
|
20923
|
+
* @dbxUtilRelated make-model-map-functions, modify-model-map-functions
|
|
20924
|
+
*
|
|
19866
20925
|
* @param key - The property key to copy
|
|
19867
20926
|
* @param inputConfig - Optional config with a default value for the field
|
|
19868
20927
|
* @returns A function that copies the field from source to target
|
|
20928
|
+
* @__NO_SIDE_EFFECTS__
|
|
19869
20929
|
*/ function makeCopyModelFieldFunction(key, inputConfig) {
|
|
19870
20930
|
var config = inputConfig !== null && inputConfig !== void 0 ? inputConfig : {};
|
|
19871
20931
|
var hasDefault = objectHasKey(config, 'default');
|
|
@@ -19931,8 +20991,15 @@ function _unsupported_iterable_to_array$6(o, minLen) {
|
|
|
19931
20991
|
*
|
|
19932
20992
|
* The `to` function converts from the model (V) to data (D), while `from` converts back from data (D) to model (V).
|
|
19933
20993
|
*
|
|
20994
|
+
* @dbxUtil
|
|
20995
|
+
* @dbxUtilCategory model
|
|
20996
|
+
* @dbxUtilKind factory
|
|
20997
|
+
* @dbxUtilTags model, conversion, map, factory, bidirectional, fields
|
|
20998
|
+
* @dbxUtilRelated to-model-map-functions, modify-model-map-functions, model-field-conversions
|
|
20999
|
+
*
|
|
19934
21000
|
* @param fields - Field conversion definitions for each key in the model
|
|
19935
21001
|
* @returns Object with `from` and `to` mapping functions
|
|
21002
|
+
* @__NO_SIDE_EFFECTS__
|
|
19936
21003
|
*/ function makeModelMapFunctions(fields) {
|
|
19937
21004
|
var keys = filterKeyValueTuples(fields);
|
|
19938
21005
|
var conversionsByKey = keys.map(function(param) {
|
|
@@ -19968,8 +21035,15 @@ function _unsupported_iterable_to_array$6(o, minLen) {
|
|
|
19968
21035
|
*
|
|
19969
21036
|
* Supports optional filtering by field names and skipping undefined values via {@link ModelConversionOptions}.
|
|
19970
21037
|
*
|
|
21038
|
+
* @dbxUtil
|
|
21039
|
+
* @dbxUtilCategory model
|
|
21040
|
+
* @dbxUtilKind factory
|
|
21041
|
+
* @dbxUtilTags model, conversion, factory, fields, map, transform
|
|
21042
|
+
* @dbxUtilRelated make-model-map-functions, model-field-map-functions
|
|
21043
|
+
*
|
|
19971
21044
|
* @param fields - Array of `[key, convertFn]` tuples defining how each field is converted
|
|
19972
21045
|
* @returns A function that converts an input object to an output object
|
|
21046
|
+
* @__NO_SIDE_EFFECTS__
|
|
19973
21047
|
*/ function makeModelConversionFieldValuesFunction(fields) {
|
|
19974
21048
|
return function(input, inputTarget, options) {
|
|
19975
21049
|
var target = inputTarget !== null && inputTarget !== void 0 ? inputTarget : {};
|
|
@@ -20006,8 +21080,15 @@ function _unsupported_iterable_to_array$6(o, minLen) {
|
|
|
20006
21080
|
/**
|
|
20007
21081
|
* Compiles a {@link ModelFieldMapFunctionsConfig} into resolved {@link ModelFieldMapFunctions} with `from` and `to` mapping functions.
|
|
20008
21082
|
*
|
|
21083
|
+
* @dbxUtil
|
|
21084
|
+
* @dbxUtilCategory model
|
|
21085
|
+
* @dbxUtilKind factory
|
|
21086
|
+
* @dbxUtilTags model, field, map, factory, conversion, bidirectional
|
|
21087
|
+
* @dbxUtilRelated model-field-map-function, make-model-map-functions
|
|
21088
|
+
*
|
|
20009
21089
|
* @param config - Configuration with `from` and `to` field map configs
|
|
20010
21090
|
* @returns Compiled field map functions
|
|
21091
|
+
* @__NO_SIDE_EFFECTS__
|
|
20011
21092
|
*/ function modelFieldMapFunctions(config) {
|
|
20012
21093
|
return {
|
|
20013
21094
|
from: modelFieldMapFunction(config.from),
|
|
@@ -20022,8 +21103,15 @@ function _unsupported_iterable_to_array$6(o, minLen) {
|
|
|
20022
21103
|
* - Null/undefined input with `convertMaybe`: delegates to that function
|
|
20023
21104
|
* - Null/undefined input with `default` or `defaultInput`: uses the appropriate fallback
|
|
20024
21105
|
*
|
|
21106
|
+
* @dbxUtil
|
|
21107
|
+
* @dbxUtilCategory model
|
|
21108
|
+
* @dbxUtilKind factory
|
|
21109
|
+
* @dbxUtilTags model, field, map, factory, maybe, default, convert
|
|
21110
|
+
* @dbxUtilRelated model-field-map-functions, make-model-map-functions
|
|
21111
|
+
*
|
|
20025
21112
|
* @param config - Configuration specifying how to convert values and handle null/undefined
|
|
20026
21113
|
* @returns A function that maps Maybe input values to output values
|
|
21114
|
+
* @__NO_SIDE_EFFECTS__
|
|
20027
21115
|
*/ function modelFieldMapFunction(config) {
|
|
20028
21116
|
var convert = config.convert;
|
|
20029
21117
|
var convertMaybe = 'convertMaybe' in config ? config.convertMaybe : undefined;
|
|
@@ -20064,8 +21152,15 @@ function _unsupported_iterable_to_array$6(o, minLen) {
|
|
|
20064
21152
|
*
|
|
20065
21153
|
* Accepts a pre-built `mapFunctions` reference, a `fieldConversions` ref, or a `fields` config.
|
|
20066
21154
|
*
|
|
21155
|
+
* @dbxUtil
|
|
21156
|
+
* @dbxUtilCategory model
|
|
21157
|
+
* @dbxUtilKind factory
|
|
21158
|
+
* @dbxUtilTags model, conversion, map, factory, normalize, resolve
|
|
21159
|
+
* @dbxUtilRelated make-model-map-functions, to-model-field-conversions
|
|
21160
|
+
*
|
|
20067
21161
|
* @param input - Input that can be resolved to model map functions
|
|
20068
21162
|
* @returns Bidirectional model map functions
|
|
21163
|
+
* @__NO_SIDE_EFFECTS__
|
|
20069
21164
|
*/ function toModelMapFunctions(input) {
|
|
20070
21165
|
var mapFunctions;
|
|
20071
21166
|
if ('mapFunctions' in input) {
|
|
@@ -20164,8 +21259,15 @@ function _object_spread$2(target) {
|
|
|
20164
21259
|
*
|
|
20165
21260
|
* Optionally copies the input object before modification to avoid mutating the original.
|
|
20166
21261
|
*
|
|
21262
|
+
* @dbxUtil
|
|
21263
|
+
* @dbxUtilCategory model
|
|
21264
|
+
* @dbxUtilKind factory
|
|
21265
|
+
* @dbxUtilTags model, map, modify, factory, modifier, copy
|
|
21266
|
+
* @dbxUtilRelated make-model-map-functions, modify-model-map-function
|
|
21267
|
+
*
|
|
20167
21268
|
* @param config - Configuration with the base map functions, modifiers, and copy options
|
|
20168
21269
|
* @returns New model map functions with modifiers applied before each conversion
|
|
21270
|
+
* @__NO_SIDE_EFFECTS__
|
|
20169
21271
|
*/ function modifyModelMapFunctions(config) {
|
|
20170
21272
|
var copy = config.copy, _config_copyModel = config.copyModel, copyModel = _config_copyModel === void 0 ? copy : _config_copyModel, _config_copyData = config.copyData, copyData = _config_copyData === void 0 ? copy : _config_copyData, mapFunctions = config.mapFunctions, modifiers = config.modifiers;
|
|
20171
21273
|
var from = mapFunctions.from, to = mapFunctions.to;
|
|
@@ -20183,10 +21285,17 @@ function _object_spread$2(target) {
|
|
|
20183
21285
|
* When `copy` is true (default), the input is shallow-copied before modification to avoid mutating the original.
|
|
20184
21286
|
* If no modifier is provided, the original map function is returned unchanged.
|
|
20185
21287
|
*
|
|
21288
|
+
* @dbxUtil
|
|
21289
|
+
* @dbxUtilCategory model
|
|
21290
|
+
* @dbxUtilKind factory
|
|
21291
|
+
* @dbxUtilTags model, map, modify, factory, modifier, wrap
|
|
21292
|
+
* @dbxUtilRelated modify-model-map-functions, model-field-map-function
|
|
21293
|
+
*
|
|
20186
21294
|
* @param mapFn - The base map function to wrap
|
|
20187
21295
|
* @param modifyModel - Optional modifier to apply before mapping
|
|
20188
21296
|
* @param copy - Whether to shallow-copy the input before modifying; defaults to true
|
|
20189
21297
|
* @returns The wrapped map function, or the original if no modifier is provided
|
|
21298
|
+
* @__NO_SIDE_EFFECTS__
|
|
20190
21299
|
*/ function modifyModelMapFunction(mapFn, modifyModel) {
|
|
20191
21300
|
var copy = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
|
|
20192
21301
|
return modifyModel ? function(input, target, options) {
|
|
@@ -20201,8 +21310,15 @@ function _object_spread$2(target) {
|
|
|
20201
21310
|
/**
|
|
20202
21311
|
* Creates a function that reads a Node.js ReadableStream and converts its contents to a string using the specified encoding.
|
|
20203
21312
|
*
|
|
21313
|
+
* @dbxUtil
|
|
21314
|
+
* @dbxUtilCategory nodejs
|
|
21315
|
+
* @dbxUtilKind factory
|
|
21316
|
+
* @dbxUtilTags nodejs, stream, readable, string, factory, encoding
|
|
21317
|
+
* @dbxUtilRelated readable-stream-to-buffer, readable-stream-to-base64
|
|
21318
|
+
*
|
|
20204
21319
|
* @param encoding - The buffer encoding to use (e.g., 'utf-8', 'base64')
|
|
20205
21320
|
* @returns A function that consumes a ReadableStream and resolves to its string content
|
|
21321
|
+
* @__NO_SIDE_EFFECTS__
|
|
20206
21322
|
*/ function readableStreamToStringFunction(encoding) {
|
|
20207
21323
|
return function(stream) {
|
|
20208
21324
|
return readableStreamToBuffer(stream).then(function(x) {
|
|
@@ -20683,8 +21799,15 @@ function handlerFactory(readKey, options) {
|
|
|
20683
21799
|
/**
|
|
20684
21800
|
* Convenience function that creates a new {@link Handler} from the given key reader using default options.
|
|
20685
21801
|
*
|
|
21802
|
+
* @dbxUtil
|
|
21803
|
+
* @dbxUtilCategory service
|
|
21804
|
+
* @dbxUtilKind factory
|
|
21805
|
+
* @dbxUtilTags service, handler, factory, dispatch, key, convenience
|
|
21806
|
+
* @dbxUtilRelated handler-factory
|
|
21807
|
+
*
|
|
20686
21808
|
* @param readKey - Function to extract the dispatch key from an input value.
|
|
20687
21809
|
* @returns A new Handler instance.
|
|
21810
|
+
* @__NO_SIDE_EFFECTS__
|
|
20688
21811
|
*/ function makeHandler(readKey) {
|
|
20689
21812
|
return handlerFactory(readKey)();
|
|
20690
21813
|
}
|
|
@@ -20718,9 +21841,16 @@ function handlerFactory(readKey, options) {
|
|
|
20718
21841
|
/**
|
|
20719
21842
|
* Creates a {@link HandlerSetFunction} that registers a handler function on a pre-defined key.
|
|
20720
21843
|
*
|
|
21844
|
+
* @dbxUtil
|
|
21845
|
+
* @dbxUtilCategory service
|
|
21846
|
+
* @dbxUtilKind factory
|
|
21847
|
+
* @dbxUtilTags service, handler, set, factory, register
|
|
21848
|
+
* @dbxUtilRelated handler-mapped-set-function, handler-factory
|
|
21849
|
+
*
|
|
20721
21850
|
* @param accessor - The handler set accessor to register on.
|
|
20722
21851
|
* @param key - The key (or keys) to associate the handler with.
|
|
20723
21852
|
* @returns A function that accepts a handler function and registers it for the given key.
|
|
21853
|
+
* @__NO_SIDE_EFFECTS__
|
|
20724
21854
|
*/ function handlerSetFunction(accessor, key) {
|
|
20725
21855
|
var fn = function fn(handlerFunction) {
|
|
20726
21856
|
accessor.set(key, handlerFunction); // set the handler on the pre-defined key.
|
|
@@ -20732,10 +21862,17 @@ function handlerFactory(readKey, options) {
|
|
|
20732
21862
|
* Creates a {@link HandlerMappedSetFunction} that maps the handler's native input type to a different
|
|
20733
21863
|
* type before invoking the registered handler function.
|
|
20734
21864
|
*
|
|
21865
|
+
* @dbxUtil
|
|
21866
|
+
* @dbxUtilCategory service
|
|
21867
|
+
* @dbxUtilKind factory
|
|
21868
|
+
* @dbxUtilTags service, handler, set, mapped, factory, transform
|
|
21869
|
+
* @dbxUtilRelated handler-set-function, handler-mapped-set-function-factory
|
|
21870
|
+
*
|
|
20735
21871
|
* @param accessor - The handler set accessor to register on.
|
|
20736
21872
|
* @param key - The key (or keys) to associate the handler with.
|
|
20737
21873
|
* @param mapFn - Function to map from the handler's native type to the handler function's expected type.
|
|
20738
21874
|
* @returns A function that accepts a mapped handler function and registers it.
|
|
21875
|
+
* @__NO_SIDE_EFFECTS__
|
|
20739
21876
|
*/ function handlerMappedSetFunction(accessor, key, mapFn) {
|
|
20740
21877
|
var handlerSet = handlerSetFunction(accessor, key);
|
|
20741
21878
|
return function(handlerFunction) {
|
|
@@ -20749,9 +21886,16 @@ function handlerFactory(readKey, options) {
|
|
|
20749
21886
|
/**
|
|
20750
21887
|
* Creates a {@link HandlerMappedSetFunctionFactory} that produces mapped set functions for any given key.
|
|
20751
21888
|
*
|
|
21889
|
+
* @dbxUtil
|
|
21890
|
+
* @dbxUtilCategory service
|
|
21891
|
+
* @dbxUtilKind factory
|
|
21892
|
+
* @dbxUtilTags service, handler, mapped, factory, dispatch
|
|
21893
|
+
* @dbxUtilRelated handler-mapped-set-function, handler-set-function
|
|
21894
|
+
*
|
|
20752
21895
|
* @param accessor - The handler set accessor to register on.
|
|
20753
21896
|
* @param mapFn - Function to map from the handler's native type to the handler function's expected type.
|
|
20754
21897
|
* @returns A factory that creates HandlerMappedSetFunctions for specific keys.
|
|
21898
|
+
* @__NO_SIDE_EFFECTS__
|
|
20755
21899
|
*/ function handlerMappedSetFunctionFactory(accessor, mapFn) {
|
|
20756
21900
|
return function(key) {
|
|
20757
21901
|
return handlerMappedSetFunction(accessor, key, mapFn);
|
|
@@ -20761,8 +21905,15 @@ function handlerFactory(readKey, options) {
|
|
|
20761
21905
|
* Creates a {@link HandlerConfigurerFactory} that produces configurers for binding handler functions
|
|
20762
21906
|
* to a handler instance with automatic `this` binding.
|
|
20763
21907
|
*
|
|
21908
|
+
* @dbxUtil
|
|
21909
|
+
* @dbxUtilCategory service
|
|
21910
|
+
* @dbxUtilKind factory
|
|
21911
|
+
* @dbxUtilTags service, handler, configurer, factory, bind
|
|
21912
|
+
* @dbxUtilRelated handler-bind-accessor, handler-factory
|
|
21913
|
+
*
|
|
20764
21914
|
* @param config - Configuration providing the accessor-to-configurer mapping.
|
|
20765
21915
|
* @returns A factory that creates HandlerConfigurers for specific handlers.
|
|
21916
|
+
* @__NO_SIDE_EFFECTS__
|
|
20766
21917
|
*/ function handlerConfigurerFactory(config) {
|
|
20767
21918
|
return function(handler) {
|
|
20768
21919
|
return function(bindTo, configure) {
|
|
@@ -21826,8 +22977,15 @@ function mimeTypeForFileExtension(extension) {
|
|
|
21826
22977
|
/**
|
|
21827
22978
|
* Creates a {@link SortByStringFunction} that sorts values in ascending alphabetical order using `localeCompare`.
|
|
21828
22979
|
*
|
|
22980
|
+
* @dbxUtil
|
|
22981
|
+
* @dbxUtilCategory string
|
|
22982
|
+
* @dbxUtilKind factory
|
|
22983
|
+
* @dbxUtilTags string, sort, compare, alphabetical, factory, locale
|
|
22984
|
+
* @dbxUtilRelated sort-by-label-function
|
|
22985
|
+
*
|
|
21829
22986
|
* @param readStringFn - Function to extract a string from each value for comparison.
|
|
21830
22987
|
* @returns A comparator function suitable for use with `Array.sort()`.
|
|
22988
|
+
* @__NO_SIDE_EFFECTS__
|
|
21831
22989
|
*/ function sortByStringFunction(readStringFn) {
|
|
21832
22990
|
return function(a, b) {
|
|
21833
22991
|
var as = readStringFn(a);
|
|
@@ -21844,8 +23002,15 @@ function mimeTypeForFileExtension(extension) {
|
|
|
21844
23002
|
/**
|
|
21845
23003
|
* Creates a {@link SearchStringFilterFunction} that filters values based on whether their string representation matches the filter text.
|
|
21846
23004
|
*
|
|
23005
|
+
* @dbxUtil
|
|
23006
|
+
* @dbxUtilCategory string
|
|
23007
|
+
* @dbxUtilKind factory
|
|
23008
|
+
* @dbxUtilTags string, search, filter, factory, match, decision
|
|
23009
|
+
* @dbxUtilRelated case-insensitive-filter-by-index-of-decision-factory
|
|
23010
|
+
*
|
|
21847
23011
|
* @param config - A read function or full configuration specifying how to extract and match search strings.
|
|
21848
23012
|
* @returns A function that filters an array of values by a search/filter text string.
|
|
23013
|
+
* @__NO_SIDE_EFFECTS__
|
|
21849
23014
|
*/ function searchStringFilterFunction(config) {
|
|
21850
23015
|
var _ref = typeof config === 'function' ? {
|
|
21851
23016
|
readStrings: config
|
|
@@ -21940,8 +23105,15 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
21940
23105
|
/**
|
|
21941
23106
|
* Creates a {@link SplitStringTreeFactory} that builds tree structures by splitting strings on the configured separator.
|
|
21942
23107
|
*
|
|
23108
|
+
* @dbxUtil
|
|
23109
|
+
* @dbxUtilCategory string
|
|
23110
|
+
* @dbxUtilKind factory
|
|
23111
|
+
* @dbxUtilTags string, tree, split, separator, factory, hierarchy
|
|
23112
|
+
* @dbxUtilRelated add-to-split-string-tree, find-best-split-string-tree-match
|
|
23113
|
+
*
|
|
21943
23114
|
* @param config - Configuration specifying the separator and optional metadata merge strategy.
|
|
21944
23115
|
* @returns A factory function that creates or extends split string trees.
|
|
23116
|
+
* @__NO_SIDE_EFFECTS__
|
|
21945
23117
|
*/ function splitStringTreeFactory(config) {
|
|
21946
23118
|
var separator = config.separator;
|
|
21947
23119
|
var fn = function fn(input, existing) {
|
|
@@ -22101,6 +23273,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
22101
23273
|
* @template N The type of the TreeNode to be created. Defaults to TreeNode<T, any> if not specified by ExpandTreeWithNodeBuilder.
|
|
22102
23274
|
* @param config An ExpandTree<T> or ExpandTreeWithNodeBuilder<T, N> configuration object.
|
|
22103
23275
|
* @returns An ExpandTreeFunction<T, N> that takes a root value and returns its corresponding tree structure.
|
|
23276
|
+
* @__NO_SIDE_EFFECTS__
|
|
22104
23277
|
*/ function expandTreeFunction(config) {
|
|
22105
23278
|
var _config_makeNode;
|
|
22106
23279
|
var makeNodeFromConfig = (_config_makeNode = config.makeNode) !== null && _config_makeNode !== void 0 ? _config_makeNode : function(basicNode) {
|
|
@@ -22193,6 +23366,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
22193
23366
|
* visited.push(id);
|
|
22194
23367
|
* });
|
|
22195
23368
|
* ```
|
|
23369
|
+
* @__NO_SIDE_EFFECTS__
|
|
22196
23370
|
*/ function exploreTreeFunction(config) {
|
|
22197
23371
|
var _ref, _ref1, _ref2;
|
|
22198
23372
|
var defaultMapNodeFn = (_ref = config === null || config === void 0 ? void 0 : config.mapNodeFunction) !== null && _ref !== void 0 ? _ref : MAP_IDENTITY;
|
|
@@ -22243,6 +23417,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
22243
23417
|
* });
|
|
22244
23418
|
* // Visits: root -> child1 -> leaf1 -> leaf2 -> child2 -> leaf3
|
|
22245
23419
|
* ```
|
|
23420
|
+
* @__NO_SIDE_EFFECTS__
|
|
22246
23421
|
*/ function depthFirstExploreTreeTraversalFactoryFunction() {
|
|
22247
23422
|
return function(visit, continueTraversal) {
|
|
22248
23423
|
return function(node, nodeMappedValue, visitDecision) {
|
|
@@ -22281,6 +23456,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
22281
23456
|
* });
|
|
22282
23457
|
* // Visits: root -> child1, child2, child3 -> leaf1, leaf2, leaf3
|
|
22283
23458
|
* ```
|
|
23459
|
+
* @__NO_SIDE_EFFECTS__
|
|
22284
23460
|
*/ function breadthFirstExploreTreeTraversalFactoryFunction() {
|
|
22285
23461
|
return function(visit, continueTraversal) {
|
|
22286
23462
|
var queue = [];
|
|
@@ -22453,6 +23629,7 @@ function _object_spread_props(target, source) {
|
|
|
22453
23629
|
* const ids = flattenIds(rootNode);
|
|
22454
23630
|
* // ['root', 'child1', 'leaf1', 'leaf2', 'child2', 'leaf3']
|
|
22455
23631
|
* ```
|
|
23632
|
+
* @__NO_SIDE_EFFECTS__
|
|
22456
23633
|
*/ function flattenTreeToArrayFunction(mapNodeFnOrConfig, defaultAddNodeFn) {
|
|
22457
23634
|
var _config_shouldAddNodeFunction;
|
|
22458
23635
|
var config = typeof mapNodeFnOrConfig === 'function' ? {
|
|
@@ -22491,6 +23668,7 @@ function _object_spread_props(target, source) {
|
|
|
22491
23668
|
* @param expand An ExpandTreeFunction (values: T[]) => N[] that converts an array of T into an array of tree nodes N.
|
|
22492
23669
|
* @param flatten A FlattenTreeFunction (tree: N, array?: V[]) => V[] that flattens a tree of N nodes into an array of V values.
|
|
22493
23670
|
* @returns An ExpandFlattenTreeFunction (values: T[]) => V[] that performs the combined expansion and flattening.
|
|
23671
|
+
* @__NO_SIDE_EFFECTS__
|
|
22494
23672
|
*/ function expandFlattenTreeFunction(expand, flatten) {
|
|
22495
23673
|
return function(values) {
|
|
22496
23674
|
return flatten(expandTrees(values, expand));
|
|
@@ -22617,6 +23795,7 @@ function invertMaybeBoolean(x) {
|
|
|
22617
23795
|
* const coinFlip = booleanFactory({ chance: 50 });
|
|
22618
23796
|
* coinFlip(); // true or false with equal probability
|
|
22619
23797
|
* ```
|
|
23798
|
+
* @__NO_SIDE_EFFECTS__
|
|
22620
23799
|
*/ function booleanFactory(config) {
|
|
22621
23800
|
var inputChance = config.chance;
|
|
22622
23801
|
var chance = inputChance / 100;
|
|
@@ -22794,6 +23973,7 @@ function _define_property$1(obj, key, value) {
|
|
|
22794
23973
|
* @param decodeValues - An array of potential original string values.
|
|
22795
23974
|
* @param hashFn - A function that takes a string and returns its hashed representation.
|
|
22796
23975
|
* @returns A {@link HashDecodeMap} for decoding hashed values.
|
|
23976
|
+
* @__NO_SIDE_EFFECTS__
|
|
22797
23977
|
*/ function makeHashDecodeMap(decodeValues, hashFn) {
|
|
22798
23978
|
var keyValuePairs = decodeValues.map(function(x) {
|
|
22799
23979
|
return [
|