@dereekb/util 13.11.1 → 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.cjs.js
CHANGED
|
@@ -789,6 +789,14 @@ function _unsupported_iterable_to_array$A(o, minLen) {
|
|
|
789
789
|
* const fn = readKeysFunction<string>((x) => x);
|
|
790
790
|
* fn(['a', 'b', 'c']); // ['a', 'b', 'c']
|
|
791
791
|
* ```
|
|
792
|
+
*
|
|
793
|
+
* @dbxUtil
|
|
794
|
+
* @dbxUtilCategory value
|
|
795
|
+
* @dbxUtilKind factory
|
|
796
|
+
* @dbxUtilTags key, read, factory, array, primitive
|
|
797
|
+
* @dbxUtilRelated read-keys-set-function
|
|
798
|
+
*
|
|
799
|
+
* @__NO_SIDE_EFFECTS__
|
|
792
800
|
*/ function readKeysFunction(readKey) {
|
|
793
801
|
return function(values) {
|
|
794
802
|
var result;
|
|
@@ -826,6 +834,14 @@ function _unsupported_iterable_to_array$A(o, minLen) {
|
|
|
826
834
|
* const fn = readKeysSetFunction<string>((x) => x);
|
|
827
835
|
* fn(['a', 'b', 'a']); // Set { 'a', 'b' }
|
|
828
836
|
* ```
|
|
837
|
+
*
|
|
838
|
+
* @dbxUtil
|
|
839
|
+
* @dbxUtilCategory value
|
|
840
|
+
* @dbxUtilKind factory
|
|
841
|
+
* @dbxUtilTags key, read, set, factory, dedupe, primitive
|
|
842
|
+
* @dbxUtilRelated read-keys-function
|
|
843
|
+
*
|
|
844
|
+
* @__NO_SIDE_EFFECTS__
|
|
829
845
|
*/ function readKeysSetFunction(readKey) {
|
|
830
846
|
return function(values) {
|
|
831
847
|
var result;
|
|
@@ -1192,9 +1208,16 @@ function _unsupported_iterable_to_array$z(o, minLen) {
|
|
|
1192
1208
|
/**
|
|
1193
1209
|
* Creates a {@link SetHasValueFunction} from an {@link IterableOrValue} by first converting it to a Set.
|
|
1194
1210
|
*
|
|
1211
|
+
* @dbxUtil
|
|
1212
|
+
* @dbxUtilCategory set
|
|
1213
|
+
* @dbxUtilKind factory
|
|
1214
|
+
* @dbxUtilTags set, has, decision, factory, membership, exclude
|
|
1215
|
+
* @dbxUtilRelated set-has-value-function, set-includes-function
|
|
1216
|
+
*
|
|
1195
1217
|
* @param iterable - The values to create a set from.
|
|
1196
1218
|
* @param exclude - If true, the returned function returns true for values NOT in the set.
|
|
1197
1219
|
* @returns A function that tests membership.
|
|
1220
|
+
* @__NO_SIDE_EFFECTS__
|
|
1198
1221
|
*/ function hasValueFunction(iterable) {
|
|
1199
1222
|
var exclude = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
1200
1223
|
var set = asSet(iterable);
|
|
@@ -1203,9 +1226,16 @@ function _unsupported_iterable_to_array$z(o, minLen) {
|
|
|
1203
1226
|
/**
|
|
1204
1227
|
* Creates a {@link SetHasValueFunction} for the given set. When `exclude` is true, returns the inverse (true for values not in the set).
|
|
1205
1228
|
*
|
|
1229
|
+
* @dbxUtil
|
|
1230
|
+
* @dbxUtilCategory set
|
|
1231
|
+
* @dbxUtilKind factory
|
|
1232
|
+
* @dbxUtilTags set, has, decision, factory, membership, exclude
|
|
1233
|
+
* @dbxUtilRelated has-value-function, set-includes-function
|
|
1234
|
+
*
|
|
1206
1235
|
* @param set - The set to check against.
|
|
1207
1236
|
* @param exclude - If true, returns true for values NOT in the set.
|
|
1208
1237
|
* @returns A function that tests membership.
|
|
1238
|
+
* @__NO_SIDE_EFFECTS__
|
|
1209
1239
|
*/ function setHasValueFunction(set, exclude) {
|
|
1210
1240
|
var hasValueFunction;
|
|
1211
1241
|
if (exclude) {
|
|
@@ -1244,10 +1274,17 @@ function _unsupported_iterable_to_array$z(o, minLen) {
|
|
|
1244
1274
|
/**
|
|
1245
1275
|
* Creates a {@link SetIncludesFunction} that checks whether the set includes given values using the specified mode.
|
|
1246
1276
|
*
|
|
1277
|
+
* @dbxUtil
|
|
1278
|
+
* @dbxUtilCategory set
|
|
1279
|
+
* @dbxUtilKind factory
|
|
1280
|
+
* @dbxUtilTags set, includes, decision, factory, all, any, mode
|
|
1281
|
+
* @dbxUtilRelated has-value-function, set-has-value-function
|
|
1282
|
+
*
|
|
1247
1283
|
* @param valuesSet - The reference set.
|
|
1248
1284
|
* @param mode - Whether to require 'all' values or 'any' value to be present. Defaults to 'all'.
|
|
1249
1285
|
* @param emptyValuesToFindArrayResult - The result when the values to find are empty.
|
|
1250
1286
|
* @returns A function that tests inclusion against the set.
|
|
1287
|
+
* @__NO_SIDE_EFFECTS__
|
|
1251
1288
|
*/ function setIncludesFunction(valuesSet) {
|
|
1252
1289
|
var mode = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 'all', emptyValuesToFindArrayResult = arguments.length > 2 ? arguments[2] : void 0;
|
|
1253
1290
|
var fn;
|
|
@@ -1420,9 +1457,16 @@ function _unsupported_iterable_to_array$y(o, minLen) {
|
|
|
1420
1457
|
/**
|
|
1421
1458
|
* Inverts the output of an arbitrary boolean-returning function.
|
|
1422
1459
|
*
|
|
1460
|
+
* @dbxUtil
|
|
1461
|
+
* @dbxUtilCategory function
|
|
1462
|
+
* @dbxUtilKind factory
|
|
1463
|
+
* @dbxUtilTags function, boolean, invert, predicate, factory
|
|
1464
|
+
* @dbxUtilRelated decision-function, filter-function
|
|
1465
|
+
*
|
|
1423
1466
|
* @param decisionFn - The function whose boolean return value to invert
|
|
1424
1467
|
* @param invert - Whether to apply the inversion (defaults to true)
|
|
1425
1468
|
* @returns The inverted function, or the original if invert is false
|
|
1469
|
+
* @__NO_SIDE_EFFECTS__
|
|
1426
1470
|
*/ function invertBooleanReturnFunction(decisionFn) {
|
|
1427
1471
|
var invert = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
|
|
1428
1472
|
return invert ? function() {
|
|
@@ -1452,6 +1496,7 @@ function _unsupported_iterable_to_array$y(o, minLen) {
|
|
|
1452
1496
|
* @param decision - Predicate used to test individual elements.
|
|
1453
1497
|
* @param mode - Whether all or any elements must satisfy the predicate.
|
|
1454
1498
|
* @returns A function that evaluates an array against the configured decision criteria.
|
|
1499
|
+
* @__NO_SIDE_EFFECTS__
|
|
1455
1500
|
*/ function arrayDecisionFunction(decision, mode) {
|
|
1456
1501
|
var findFn = mode === 'all' ? invertBooleanReturnFunction(decision) : decision;
|
|
1457
1502
|
return invertBooleanReturnFunction(function(values) {
|
|
@@ -1763,8 +1808,15 @@ function _type_of$l(obj) {
|
|
|
1763
1808
|
/**
|
|
1764
1809
|
* Creates a {@link FilterMaybeArrayFunction} that filters maybe values from an array using the provided filter function.
|
|
1765
1810
|
*
|
|
1811
|
+
* @dbxUtil
|
|
1812
|
+
* @dbxUtilCategory array
|
|
1813
|
+
* @dbxUtilKind factory
|
|
1814
|
+
* @dbxUtilTags array, filter, maybe, factory, predicate
|
|
1815
|
+
* @dbxUtilRelated filter-maybe-array-values
|
|
1816
|
+
*
|
|
1766
1817
|
* @param filterFn - Filter predicate used to determine which values to keep.
|
|
1767
1818
|
* @returns A function that filters maybe values from an optional input array.
|
|
1819
|
+
* @__NO_SIDE_EFFECTS__
|
|
1768
1820
|
*/ function filterMaybeArrayFunction(filterFn) {
|
|
1769
1821
|
return function(values) {
|
|
1770
1822
|
var result;
|
|
@@ -1874,6 +1926,7 @@ function _type_of$l(obj) {
|
|
|
1874
1926
|
* maybeDouble(undefined); // undefined
|
|
1875
1927
|
* maybeDouble(null); // null
|
|
1876
1928
|
* ```
|
|
1929
|
+
* @__NO_SIDE_EFFECTS__
|
|
1877
1930
|
*/ function mapMaybeFunction(mapFunction) {
|
|
1878
1931
|
return function(input) {
|
|
1879
1932
|
var output = isMaybeNot(input) ? input : mapFunction(input);
|
|
@@ -1891,6 +1944,7 @@ function _type_of$l(obj) {
|
|
|
1891
1944
|
*
|
|
1892
1945
|
* @param mapFunction - per-element transformation
|
|
1893
1946
|
* @returns a function that maps entire arrays
|
|
1947
|
+
* @__NO_SIDE_EFFECTS__
|
|
1894
1948
|
*/ function mapArrayFunction(mapFunction) {
|
|
1895
1949
|
return function(input) {
|
|
1896
1950
|
return input.map(mapFunction);
|
|
@@ -1916,15 +1970,27 @@ function _type_of$l(obj) {
|
|
|
1916
1970
|
/**
|
|
1917
1971
|
* Returns the shared {@link MAP_IDENTITY} function cast to the requested type, useful for providing a typed no-op transformation.
|
|
1918
1972
|
*
|
|
1973
|
+
* @dbxUtil
|
|
1974
|
+
* @dbxUtilCategory value
|
|
1975
|
+
* @dbxUtilTags map, identity, no-op, typed
|
|
1976
|
+
* @dbxUtilRelated map-identity, is-map-identity-function
|
|
1977
|
+
*
|
|
1919
1978
|
* @returns the singleton identity function typed as `MapFunction<T, T>`
|
|
1979
|
+
* @__NO_SIDE_EFFECTS__
|
|
1920
1980
|
*/ function mapIdentityFunction() {
|
|
1921
1981
|
return MAP_IDENTITY;
|
|
1922
1982
|
}
|
|
1923
1983
|
/**
|
|
1924
1984
|
* Checks whether the given function is the singleton {@link MAP_IDENTITY} reference.
|
|
1925
1985
|
*
|
|
1986
|
+
* @dbxUtil
|
|
1987
|
+
* @dbxUtilCategory value
|
|
1988
|
+
* @dbxUtilTags map, identity, type-guard, sentinel
|
|
1989
|
+
* @dbxUtilRelated map-identity, map-identity-function
|
|
1990
|
+
*
|
|
1926
1991
|
* @param fn - the function to check
|
|
1927
1992
|
* @returns `true` if the function is the identity singleton
|
|
1993
|
+
* @__NO_SIDE_EFFECTS__
|
|
1928
1994
|
*/ function isMapIdentityFunction(fn) {
|
|
1929
1995
|
return fn === MAP_IDENTITY;
|
|
1930
1996
|
}
|
|
@@ -1992,6 +2058,8 @@ function _type_of$l(obj) {
|
|
|
1992
2058
|
* const result = fnChain('aaaab');
|
|
1993
2059
|
* // result === 'aaaab'
|
|
1994
2060
|
* ```
|
|
2061
|
+
*
|
|
2062
|
+
* @__NO_SIDE_EFFECTS__
|
|
1995
2063
|
*/ function chainMapSameFunctions(input) {
|
|
1996
2064
|
var fns = filterMaybeArrayValues(asArray(input).filter(function(x) {
|
|
1997
2065
|
return !isMapIdentityFunction(x);
|
|
@@ -2129,6 +2197,7 @@ function _unsupported_iterable_to_array$x(o, minLen) {
|
|
|
2129
2197
|
* @param readKey - Function to extract a unique key from each item.
|
|
2130
2198
|
* @param additionalKeysInput - Optional keys or values to pre-seed as already seen, causing them to be excluded.
|
|
2131
2199
|
* @returns A reusable filter function that removes duplicate items from arrays.
|
|
2200
|
+
* @__NO_SIDE_EFFECTS__
|
|
2132
2201
|
*/ function filterUniqueFunction(readKey, additionalKeysInput) {
|
|
2133
2202
|
var baseKeys = readKeysFromFilterUniqueFunctionAdditionalKeysInput(additionalKeysInput, readKey);
|
|
2134
2203
|
function calculateExclude(excludeInput) {
|
|
@@ -2179,6 +2248,7 @@ function _unsupported_iterable_to_array$x(o, minLen) {
|
|
|
2179
2248
|
*
|
|
2180
2249
|
* @param readKey - Function to extract a unique key from each item.
|
|
2181
2250
|
* @returns A decision function that returns true if all items have distinct keys.
|
|
2251
|
+
* @__NO_SIDE_EFFECTS__
|
|
2182
2252
|
*/ function isUniqueKeyedFunction(readKey) {
|
|
2183
2253
|
return function(input) {
|
|
2184
2254
|
var keys = new Set();
|
|
@@ -2304,9 +2374,15 @@ function makeModelMap(input, read) {
|
|
|
2304
2374
|
*
|
|
2305
2375
|
* If multiple models share the same relation key, the last one wins for that key.
|
|
2306
2376
|
*
|
|
2377
|
+
* @dbxUtil
|
|
2378
|
+
* @dbxUtilCategory model
|
|
2379
|
+
* @dbxUtilTags model, map, key, multi, relation, index, lookup
|
|
2380
|
+
* @dbxUtilRelated make-model-map, read-model-key
|
|
2381
|
+
*
|
|
2307
2382
|
* @param input - Array of models to index
|
|
2308
2383
|
* @param read - Function that returns an array of relation keys for each model
|
|
2309
2384
|
* @returns Map from relation key to model
|
|
2385
|
+
* @__NO_SIDE_EFFECTS__
|
|
2310
2386
|
*/ function makeMultiModelKeyMap(input, read) {
|
|
2311
2387
|
var map = new Map();
|
|
2312
2388
|
input.forEach(function(x) {
|
|
@@ -2458,9 +2534,16 @@ function readModelKey(input) {
|
|
|
2458
2534
|
*
|
|
2459
2535
|
* Falls back to the provided default type if the type reader returns a nullish value.
|
|
2460
2536
|
*
|
|
2537
|
+
* @dbxUtil
|
|
2538
|
+
* @dbxUtilCategory model
|
|
2539
|
+
* @dbxUtilKind factory
|
|
2540
|
+
* @dbxUtilTags model, type, pair, factory, wrap
|
|
2541
|
+
* @dbxUtilRelated read-model-key, encode-model-key-type-pair
|
|
2542
|
+
*
|
|
2461
2543
|
* @param typeReader - Function to extract the model type from input data
|
|
2462
2544
|
* @param defaultType - Fallback type string when the reader returns nullish
|
|
2463
2545
|
* @returns Factory function that produces ModelTypeDataPair values
|
|
2546
|
+
* @__NO_SIDE_EFFECTS__
|
|
2464
2547
|
*/ function modelTypeDataPairFactory(typeReader) {
|
|
2465
2548
|
var defaultType = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : DEFAULT_UNKNOWN_MODEL_TYPE_STRING;
|
|
2466
2549
|
return function(data) {
|
|
@@ -2939,6 +3022,7 @@ function reverseCompareFn(compareFn) {
|
|
|
2939
3022
|
* [{ name: 'Bob' }, { name: 'Alice' }].sort(byName);
|
|
2940
3023
|
* // [{ name: 'Alice' }, { name: 'Bob' }]
|
|
2941
3024
|
* ```
|
|
3025
|
+
* @__NO_SIDE_EFFECTS__
|
|
2942
3026
|
*/ function compareWithMappedValuesFunction(mapValue, comparesFunction) {
|
|
2943
3027
|
return function(a, b) {
|
|
2944
3028
|
var vA = mapValue(a);
|
|
@@ -3004,12 +3088,19 @@ function reverseCompareFn(compareFn) {
|
|
|
3004
3088
|
* @param compareFn - Ascending sort comparison function used to determine min/max.
|
|
3005
3089
|
* @returns A function that returns `{ min, max }` or `null` for empty iterables.
|
|
3006
3090
|
*
|
|
3091
|
+
* @dbxUtil
|
|
3092
|
+
* @dbxUtilCategory sort
|
|
3093
|
+
* @dbxUtilKind factory
|
|
3094
|
+
* @dbxUtilTags sort, min, max, factory, iterable, compare
|
|
3095
|
+
* @dbxUtilRelated min-and-max-index-items-function, sort-by-number-function
|
|
3096
|
+
*
|
|
3007
3097
|
* @example
|
|
3008
3098
|
* ```ts
|
|
3009
3099
|
* const fn = minAndMaxFunction<number>((a, b) => a - b);
|
|
3010
3100
|
* fn([3, 1, 4, 1, 5]); // { min: 1, max: 5 }
|
|
3011
3101
|
* fn([]); // null
|
|
3012
3102
|
* ```
|
|
3103
|
+
* @__NO_SIDE_EFFECTS__
|
|
3013
3104
|
*/ function minAndMaxFunction(compareFn) {
|
|
3014
3105
|
return function(values) {
|
|
3015
3106
|
var _firstValueFromIterable;
|
|
@@ -3303,9 +3394,15 @@ function _unsupported_iterable_to_array$t(o, minLen) {
|
|
|
3303
3394
|
/**
|
|
3304
3395
|
* Creates an array of `[key, value]` tuples by extracting a key from each value.
|
|
3305
3396
|
*
|
|
3397
|
+
* @dbxUtil
|
|
3398
|
+
* @dbxUtilCategory grouping
|
|
3399
|
+
* @dbxUtilTags grouping, key, pairs, tuple, array
|
|
3400
|
+
* @dbxUtilRelated group-values, make-values-group-map
|
|
3401
|
+
*
|
|
3306
3402
|
* @param values - Values to create key pairs from.
|
|
3307
3403
|
* @param keyFn - Extracts the key from each value.
|
|
3308
3404
|
* @returns An array of `[key, value]` tuples.
|
|
3405
|
+
* @__NO_SIDE_EFFECTS__
|
|
3309
3406
|
*/ function makeKeyPairs(values, keyFn) {
|
|
3310
3407
|
return values.map(function(x) {
|
|
3311
3408
|
return [
|
|
@@ -3471,8 +3568,15 @@ function _unsupported_iterable_to_array$s(o, minLen) {
|
|
|
3471
3568
|
/**
|
|
3472
3569
|
* Creates a KeyValueMapFactory that maps values by their key using a ReadKeyFunction.
|
|
3473
3570
|
*
|
|
3571
|
+
* @dbxUtil
|
|
3572
|
+
* @dbxUtilCategory value
|
|
3573
|
+
* @dbxUtilKind factory
|
|
3574
|
+
* @dbxUtilTags map, key, factory, lookup, index
|
|
3575
|
+
* @dbxUtilRelated multi-key-value-map-factory, read-keys-to-map
|
|
3576
|
+
*
|
|
3474
3577
|
* @param read - Function that extracts a key from each value
|
|
3475
3578
|
* @returns A factory that creates Maps from arrays of values
|
|
3579
|
+
* @__NO_SIDE_EFFECTS__
|
|
3476
3580
|
*/ function keyValueMapFactory(read) {
|
|
3477
3581
|
return function(values) {
|
|
3478
3582
|
var map = new Map();
|
|
@@ -3498,8 +3602,15 @@ function _unsupported_iterable_to_array$s(o, minLen) {
|
|
|
3498
3602
|
* Creates a KeyValueMapFactory that maps values by multiple keys using a ReadMultipleKeysFunction.
|
|
3499
3603
|
* Each value can appear under multiple keys.
|
|
3500
3604
|
*
|
|
3605
|
+
* @dbxUtil
|
|
3606
|
+
* @dbxUtilCategory value
|
|
3607
|
+
* @dbxUtilKind factory
|
|
3608
|
+
* @dbxUtilTags map, key, multi, factory, lookup, index
|
|
3609
|
+
* @dbxUtilRelated key-value-map-factory, read-multiple-keys-to-map
|
|
3610
|
+
*
|
|
3501
3611
|
* @param read - Function that extracts multiple keys from each value
|
|
3502
3612
|
* @returns A factory that creates Maps from arrays of values
|
|
3613
|
+
* @__NO_SIDE_EFFECTS__
|
|
3503
3614
|
*/ function multiKeyValueMapFactory(read) {
|
|
3504
3615
|
return function(values) {
|
|
3505
3616
|
var map = new Map();
|
|
@@ -3615,8 +3726,15 @@ function _unsupported_iterable_to_array$s(o, minLen) {
|
|
|
3615
3726
|
* Creates an {@link IsSelectedDecisionFunctionFactory} that produces decision functions
|
|
3616
3727
|
* checking whether a value's key is included in a set of selected values.
|
|
3617
3728
|
*
|
|
3729
|
+
* @dbxUtil
|
|
3730
|
+
* @dbxUtilCategory set
|
|
3731
|
+
* @dbxUtilKind factory
|
|
3732
|
+
* @dbxUtilTags set, selection, decision, predicate, factory, key
|
|
3733
|
+
* @dbxUtilRelated is-in-set-decision-function
|
|
3734
|
+
*
|
|
3618
3735
|
* @param config - Configuration with the key reader and default behavior.
|
|
3619
3736
|
* @returns A factory that creates decision functions from a set of selected keys.
|
|
3737
|
+
* @__NO_SIDE_EFFECTS__
|
|
3620
3738
|
*/ function isSelectedDecisionFunctionFactory(config) {
|
|
3621
3739
|
var readKey = config.readKey, _config_defaultIfKeyNull = config.defaultIfKeyNull, defaultIfKeyNull = _config_defaultIfKeyNull === void 0 ? false : _config_defaultIfKeyNull;
|
|
3622
3740
|
return function(selectedValues) {
|
|
@@ -3774,6 +3892,7 @@ function _unsupported_iterable_to_array$s(o, minLen) {
|
|
|
3774
3892
|
*
|
|
3775
3893
|
* @param x - The value to check.
|
|
3776
3894
|
* @returns Whether the value is a non-class function.
|
|
3895
|
+
* @__NO_SIDE_EFFECTS__
|
|
3777
3896
|
*/ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
3778
3897
|
function isNonClassFunction(x) {
|
|
3779
3898
|
var type = getFunctionType(x);
|
|
@@ -3827,6 +3946,7 @@ function getValueFromGetter(input, args) {
|
|
|
3827
3946
|
* @param value - The object to copy
|
|
3828
3947
|
* @param copyFunction - Optional custom copy function (defaults to copyObject)
|
|
3829
3948
|
* @returns A factory that produces copies of the value
|
|
3949
|
+
* @__NO_SIDE_EFFECTS__
|
|
3830
3950
|
*/ function objectCopyFactory(value) {
|
|
3831
3951
|
var copyFunction = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : copyObject;
|
|
3832
3952
|
return function() {
|
|
@@ -3837,17 +3957,31 @@ function getValueFromGetter(input, args) {
|
|
|
3837
3957
|
* Converts the input to an ObjectCopyFactory. If the input is an object, wraps it with objectCopyFactory.
|
|
3838
3958
|
* If it's already a function (Getter), it's returned directly.
|
|
3839
3959
|
*
|
|
3960
|
+
* @dbxUtil
|
|
3961
|
+
* @dbxUtilCategory getter
|
|
3962
|
+
* @dbxUtilKind factory
|
|
3963
|
+
* @dbxUtilTags getter, factory, copy, clone, object, normalize
|
|
3964
|
+
* @dbxUtilRelated object-copy-factory, as-getter
|
|
3965
|
+
*
|
|
3840
3966
|
* @param input - An object value or a getter function
|
|
3841
3967
|
* @param copyFunction - Optional custom copy function
|
|
3842
3968
|
* @returns An ObjectCopyFactory for the input
|
|
3969
|
+
* @__NO_SIDE_EFFECTS__
|
|
3843
3970
|
*/ function asObjectCopyFactory(input, copyFunction) {
|
|
3844
3971
|
return (typeof input === "undefined" ? "undefined" : _type_of$j(input)) === 'object' ? objectCopyFactory(input, copyFunction) : asGetter(input);
|
|
3845
3972
|
}
|
|
3846
3973
|
/**
|
|
3847
3974
|
* Wraps the input value in a Getter function that always returns it.
|
|
3848
3975
|
*
|
|
3976
|
+
* @dbxUtil
|
|
3977
|
+
* @dbxUtilCategory getter
|
|
3978
|
+
* @dbxUtilKind factory
|
|
3979
|
+
* @dbxUtilTags getter, factory, wrap, constant
|
|
3980
|
+
* @dbxUtilRelated as-getter, get-value-from-getter
|
|
3981
|
+
*
|
|
3849
3982
|
* @param input - The value to wrap
|
|
3850
3983
|
* @returns A Getter that returns the input value
|
|
3984
|
+
* @__NO_SIDE_EFFECTS__
|
|
3851
3985
|
*/ function makeGetter(input) {
|
|
3852
3986
|
return function() {
|
|
3853
3987
|
return input;
|
|
@@ -3856,9 +3990,15 @@ function getValueFromGetter(input, args) {
|
|
|
3856
3990
|
/**
|
|
3857
3991
|
* Calls a factory function the specified number of times and returns the results as an array.
|
|
3858
3992
|
*
|
|
3993
|
+
* @dbxUtil
|
|
3994
|
+
* @dbxUtilCategory getter
|
|
3995
|
+
* @dbxUtilTags getter, factory, generate, array, count
|
|
3996
|
+
* @dbxUtilRelated make-with-factory-input, array-factory
|
|
3997
|
+
*
|
|
3859
3998
|
* @param factory - The factory function to call (receives the current index as argument)
|
|
3860
3999
|
* @param count - The number of items to create
|
|
3861
4000
|
* @returns An array of produced values
|
|
4001
|
+
* @__NO_SIDE_EFFECTS__
|
|
3862
4002
|
*/ function makeWithFactory(factory, count) {
|
|
3863
4003
|
var results = [];
|
|
3864
4004
|
for(var i = 0; i < count; i += 1){
|
|
@@ -3875,8 +4015,15 @@ function makeWithFactoryInput(factory, input) {
|
|
|
3875
4015
|
* Wraps a factory so that no arguments are forwarded when it's called.
|
|
3876
4016
|
* Useful for protecting a factory from accidentally receiving arguments.
|
|
3877
4017
|
*
|
|
4018
|
+
* @dbxUtil
|
|
4019
|
+
* @dbxUtilCategory getter
|
|
4020
|
+
* @dbxUtilKind factory
|
|
4021
|
+
* @dbxUtilTags getter, factory, protect, wrap, no-args
|
|
4022
|
+
* @dbxUtilRelated as-getter, make-getter
|
|
4023
|
+
*
|
|
3878
4024
|
* @param factory - The factory to wrap
|
|
3879
4025
|
* @returns A new factory that calls the original with no arguments
|
|
4026
|
+
* @__NO_SIDE_EFFECTS__
|
|
3880
4027
|
*/ function protectedFactory(factory) {
|
|
3881
4028
|
return function() {
|
|
3882
4029
|
return factory();
|
|
@@ -3889,6 +4036,12 @@ function makeWithFactoryInput(factory, input) {
|
|
|
3889
4036
|
* @param config - Configuration with optional `startAt` (default 0) and `increaseBy` (default 1)
|
|
3890
4037
|
* @returns A factory function that returns the next number in the sequence on each call
|
|
3891
4038
|
*
|
|
4039
|
+
* @dbxUtil
|
|
4040
|
+
* @dbxUtilCategory number
|
|
4041
|
+
* @dbxUtilKind factory
|
|
4042
|
+
* @dbxUtilTags number, factory, increment, sequence, counter
|
|
4043
|
+
* @dbxUtilRelated random-number-factory
|
|
4044
|
+
*
|
|
3892
4045
|
* @example
|
|
3893
4046
|
* ```ts
|
|
3894
4047
|
* const factory = incrementingNumberFactory({ startAt: 10, increaseBy: 5 });
|
|
@@ -3896,6 +4049,7 @@ function makeWithFactoryInput(factory, input) {
|
|
|
3896
4049
|
* factory(); // 15
|
|
3897
4050
|
* factory(); // 20
|
|
3898
4051
|
* ```
|
|
4052
|
+
* @__NO_SIDE_EFFECTS__
|
|
3899
4053
|
*/ function incrementingNumberFactory() {
|
|
3900
4054
|
var config = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
3901
4055
|
var initial = config.startAt, inputIncreaseBy = config.increaseBy;
|
|
@@ -3929,6 +4083,7 @@ function makeWithFactoryInput(factory, input) {
|
|
|
3929
4083
|
* @param bounds - The min/max bounds to test against
|
|
3930
4084
|
* @returns A function that returns `true` if the input number is within bounds
|
|
3931
4085
|
* @throws Error if the bounds are invalid (min > max)
|
|
4086
|
+
* @__NO_SIDE_EFFECTS__
|
|
3932
4087
|
*/ function isInNumberBoundFunction(bounds) {
|
|
3933
4088
|
var min = bounds.min, max = bounds.max;
|
|
3934
4089
|
if (!isValidNumberBound(bounds)) {
|
|
@@ -3951,6 +4106,7 @@ function makeWithFactoryInput(factory, input) {
|
|
|
3951
4106
|
*
|
|
3952
4107
|
* @param wrapNumberFunctionConfig - Configuration with min, max, and optional fence post behavior
|
|
3953
4108
|
* @returns A function that wraps input numbers into the bounded range
|
|
4109
|
+
* @__NO_SIDE_EFFECTS__
|
|
3954
4110
|
*/ function wrapNumberFunction(wrapNumberFunctionConfig) {
|
|
3955
4111
|
var min = wrapNumberFunctionConfig.min, max = wrapNumberFunctionConfig.max, _wrapNumberFunctionConfig_fencePosts = wrapNumberFunctionConfig.fencePosts, fencePosts = _wrapNumberFunctionConfig_fencePosts === void 0 ? false : _wrapNumberFunctionConfig_fencePosts;
|
|
3956
4112
|
var distance = max - min;
|
|
@@ -3982,6 +4138,7 @@ function makeWithFactoryInput(factory, input) {
|
|
|
3982
4138
|
*
|
|
3983
4139
|
* @param boundNumberFunctionConfig - Configuration with min, max, and optional wrap behavior
|
|
3984
4140
|
* @returns A function that bounds input numbers into the configured range
|
|
4141
|
+
* @__NO_SIDE_EFFECTS__
|
|
3985
4142
|
*/ function boundNumberFunction(boundNumberFunctionConfig) {
|
|
3986
4143
|
var min = boundNumberFunctionConfig.min, max = boundNumberFunctionConfig.max, wrap = boundNumberFunctionConfig.wrap;
|
|
3987
4144
|
return wrap ? wrapNumberFunction(boundNumberFunctionConfig) : function(input) {
|
|
@@ -4205,6 +4362,7 @@ function _type_of$h(obj) {
|
|
|
4205
4362
|
*
|
|
4206
4363
|
* @param type - The rounding strategy: 'floor', 'ceil', 'round', or 'none'
|
|
4207
4364
|
* @returns The corresponding Math function, or an identity function for 'none'
|
|
4365
|
+
* @__NO_SIDE_EFFECTS__
|
|
4208
4366
|
*/ function roundingFunction(type) {
|
|
4209
4367
|
var fn;
|
|
4210
4368
|
switch(type){
|
|
@@ -4261,9 +4419,16 @@ function _type_of$h(obj) {
|
|
|
4261
4419
|
/**
|
|
4262
4420
|
* Creates a {@link CutValueToPrecisionFunction} that truncates values to the configured precision.
|
|
4263
4421
|
*
|
|
4422
|
+
* @dbxUtil
|
|
4423
|
+
* @dbxUtilCategory number
|
|
4424
|
+
* @dbxUtilKind factory
|
|
4425
|
+
* @dbxUtilTags number, precision, cut, truncate, factory, round
|
|
4426
|
+
* @dbxUtilRelated round-to-precision-function, cut-to-precision
|
|
4427
|
+
*
|
|
4264
4428
|
* @param precision - Number of decimal places to retain
|
|
4265
4429
|
* @param roundingType - Rounding strategy; defaults to 'cut' (truncation)
|
|
4266
4430
|
* @returns A function that accepts a number or string and returns the truncated number
|
|
4431
|
+
* @__NO_SIDE_EFFECTS__
|
|
4267
4432
|
*/ function cutValueToPrecisionFunction(precision) {
|
|
4268
4433
|
var roundingType = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 'cut';
|
|
4269
4434
|
var roundFn = roundToPrecisionFunction(precision, roundingType);
|
|
@@ -4276,9 +4441,16 @@ function _type_of$h(obj) {
|
|
|
4276
4441
|
/**
|
|
4277
4442
|
* Creates a function that rounds numbers to the specified precision using a configurable rounding strategy.
|
|
4278
4443
|
*
|
|
4444
|
+
* @dbxUtil
|
|
4445
|
+
* @dbxUtilCategory number
|
|
4446
|
+
* @dbxUtilKind factory
|
|
4447
|
+
* @dbxUtilTags number, round, precision, factory, decimals
|
|
4448
|
+
* @dbxUtilRelated cut-value-to-precision-function, round-to-precision, cut-to-precision
|
|
4449
|
+
*
|
|
4279
4450
|
* @param precision - Number of decimal places
|
|
4280
4451
|
* @param roundFn - Rounding strategy; defaults to 'round'. Use 'cut' for truncation.
|
|
4281
4452
|
* @returns A function that rounds numbers to the configured precision
|
|
4453
|
+
* @__NO_SIDE_EFFECTS__
|
|
4282
4454
|
*/ function roundToPrecisionFunction(precision) {
|
|
4283
4455
|
var roundFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 'round';
|
|
4284
4456
|
var result;
|
|
@@ -4331,9 +4503,16 @@ function _type_of$h(obj) {
|
|
|
4331
4503
|
*
|
|
4332
4504
|
* Accepts either a step number (uses 'ceil' rounding) or a full config with step, rounding type, and origin.
|
|
4333
4505
|
*
|
|
4506
|
+
* @dbxUtil
|
|
4507
|
+
* @dbxUtilCategory number
|
|
4508
|
+
* @dbxUtilKind factory
|
|
4509
|
+
* @dbxUtilTags number, round, step, factory, multiple, origin
|
|
4510
|
+
* @dbxUtilRelated round-number-up-to-step, round-to-precision-function
|
|
4511
|
+
*
|
|
4334
4512
|
* @param input - Step size or full configuration
|
|
4335
4513
|
* @returns A function that rounds input numbers to the nearest step
|
|
4336
4514
|
* @throws Error if step is 0 or undefined
|
|
4515
|
+
* @__NO_SIDE_EFFECTS__
|
|
4337
4516
|
*/ function roundNumberToStepFunction(input) {
|
|
4338
4517
|
var config = typeof input === 'number' ? {
|
|
4339
4518
|
step: input,
|
|
@@ -4385,8 +4564,15 @@ var DOLLAR_AMOUNT_STRING_REGEX = /^\$?(\d+)\.?(\d\d)$/;
|
|
|
4385
4564
|
/**
|
|
4386
4565
|
* Creates a function that formats dollar amounts as strings with a unit prefix (e.g., "$12.50").
|
|
4387
4566
|
*
|
|
4567
|
+
* @dbxUtil
|
|
4568
|
+
* @dbxUtilCategory number
|
|
4569
|
+
* @dbxUtilKind factory
|
|
4570
|
+
* @dbxUtilTags number, dollar, currency, format, factory, unit
|
|
4571
|
+
* @dbxUtilRelated dollar-amount-string
|
|
4572
|
+
*
|
|
4388
4573
|
* @param unit - The unit prefix to prepend; defaults to "$"
|
|
4389
4574
|
* @returns A function that formats dollar amounts with the configured unit
|
|
4575
|
+
* @__NO_SIDE_EFFECTS__
|
|
4390
4576
|
*/ function dollarAmountStringWithUnitFunction() {
|
|
4391
4577
|
var unit = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : '$';
|
|
4392
4578
|
var fn = function fn(amount) {
|
|
@@ -4410,6 +4596,7 @@ var DOLLAR_AMOUNT_STRING_REGEX = /^\$?(\d+)\.?(\d\d)$/;
|
|
|
4410
4596
|
* @param maxOrArgs - Maximum value (exclusive) or full configuration object
|
|
4411
4597
|
* @param roundingInput - Optional rounding mode override
|
|
4412
4598
|
* @returns A factory function that produces random numbers within the range
|
|
4599
|
+
* @__NO_SIDE_EFFECTS__
|
|
4413
4600
|
*/ function randomNumberFactory(maxOrArgs, roundingInput) {
|
|
4414
4601
|
var config = typeof maxOrArgs === 'number' ? {
|
|
4415
4602
|
min: 0,
|
|
@@ -4455,8 +4642,15 @@ var DOLLAR_AMOUNT_STRING_REGEX = /^\$?(\d+)\.?(\d\d)$/;
|
|
|
4455
4642
|
/**
|
|
4456
4643
|
* Creates a {@link SortCompareFunction} that sorts values in ascending order by a numeric property.
|
|
4457
4644
|
*
|
|
4645
|
+
* @dbxUtil
|
|
4646
|
+
* @dbxUtilCategory number
|
|
4647
|
+
* @dbxUtilKind factory
|
|
4648
|
+
* @dbxUtilTags number, sort, compare, ascending, factory
|
|
4649
|
+
* @dbxUtilRelated sort-numbers-ascending-function, sort-by-string-function
|
|
4650
|
+
*
|
|
4458
4651
|
* @param readNumberFn - Function that extracts the numeric value from each item
|
|
4459
4652
|
* @returns A sort comparator function for ascending numeric order
|
|
4653
|
+
* @__NO_SIDE_EFFECTS__
|
|
4460
4654
|
*/ function sortByNumberFunction(readNumberFn) {
|
|
4461
4655
|
return function(a, b) {
|
|
4462
4656
|
var as = readNumberFn(a);
|
|
@@ -4487,8 +4681,15 @@ var DOLLAR_AMOUNT_STRING_REGEX = /^\$?(\d+)\.?(\d\d)$/;
|
|
|
4487
4681
|
*
|
|
4488
4682
|
* Chains the configured operations in order: custom transform, step rounding, precision cut, then bounds clamping.
|
|
4489
4683
|
*
|
|
4684
|
+
* @dbxUtil
|
|
4685
|
+
* @dbxUtilCategory number
|
|
4686
|
+
* @dbxUtilKind factory
|
|
4687
|
+
* @dbxUtilTags number, transform, factory, round, precision, bounds, chain
|
|
4688
|
+
* @dbxUtilRelated transform-string-function, round-number-to-step-function
|
|
4689
|
+
*
|
|
4490
4690
|
* @param config - Configuration with optional transform, roundToStep, precision, and bounds
|
|
4491
4691
|
* @returns A single function that applies all configured transformations in sequence
|
|
4692
|
+
* @__NO_SIDE_EFFECTS__
|
|
4492
4693
|
*/ function transformNumberFunction(config) {
|
|
4493
4694
|
var transformFunctions = [
|
|
4494
4695
|
config.transform
|
|
@@ -4716,12 +4917,19 @@ function reduceNumbersFn(reduceFn, emptyArrayValue) {
|
|
|
4716
4917
|
*
|
|
4717
4918
|
* @returns a compare function suitable for Array.sort()
|
|
4718
4919
|
*
|
|
4920
|
+
* @dbxUtil
|
|
4921
|
+
* @dbxUtilCategory value
|
|
4922
|
+
* @dbxUtilKind factory
|
|
4923
|
+
* @dbxUtilTags value, index, sort, ascending, factory, ref
|
|
4924
|
+
* @dbxUtilRelated sort-by-index-ascending-compare-function, sort-by-index-range-ascending-compare-function
|
|
4925
|
+
*
|
|
4719
4926
|
* @example
|
|
4720
4927
|
* ```ts
|
|
4721
4928
|
* const items = [{ i: 4 }, { i: 0 }, { i: 2 }];
|
|
4722
4929
|
* items.sort(sortAscendingIndexNumberRefFunction());
|
|
4723
4930
|
* // items[0].i === 0
|
|
4724
4931
|
* ```
|
|
4932
|
+
* @__NO_SIDE_EFFECTS__
|
|
4725
4933
|
*/ function sortAscendingIndexNumberRefFunction() {
|
|
4726
4934
|
return function(a, b) {
|
|
4727
4935
|
return a.i - b.i;
|
|
@@ -4743,6 +4951,12 @@ function reduceNumbersFn(reduceFn, emptyArrayValue) {
|
|
|
4743
4951
|
* @param readIndex - reads an item's index, returning null/undefined for unindexed items
|
|
4744
4952
|
* @returns a function that groups items by their index state
|
|
4745
4953
|
*
|
|
4954
|
+
* @dbxUtil
|
|
4955
|
+
* @dbxUtilCategory value
|
|
4956
|
+
* @dbxUtilKind factory
|
|
4957
|
+
* @dbxUtilTags value, index, delta, group, factory, classify
|
|
4958
|
+
* @dbxUtilRelated separate-values, compute-next-free-index-function
|
|
4959
|
+
*
|
|
4746
4960
|
* @example
|
|
4747
4961
|
* ```ts
|
|
4748
4962
|
* const groupFn = indexDeltaGroupFunction<{ x: string; i?: number }>((x) => x.i);
|
|
@@ -4751,6 +4965,7 @@ function reduceNumbersFn(reduceFn, emptyArrayValue) {
|
|
|
4751
4965
|
* // result.newItems.length === 1 (item without an index)
|
|
4752
4966
|
* // result.currentItems.length === 2 (items with indexes)
|
|
4753
4967
|
* ```
|
|
4968
|
+
* @__NO_SIDE_EFFECTS__
|
|
4754
4969
|
*/ function indexDeltaGroupFunction(readIndex) {
|
|
4755
4970
|
return function(inputItems, previousItems) {
|
|
4756
4971
|
var _separateValues = separateValues(inputItems, function(x) {
|
|
@@ -4788,8 +5003,15 @@ function reduceNumbersFn(reduceFn, emptyArrayValue) {
|
|
|
4788
5003
|
/**
|
|
4789
5004
|
* Creates a SortCompareFunction that sorts items in ascending order using a custom index reader.
|
|
4790
5005
|
*
|
|
5006
|
+
* @dbxUtil
|
|
5007
|
+
* @dbxUtilCategory value
|
|
5008
|
+
* @dbxUtilKind factory
|
|
5009
|
+
* @dbxUtilTags value, index, sort, ascending, factory, compare
|
|
5010
|
+
* @dbxUtilRelated sort-ascending-index-number-ref-function, sort-by-index-range-ascending-compare-function
|
|
5011
|
+
*
|
|
4791
5012
|
* @param readIndex - extracts the index number from each item
|
|
4792
5013
|
* @returns a compare function suitable for Array.sort()
|
|
5014
|
+
* @__NO_SIDE_EFFECTS__
|
|
4793
5015
|
*/ function sortByIndexAscendingCompareFunction(readIndex) {
|
|
4794
5016
|
return function(a, b) {
|
|
4795
5017
|
return readIndex(a) - readIndex(b);
|
|
@@ -4803,12 +5025,19 @@ function reduceNumbersFn(reduceFn, emptyArrayValue) {
|
|
|
4803
5025
|
* @param nextIndex - optional custom function to compute the next index from the max item; defaults to max + 1
|
|
4804
5026
|
* @returns a function that computes the next free index for a given array
|
|
4805
5027
|
*
|
|
5028
|
+
* @dbxUtil
|
|
5029
|
+
* @dbxUtilCategory value
|
|
5030
|
+
* @dbxUtilKind factory
|
|
5031
|
+
* @dbxUtilTags value, index, free, next, factory, max
|
|
5032
|
+
* @dbxUtilRelated compute-next-free-index-on-sorted-values-function, min-and-max-index-function
|
|
5033
|
+
*
|
|
4806
5034
|
* @example
|
|
4807
5035
|
* ```ts
|
|
4808
5036
|
* const fn = computeNextFreeIndexFunction<IndexRef>((x) => x.i);
|
|
4809
5037
|
* const nextIndex = fn([{ i: 0 }, { i: 1 }, { i: 5 }]);
|
|
4810
5038
|
* // nextIndex === 6
|
|
4811
5039
|
* ```
|
|
5040
|
+
* @__NO_SIDE_EFFECTS__
|
|
4812
5041
|
*/ function computeNextFreeIndexFunction(readIndex, nextIndex) {
|
|
4813
5042
|
var findMinMax = minAndMaxIndexItemsFunction(readIndex);
|
|
4814
5043
|
var readNextIndex = nextIndex !== null && nextIndex !== void 0 ? nextIndex : function(x) {
|
|
@@ -4824,9 +5053,16 @@ function reduceNumbersFn(reduceFn, emptyArrayValue) {
|
|
|
4824
5053
|
* Creates a {@link ComputeNextFreeIndexFunction} optimized for pre-sorted input arrays.
|
|
4825
5054
|
* Instead of scanning all items for the maximum, it reads only the last element.
|
|
4826
5055
|
*
|
|
5056
|
+
* @dbxUtil
|
|
5057
|
+
* @dbxUtilCategory value
|
|
5058
|
+
* @dbxUtilKind factory
|
|
5059
|
+
* @dbxUtilTags value, index, free, next, sorted, factory, optimized
|
|
5060
|
+
* @dbxUtilRelated compute-next-free-index-function
|
|
5061
|
+
*
|
|
4827
5062
|
* @param readIndex - extracts the index number from each item
|
|
4828
5063
|
* @param nextIndex - optional custom function to compute the next index from the last item; defaults to last + 1
|
|
4829
5064
|
* @returns a function that computes the next free index from sorted arrays
|
|
5065
|
+
* @__NO_SIDE_EFFECTS__
|
|
4830
5066
|
*/ function computeNextFreeIndexOnSortedValuesFunction(readIndex, nextIndex) {
|
|
4831
5067
|
var readNextIndex = nextIndex !== null && nextIndex !== void 0 ? nextIndex : function(x) {
|
|
4832
5068
|
return readIndex(x) + 1;
|
|
@@ -4842,12 +5078,19 @@ function reduceNumbersFn(reduceFn, emptyArrayValue) {
|
|
|
4842
5078
|
* @param readIndex - extracts the index number from each item
|
|
4843
5079
|
* @returns a function returning the min/max indexes, or null for empty input
|
|
4844
5080
|
*
|
|
5081
|
+
* @dbxUtil
|
|
5082
|
+
* @dbxUtilCategory value
|
|
5083
|
+
* @dbxUtilKind factory
|
|
5084
|
+
* @dbxUtilTags value, index, min, max, factory, range
|
|
5085
|
+
* @dbxUtilRelated min-and-max-index, min-and-max-index-items-function
|
|
5086
|
+
*
|
|
4845
5087
|
* @example
|
|
4846
5088
|
* ```ts
|
|
4847
5089
|
* const fn = minAndMaxIndexFunction<IndexRef>((x) => x.i);
|
|
4848
5090
|
* const result = fn([{ i: 3 }, { i: 0 }, { i: 5 }]);
|
|
4849
5091
|
* // result?.min === 0, result?.max === 5
|
|
4850
5092
|
* ```
|
|
5093
|
+
* @__NO_SIDE_EFFECTS__
|
|
4851
5094
|
*/ function minAndMaxIndexFunction(readIndex) {
|
|
4852
5095
|
var minAndMaxItems = minAndMaxIndexItemsFunction(readIndex);
|
|
4853
5096
|
var fn = function fn(values) {
|
|
@@ -4873,8 +5116,15 @@ function reduceNumbersFn(reduceFn, emptyArrayValue) {
|
|
|
4873
5116
|
* Creates a {@link MinAndMaxIndexItemsFunction} that returns the actual items (not just index numbers)
|
|
4874
5117
|
* with the minimum and maximum index values.
|
|
4875
5118
|
*
|
|
5119
|
+
* @dbxUtil
|
|
5120
|
+
* @dbxUtilCategory value
|
|
5121
|
+
* @dbxUtilKind factory
|
|
5122
|
+
* @dbxUtilTags value, index, min, max, items, factory
|
|
5123
|
+
* @dbxUtilRelated min-and-max-index-function, min-and-max-function
|
|
5124
|
+
*
|
|
4876
5125
|
* @param readIndex - extracts the index number from each item
|
|
4877
5126
|
* @returns a function returning the min/max items, or null for empty input
|
|
5127
|
+
* @__NO_SIDE_EFFECTS__
|
|
4878
5128
|
*/ function minAndMaxIndexItemsFunction(readIndex) {
|
|
4879
5129
|
var fn = minAndMaxFunction(readIndex);
|
|
4880
5130
|
fn._readIndex = readIndex;
|
|
@@ -4929,6 +5179,14 @@ function reduceNumbersFn(reduceFn, emptyArrayValue) {
|
|
|
4929
5179
|
* fn({ i: 6 }); // returns { i: 5 }
|
|
4930
5180
|
* fn({ i: 11 }); // returns { i: 10 }
|
|
4931
5181
|
* ```
|
|
5182
|
+
*
|
|
5183
|
+
* @dbxUtil
|
|
5184
|
+
* @dbxUtilCategory value
|
|
5185
|
+
* @dbxUtilKind factory
|
|
5186
|
+
* @dbxUtilTags value, index, match, find, factory, lookup
|
|
5187
|
+
* @dbxUtilRelated find-best-index-match, safe-find-best-index-match
|
|
5188
|
+
*
|
|
5189
|
+
* @__NO_SIDE_EFFECTS__
|
|
4932
5190
|
*/ function findBestIndexMatchFunction(items) {
|
|
4933
5191
|
// reverse the order so we can return the first item that is less than or equal to the input i
|
|
4934
5192
|
var bestMatchArray = iterableToArray(items, false).sort(reverseCompareFn(sortAscendingIndexNumberRefFunction()));
|
|
@@ -4979,8 +5237,15 @@ function reduceNumbersFn(reduceFn, emptyArrayValue) {
|
|
|
4979
5237
|
* Creates a SortCompareFunction that sorts items by their IndexRange in ascending order.
|
|
4980
5238
|
* Sorts by minIndex first, then by maxIndex for items with equal minIndex values.
|
|
4981
5239
|
*
|
|
5240
|
+
* @dbxUtil
|
|
5241
|
+
* @dbxUtilCategory value
|
|
5242
|
+
* @dbxUtilKind factory
|
|
5243
|
+
* @dbxUtilTags value, index-range, sort, ascending, factory, compare
|
|
5244
|
+
* @dbxUtilRelated sort-by-index-ascending-compare-function, index-range-reader-pair-factory
|
|
5245
|
+
*
|
|
4982
5246
|
* @param readIndexRange - extracts the IndexRange from each item
|
|
4983
5247
|
* @returns a compare function suitable for Array.sort()
|
|
5248
|
+
* @__NO_SIDE_EFFECTS__
|
|
4984
5249
|
*/ function sortByIndexRangeAscendingCompareFunction(readIndexRange) {
|
|
4985
5250
|
return function(a, b) {
|
|
4986
5251
|
var ra = readIndexRange(a);
|
|
@@ -4992,8 +5257,15 @@ function reduceNumbersFn(reduceFn, emptyArrayValue) {
|
|
|
4992
5257
|
/**
|
|
4993
5258
|
* Creates a new {@link IndexRangeReaderPairFactory} that pairs each value with its computed IndexRange.
|
|
4994
5259
|
*
|
|
5260
|
+
* @dbxUtil
|
|
5261
|
+
* @dbxUtilCategory value
|
|
5262
|
+
* @dbxUtilKind factory
|
|
5263
|
+
* @dbxUtilTags value, index-range, pair, factory, reader
|
|
5264
|
+
* @dbxUtilRelated sort-by-index-range-ascending-compare-function
|
|
5265
|
+
*
|
|
4995
5266
|
* @param reader - reads the IndexRange from the input value
|
|
4996
5267
|
* @returns a factory that creates IndexRangeReaderPair instances
|
|
5268
|
+
* @__NO_SIDE_EFFECTS__
|
|
4997
5269
|
*/ function indexRangeReaderPairFactory(reader) {
|
|
4998
5270
|
return function(value) {
|
|
4999
5271
|
var range = reader(value);
|
|
@@ -5018,8 +5290,15 @@ function reduceNumbersFn(reduceFn, emptyArrayValue) {
|
|
|
5018
5290
|
/**
|
|
5019
5291
|
* Creates a {@link FitToIndexRangeFunction} that clamps index numbers to the given range boundaries.
|
|
5020
5292
|
*
|
|
5293
|
+
* @dbxUtil
|
|
5294
|
+
* @dbxUtilCategory value
|
|
5295
|
+
* @dbxUtilKind factory
|
|
5296
|
+
* @dbxUtilTags value, index, clamp, range, factory, fit
|
|
5297
|
+
* @dbxUtilRelated wrap-index-range-function, bound-number-function
|
|
5298
|
+
*
|
|
5021
5299
|
* @param input - the range to clamp to
|
|
5022
5300
|
* @returns a function that clamps any index to the range
|
|
5301
|
+
* @__NO_SIDE_EFFECTS__
|
|
5023
5302
|
*/ function fitToIndexRangeFunction(input) {
|
|
5024
5303
|
var min = input.minIndex, maxIndex = input.maxIndex;
|
|
5025
5304
|
var max = maxIndex - 1;
|
|
@@ -5037,12 +5316,19 @@ function reduceNumbersFn(reduceFn, emptyArrayValue) {
|
|
|
5037
5316
|
* @param fencePosts - whether to use fencepost semantics (maxIndex is exclusive); defaults to true
|
|
5038
5317
|
* @returns a function that wraps any index into the range
|
|
5039
5318
|
*
|
|
5319
|
+
* @dbxUtil
|
|
5320
|
+
* @dbxUtilCategory value
|
|
5321
|
+
* @dbxUtilKind factory
|
|
5322
|
+
* @dbxUtilTags value, index, wrap, range, factory, modular
|
|
5323
|
+
* @dbxUtilRelated fit-to-index-range-function, wrap-number-function
|
|
5324
|
+
*
|
|
5040
5325
|
* @example
|
|
5041
5326
|
* ```ts
|
|
5042
5327
|
* const wrap = wrapIndexRangeFunction({ minIndex: 0, maxIndex: 6 });
|
|
5043
5328
|
* wrap(6); // 0 (wraps from positive side)
|
|
5044
5329
|
* wrap(-1); // 5 (wraps from negative side)
|
|
5045
5330
|
* ```
|
|
5331
|
+
* @__NO_SIDE_EFFECTS__
|
|
5046
5332
|
*/ function wrapIndexRangeFunction(input) {
|
|
5047
5333
|
var fencePosts = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
|
|
5048
5334
|
var min = input.minIndex, maxIndex = input.maxIndex;
|
|
@@ -5090,8 +5376,15 @@ function indexRangeCheckFunctionConfigToIndexRange(param) {
|
|
|
5090
5376
|
* Creates an {@link IndexRangeCheckFunction} that tests whether an index number falls within the configured range.
|
|
5091
5377
|
* The min is inclusive and the max is exclusive by default unless `inclusiveMaxIndex` is set.
|
|
5092
5378
|
*
|
|
5379
|
+
* @dbxUtil
|
|
5380
|
+
* @dbxUtilCategory value
|
|
5381
|
+
* @dbxUtilKind factory
|
|
5382
|
+
* @dbxUtilTags value, index, range, check, factory, predicate
|
|
5383
|
+
* @dbxUtilRelated index-range-check-reader-function, is-index-number-in-index-range-function
|
|
5384
|
+
*
|
|
5093
5385
|
* @param input - the range or range config to check against
|
|
5094
5386
|
* @returns a predicate function for index numbers
|
|
5387
|
+
* @__NO_SIDE_EFFECTS__
|
|
5095
5388
|
*/ function indexRangeCheckFunction(input) {
|
|
5096
5389
|
var _indexRangeCheckFunctionConfigToIndexRange = indexRangeCheckFunctionConfigToIndexRange(asIndexRangeCheckFunctionConfig(input)), minIndex = _indexRangeCheckFunctionConfigToIndexRange.minIndex, maxIndex = _indexRangeCheckFunctionConfigToIndexRange.maxIndex;
|
|
5097
5390
|
return function(i) {
|
|
@@ -5115,8 +5408,15 @@ function indexRangeCheckFunctionConfigToIndexRange(param) {
|
|
|
5115
5408
|
/**
|
|
5116
5409
|
* Creates an {@link IsIndexNumberInIndexRangeFunction} bound to the given range configuration.
|
|
5117
5410
|
*
|
|
5411
|
+
* @dbxUtil
|
|
5412
|
+
* @dbxUtilCategory value
|
|
5413
|
+
* @dbxUtilKind factory
|
|
5414
|
+
* @dbxUtilTags value, index, range, check, factory, predicate
|
|
5415
|
+
* @dbxUtilRelated is-index-number-in-index-range, index-range-check-function
|
|
5416
|
+
*
|
|
5118
5417
|
* @param input - the range or range config to bind
|
|
5119
5418
|
* @returns a predicate that tests index numbers against the bound range
|
|
5419
|
+
* @__NO_SIDE_EFFECTS__
|
|
5120
5420
|
*/ function isIndexNumberInIndexRangeFunction(input) {
|
|
5121
5421
|
var _indexRangeCheckFunctionConfigToIndexRange = indexRangeCheckFunctionConfigToIndexRange(asIndexRangeCheckFunctionConfig(input)), minIndex = _indexRangeCheckFunctionConfigToIndexRange.minIndex, maxIndex = _indexRangeCheckFunctionConfigToIndexRange.maxIndex;
|
|
5122
5422
|
return function(index) {
|
|
@@ -5135,8 +5435,15 @@ function indexRangeCheckFunctionConfigToIndexRange(param) {
|
|
|
5135
5435
|
/**
|
|
5136
5436
|
* Creates an {@link IsIndexRangeInIndexRangeFunction} bound to the given range configuration.
|
|
5137
5437
|
*
|
|
5438
|
+
* @dbxUtil
|
|
5439
|
+
* @dbxUtilCategory value
|
|
5440
|
+
* @dbxUtilKind factory
|
|
5441
|
+
* @dbxUtilTags value, index-range, contains, decision, factory, predicate
|
|
5442
|
+
* @dbxUtilRelated is-index-range-in-index-range, index-range-overlaps-index-range-function
|
|
5443
|
+
*
|
|
5138
5444
|
* @param input - the bounding range or range config to bind
|
|
5139
5445
|
* @returns a predicate that tests whether index ranges are fully contained
|
|
5446
|
+
* @__NO_SIDE_EFFECTS__
|
|
5140
5447
|
*/ function isIndexRangeInIndexRangeFunction(input) {
|
|
5141
5448
|
var _indexRangeCheckFunctionConfigToIndexRange = indexRangeCheckFunctionConfigToIndexRange(asIndexRangeCheckFunctionConfig(input)), minIndex = _indexRangeCheckFunctionConfigToIndexRange.minIndex, maxIndex = _indexRangeCheckFunctionConfigToIndexRange.maxIndex;
|
|
5142
5449
|
return function(input) {
|
|
@@ -5155,8 +5462,15 @@ function indexRangeCheckFunctionConfigToIndexRange(param) {
|
|
|
5155
5462
|
/**
|
|
5156
5463
|
* Creates an {@link IndexRangeOverlapsIndexRangeFunction} bound to the given range configuration.
|
|
5157
5464
|
*
|
|
5465
|
+
* @dbxUtil
|
|
5466
|
+
* @dbxUtilCategory value
|
|
5467
|
+
* @dbxUtilKind factory
|
|
5468
|
+
* @dbxUtilTags value, index-range, overlap, decision, factory, predicate
|
|
5469
|
+
* @dbxUtilRelated is-index-range-in-index-range-function, index-range-check-function
|
|
5470
|
+
*
|
|
5158
5471
|
* @param input - the reference range or range config to bind
|
|
5159
5472
|
* @returns a predicate that tests for overlap with the bound range
|
|
5473
|
+
* @__NO_SIDE_EFFECTS__
|
|
5160
5474
|
*/ function indexRangeOverlapsIndexRangeFunction(input) {
|
|
5161
5475
|
var _indexRangeCheckFunctionConfigToIndexRange = indexRangeCheckFunctionConfigToIndexRange(asIndexRangeCheckFunctionConfig(input)), minIndex = _indexRangeCheckFunctionConfigToIndexRange.minIndex, maxIndex = _indexRangeCheckFunctionConfigToIndexRange.maxIndex;
|
|
5162
5476
|
return function(input) {
|
|
@@ -5175,8 +5489,15 @@ function indexRangeCheckFunctionConfigToIndexRange(param) {
|
|
|
5175
5489
|
* Creates a {@link StepsFromIndexFunction} that computes the next index after stepping from a start position.
|
|
5176
5490
|
* Returns undefined when the result falls outside the range (unless wrapping or fitting is enabled).
|
|
5177
5491
|
*
|
|
5492
|
+
* @dbxUtil
|
|
5493
|
+
* @dbxUtilCategory value
|
|
5494
|
+
* @dbxUtilKind factory
|
|
5495
|
+
* @dbxUtilTags value, index, step, range, factory, wrap, navigation
|
|
5496
|
+
* @dbxUtilRelated wrap-index-range-function, fit-to-index-range-function
|
|
5497
|
+
*
|
|
5178
5498
|
* @param config - stepping behavior configuration
|
|
5179
5499
|
* @returns a function that computes the stepped index
|
|
5500
|
+
* @__NO_SIDE_EFFECTS__
|
|
5180
5501
|
*/ function stepsFromIndexFunction(config) {
|
|
5181
5502
|
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;
|
|
5182
5503
|
var wrapNumber = wrapIndexRangeFunction(range, fencePosts);
|
|
@@ -5316,8 +5637,15 @@ function stepsFromIndex(range, startIndex) {
|
|
|
5316
5637
|
/**
|
|
5317
5638
|
* Creates a {@link SliceIndexRangeFunction} that slices the specified index range from any input array.
|
|
5318
5639
|
*
|
|
5640
|
+
* @dbxUtil
|
|
5641
|
+
* @dbxUtilCategory array
|
|
5642
|
+
* @dbxUtilKind factory
|
|
5643
|
+
* @dbxUtilTags array, slice, index, range, factory
|
|
5644
|
+
* @dbxUtilRelated index-range, find-to-index-set
|
|
5645
|
+
*
|
|
5319
5646
|
* @param inputRange - the index range configuration to use for slicing
|
|
5320
5647
|
* @returns a function that slices the configured range from an input array
|
|
5648
|
+
* @__NO_SIDE_EFFECTS__
|
|
5321
5649
|
*/ function sliceIndexRangeFunction(inputRange) {
|
|
5322
5650
|
var range = indexRange(inputRange);
|
|
5323
5651
|
return function(input) {
|
|
@@ -5329,15 +5657,39 @@ function stepsFromIndex(range, startIndex) {
|
|
|
5329
5657
|
* Filters the input values by distance while maintaining the original order of elements.
|
|
5330
5658
|
* Values that are too close to each other (based on the minDistance parameter) will be filtered out.
|
|
5331
5659
|
*
|
|
5660
|
+
* Items whose extracted value is null are excluded from the result.
|
|
5661
|
+
*
|
|
5332
5662
|
* If order is irrelevant, use filterValuesByDistanceNoOrder() instead.
|
|
5333
5663
|
*
|
|
5334
|
-
* @param
|
|
5335
|
-
* @param
|
|
5336
|
-
* @param
|
|
5337
|
-
* @returns A filtered array with only values that are at least minDistance apart
|
|
5338
|
-
*/ function filterValuesByDistance(
|
|
5339
|
-
//
|
|
5340
|
-
|
|
5664
|
+
* @param input - The array of values to filter
|
|
5665
|
+
* @param minDistance - The minimum distance required between values (inclusive)
|
|
5666
|
+
* @param getValue - Function that extracts a numeric value from each item for distance comparison
|
|
5667
|
+
* @returns A filtered array with only values that are at least minDistance apart, in their original input order
|
|
5668
|
+
*/ function filterValuesByDistance(input, minDistance, getValue) {
|
|
5669
|
+
// Tag each non-null value with its original index so we can restore order after the distance filter.
|
|
5670
|
+
var tagged = [];
|
|
5671
|
+
for(var i = 0, n = input.length; i < n; i += 1){
|
|
5672
|
+
var item = input[i];
|
|
5673
|
+
var value = getValue(item);
|
|
5674
|
+
if (value != null) {
|
|
5675
|
+
tagged.push([
|
|
5676
|
+
{
|
|
5677
|
+
item: item,
|
|
5678
|
+
index: i
|
|
5679
|
+
},
|
|
5680
|
+
value
|
|
5681
|
+
]);
|
|
5682
|
+
}
|
|
5683
|
+
}
|
|
5684
|
+
var kept = _filterValuesByDistance(tagged, minDistance, function(x) {
|
|
5685
|
+
return x[0];
|
|
5686
|
+
});
|
|
5687
|
+
kept.sort(function(a, b) {
|
|
5688
|
+
return a.index - b.index;
|
|
5689
|
+
});
|
|
5690
|
+
return kept.map(function(x) {
|
|
5691
|
+
return x.item;
|
|
5692
|
+
});
|
|
5341
5693
|
}
|
|
5342
5694
|
/**
|
|
5343
5695
|
* Filters the input values by an arbitrary "distance"/difference from each other and returns the values sorted by their determined distance.
|
|
@@ -5401,14 +5753,17 @@ function stepsFromIndex(range, startIndex) {
|
|
|
5401
5753
|
/**
|
|
5402
5754
|
* Same as applyBestFit, but returns a new array, rather than modifying the existing array.
|
|
5403
5755
|
*
|
|
5404
|
-
* @
|
|
5405
|
-
* @
|
|
5406
|
-
* @
|
|
5407
|
-
* @
|
|
5408
|
-
*
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
|
|
5756
|
+
* @dbxUtil
|
|
5757
|
+
* @dbxUtilCategory array
|
|
5758
|
+
* @dbxUtilTags array, best-fit, filter, sort, immutable
|
|
5759
|
+
* @dbxUtilRelated apply-best-fit, find-best-index-set-pair
|
|
5760
|
+
*
|
|
5761
|
+
* @param input - The array to filter for the best fit.
|
|
5762
|
+
* @param config - The best-fit strategy ({@link BestFitConfig}).
|
|
5763
|
+
* @returns A new array with only the best fit item and transformed non-best-fit items.
|
|
5764
|
+
* @__NO_SIDE_EFFECTS__
|
|
5765
|
+
*/ function makeBestFit(input, config) {
|
|
5766
|
+
return applyBestFit(copyArray(input), config);
|
|
5412
5767
|
}
|
|
5413
5768
|
/**
|
|
5414
5769
|
* Used for updating an array so that a single element becomes the "best fit" in whatever context is provided.
|
|
@@ -5416,13 +5771,16 @@ function makeBestFit(input, filter, compare, updateNonBestFit) {
|
|
|
5416
5771
|
* For instance, if two items are selected but only one can be selected by design, this function can be used to
|
|
5417
5772
|
* pick the best fit, and update the input array.
|
|
5418
5773
|
*
|
|
5419
|
-
* @
|
|
5420
|
-
* @
|
|
5421
|
-
* @
|
|
5422
|
-
* @
|
|
5423
|
-
*
|
|
5424
|
-
|
|
5425
|
-
|
|
5774
|
+
* @dbxUtil
|
|
5775
|
+
* @dbxUtilCategory array
|
|
5776
|
+
* @dbxUtilTags array, best-fit, filter, sort, mutable, in-place
|
|
5777
|
+
* @dbxUtilRelated make-best-fit, find-best-index-set-pair
|
|
5778
|
+
*
|
|
5779
|
+
* @param input - The array to modify in-place.
|
|
5780
|
+
* @param config - The best-fit strategy ({@link BestFitConfig}).
|
|
5781
|
+
* @returns The modified input array with only the best fit item and transformed non-best-fit items.
|
|
5782
|
+
*/ function applyBestFit(input, config) {
|
|
5783
|
+
var filter = config.filter, compare = config.compare, updateNonBestFit = config.updateNonBestFit;
|
|
5426
5784
|
var matchIndexSet = findToIndexSet(input, filter);
|
|
5427
5785
|
if (matchIndexSet.length > 1) {
|
|
5428
5786
|
var expansion = expandIndexSet(input, matchIndexSet);
|
|
@@ -5440,9 +5798,16 @@ function applyBestFit(input, filter, compare, updateNonBestFit) {
|
|
|
5440
5798
|
* Creates a function that filters the input values and maps all matching values to a new value.
|
|
5441
5799
|
* This is a higher-order function that combines filtering and mapping operations.
|
|
5442
5800
|
*
|
|
5801
|
+
* @dbxUtil
|
|
5802
|
+
* @dbxUtilCategory array
|
|
5803
|
+
* @dbxUtilKind factory
|
|
5804
|
+
* @dbxUtilTags array, filter, map, transform, factory, iterable
|
|
5805
|
+
* @dbxUtilRelated array-decision-function
|
|
5806
|
+
*
|
|
5443
5807
|
* @param decisionFunction - Function that determines which items to include in the result
|
|
5444
5808
|
* @param mapFunction - Function that transforms each included item
|
|
5445
5809
|
* @returns A function that takes an iterable of input values and returns an array of transformed values
|
|
5810
|
+
* @__NO_SIDE_EFFECTS__
|
|
5446
5811
|
*/ function filterAndMapFunction(decisionFunction, mapFunction) {
|
|
5447
5812
|
return function(values) {
|
|
5448
5813
|
var result = [];
|
|
@@ -5466,6 +5831,7 @@ function applyBestFit(input, filter, compare, updateNonBestFit) {
|
|
|
5466
5831
|
*
|
|
5467
5832
|
* @param factory - The factory function used to generate each item
|
|
5468
5833
|
* @returns A function that takes a count parameter and returns an array of generated items
|
|
5834
|
+
* @__NO_SIDE_EFFECTS__
|
|
5469
5835
|
*/ function arrayFactory(factory) {
|
|
5470
5836
|
return function(count) {
|
|
5471
5837
|
return makeWithFactory(factory, count);
|
|
@@ -5482,6 +5848,7 @@ function applyBestFit(input, filter, compare, updateNonBestFit) {
|
|
|
5482
5848
|
*
|
|
5483
5849
|
* @param factory - The factory function used to transform each input value
|
|
5484
5850
|
* @returns A function that takes an array of input values and returns an array of output values
|
|
5851
|
+
* @__NO_SIDE_EFFECTS__
|
|
5485
5852
|
*/ function arrayInputFactory(factory) {
|
|
5486
5853
|
return function(input) {
|
|
5487
5854
|
return makeWithFactoryInput(factory, input);
|
|
@@ -5566,8 +5933,15 @@ function getArrayNextIndex(array, index) {
|
|
|
5566
5933
|
*
|
|
5567
5934
|
* Each accessor maps an index to the value whose range contains that index, or undefined if no range matches.
|
|
5568
5935
|
*
|
|
5936
|
+
* @dbxUtil
|
|
5937
|
+
* @dbxUtilCategory array
|
|
5938
|
+
* @dbxUtilKind factory
|
|
5939
|
+
* @dbxUtilTags array, indexed, range, accessor, factory, lookup
|
|
5940
|
+
* @dbxUtilRelated indexed-values-array-accessor-factory, ranged-indexed-values-array-accessor-info-factory
|
|
5941
|
+
*
|
|
5569
5942
|
* @param readIndexRange - Function that reads the index range from each value.
|
|
5570
5943
|
* @returns A factory that creates ranged accessors from arrays of values.
|
|
5944
|
+
* @__NO_SIDE_EFFECTS__
|
|
5571
5945
|
*/ function rangedIndexedValuesArrayAccessorFactory(readIndexRange) {
|
|
5572
5946
|
var readInfoFactory = rangedIndexedValuesArrayAccessorInfoFactory({
|
|
5573
5947
|
readIndexRange: readIndexRange
|
|
@@ -5586,9 +5960,16 @@ function getArrayNextIndex(array, index) {
|
|
|
5586
5960
|
* Each accessor maps an index to the matching value, falling back to the previous value, then the next value.
|
|
5587
5961
|
* This guarantees a value is always returned.
|
|
5588
5962
|
*
|
|
5963
|
+
* @dbxUtil
|
|
5964
|
+
* @dbxUtilCategory array
|
|
5965
|
+
* @dbxUtilKind factory
|
|
5966
|
+
* @dbxUtilTags array, indexed, range, accessor, factory, fallback
|
|
5967
|
+
* @dbxUtilRelated ranged-indexed-values-array-accessor-factory, ranged-indexed-values-array-accessor-info-factory
|
|
5968
|
+
*
|
|
5589
5969
|
* @param readIndexRange - Function that reads the index range from each value.
|
|
5590
5970
|
* @returns A factory that creates indexed accessors from arrays of values.
|
|
5591
5971
|
* @throws Error if the provided values array is empty.
|
|
5972
|
+
* @__NO_SIDE_EFFECTS__
|
|
5592
5973
|
*/ function indexedValuesArrayAccessorFactory(readIndexRange) {
|
|
5593
5974
|
var readInfoFactory = rangedIndexedValuesArrayAccessorInfoFactory({
|
|
5594
5975
|
readIndexRange: readIndexRange
|
|
@@ -5612,8 +5993,15 @@ function getArrayNextIndex(array, index) {
|
|
|
5612
5993
|
* Each accessor sorts the values by their index ranges in ascending order, then for a given index
|
|
5613
5994
|
* returns the matching value along with its previous and next neighbors.
|
|
5614
5995
|
*
|
|
5996
|
+
* @dbxUtil
|
|
5997
|
+
* @dbxUtilCategory array
|
|
5998
|
+
* @dbxUtilKind factory
|
|
5999
|
+
* @dbxUtilTags array, indexed, range, accessor, info, factory, neighbors
|
|
6000
|
+
* @dbxUtilRelated ranged-indexed-values-array-accessor-factory, indexed-values-array-accessor-factory
|
|
6001
|
+
*
|
|
5615
6002
|
* @param config - Configuration containing the index range reader function.
|
|
5616
6003
|
* @returns A factory that creates ranged info accessors from arrays of values.
|
|
6004
|
+
* @__NO_SIDE_EFFECTS__
|
|
5617
6005
|
*/ function rangedIndexedValuesArrayAccessorInfoFactory(config) {
|
|
5618
6006
|
var pairFactory = indexRangeReaderPairFactory(config.readIndexRange);
|
|
5619
6007
|
return function(values) {
|
|
@@ -5679,8 +6067,15 @@ function limitArray(array, inputConfig) {
|
|
|
5679
6067
|
/**
|
|
5680
6068
|
* Creates a factory function that generates arrays of a random length populated with items from a make function.
|
|
5681
6069
|
*
|
|
6070
|
+
* @dbxUtil
|
|
6071
|
+
* @dbxUtilCategory array
|
|
6072
|
+
* @dbxUtilKind factory
|
|
6073
|
+
* @dbxUtilTags array, random, factory, generate, make
|
|
6074
|
+
* @dbxUtilRelated array-factory, random-number-factory
|
|
6075
|
+
*
|
|
5682
6076
|
* @param config - configuration containing the make function and random number source
|
|
5683
6077
|
* @returns a factory that produces arrays of random length, optionally accepting a specific count override
|
|
6078
|
+
* @__NO_SIDE_EFFECTS__
|
|
5684
6079
|
*/ function randomArrayFactory(config) {
|
|
5685
6080
|
var randomFn = typeof config.random === 'function' ? config.random : randomNumberFactory(config.random);
|
|
5686
6081
|
var nextRandomCount = function nextRandomCount() {
|
|
@@ -5747,6 +6142,7 @@ function generateIfDoesNotExist(keys, existing, readKey, generateFn) {
|
|
|
5747
6142
|
* @param values - array of values to randomly pick from
|
|
5748
6143
|
* @returns a callable factory that returns a random value from the array on each invocation
|
|
5749
6144
|
* @throws Error if the input array is empty
|
|
6145
|
+
* @__NO_SIDE_EFFECTS__
|
|
5750
6146
|
*/ function randomPickFactory(values) {
|
|
5751
6147
|
if (values.length === 0) {
|
|
5752
6148
|
throw new Error('randomPickFactory() cannot use an empty array.');
|
|
@@ -6056,6 +6452,7 @@ function caseInsensitiveString(input) {
|
|
|
6056
6452
|
*
|
|
6057
6453
|
* @param config - configuration controlling max length and end text behavior
|
|
6058
6454
|
* @returns a reusable function that truncates input strings
|
|
6455
|
+
* @__NO_SIDE_EFFECTS__
|
|
6059
6456
|
*/ function cutStringFunction(config) {
|
|
6060
6457
|
var inputMaxLength = config.maxLength, maxLengthIncludesEndText = config.maxLengthIncludesEndText, inputEndText = config.endText;
|
|
6061
6458
|
var endText = inputEndText === undefined ? DEFAULT_CUT_STRING_END_TEXT : '';
|
|
@@ -6172,24 +6569,42 @@ function caseInsensitiveString(input) {
|
|
|
6172
6569
|
/**
|
|
6173
6570
|
* Trims leading and trailing whitespace from a string.
|
|
6174
6571
|
*
|
|
6572
|
+
* @dbxUtil
|
|
6573
|
+
* @dbxUtilCategory string
|
|
6574
|
+
* @dbxUtilTags string, trim, whitespace, transform
|
|
6575
|
+
* @dbxUtilRelated transform-string-function
|
|
6576
|
+
*
|
|
6175
6577
|
* @param input The string to trim.
|
|
6176
6578
|
* @returns The trimmed string.
|
|
6579
|
+
* @__NO_SIDE_EFFECTS__
|
|
6177
6580
|
*/ function stringTrimFunction(input) {
|
|
6178
6581
|
return input.trim();
|
|
6179
6582
|
}
|
|
6180
6583
|
/**
|
|
6181
6584
|
* Converts a string to uppercase.
|
|
6182
6585
|
*
|
|
6586
|
+
* @dbxUtil
|
|
6587
|
+
* @dbxUtilCategory string
|
|
6588
|
+
* @dbxUtilTags string, uppercase, case, transform
|
|
6589
|
+
* @dbxUtilRelated string-to-lowercase-function, transform-string-function
|
|
6590
|
+
*
|
|
6183
6591
|
* @param input The string to convert.
|
|
6184
6592
|
* @returns The uppercase string.
|
|
6593
|
+
* @__NO_SIDE_EFFECTS__
|
|
6185
6594
|
*/ function stringToUppercaseFunction(input) {
|
|
6186
6595
|
return input.toUpperCase();
|
|
6187
6596
|
}
|
|
6188
6597
|
/**
|
|
6189
6598
|
* Converts a string to lowercase.
|
|
6190
6599
|
*
|
|
6600
|
+
* @dbxUtil
|
|
6601
|
+
* @dbxUtilCategory string
|
|
6602
|
+
* @dbxUtilTags string, lowercase, case, transform
|
|
6603
|
+
* @dbxUtilRelated string-to-uppercase-function, transform-string-function
|
|
6604
|
+
*
|
|
6191
6605
|
* @param input The string to convert.
|
|
6192
6606
|
* @returns The lowercase string.
|
|
6607
|
+
* @__NO_SIDE_EFFECTS__
|
|
6193
6608
|
*/ function stringToLowercaseFunction(input) {
|
|
6194
6609
|
return input.toLowerCase();
|
|
6195
6610
|
}
|
|
@@ -6216,9 +6631,16 @@ function caseInsensitiveString(input) {
|
|
|
6216
6631
|
* 4. Lowercase conversion (if `config.toLowercase` is true and no `config.transform` or `config.toUppercase`).
|
|
6217
6632
|
* If no transformations are specified, the identity function is returned.
|
|
6218
6633
|
*
|
|
6634
|
+
* @dbxUtil
|
|
6635
|
+
* @dbxUtilCategory string
|
|
6636
|
+
* @dbxUtilKind factory
|
|
6637
|
+
* @dbxUtilTags string, transform, trim, case, slice, factory
|
|
6638
|
+
* @dbxUtilRelated string-trim-function, string-to-uppercase-function, string-to-lowercase-function, slice-string-function
|
|
6639
|
+
*
|
|
6219
6640
|
* @template S The specific string type, defaults to `string`.
|
|
6220
6641
|
* @param config The `TransformStringFunctionConfig` detailing the transformations.
|
|
6221
6642
|
* @returns A `TransformStringFunction` that applies the configured transformations.
|
|
6643
|
+
* @__NO_SIDE_EFFECTS__
|
|
6222
6644
|
*/ function transformStringFunction(config) {
|
|
6223
6645
|
var baseTransform;
|
|
6224
6646
|
if (config.transform) {
|
|
@@ -6264,8 +6686,15 @@ function caseInsensitiveString(input) {
|
|
|
6264
6686
|
/**
|
|
6265
6687
|
* Creates a function that adds a configured prefix to the input string if it does not exist on that string.
|
|
6266
6688
|
*
|
|
6689
|
+
* @dbxUtil
|
|
6690
|
+
* @dbxUtilCategory string
|
|
6691
|
+
* @dbxUtilKind factory
|
|
6692
|
+
* @dbxUtilTags string, prefix, add, factory
|
|
6693
|
+
* @dbxUtilRelated add-prefix, add-suffix-function
|
|
6694
|
+
*
|
|
6267
6695
|
* @param prefix The prefix to add.
|
|
6268
6696
|
* @returns A function that adds the prefix to a string.
|
|
6697
|
+
* @__NO_SIDE_EFFECTS__
|
|
6269
6698
|
*/ function addPrefixFunction(prefix) {
|
|
6270
6699
|
return function(input) {
|
|
6271
6700
|
return input.startsWith(prefix) ? input : prefix + input;
|
|
@@ -6283,8 +6712,15 @@ function caseInsensitiveString(input) {
|
|
|
6283
6712
|
/**
|
|
6284
6713
|
* Creates a function that adds a configured suffix to the input string if it does not exist on that string.
|
|
6285
6714
|
*
|
|
6715
|
+
* @dbxUtil
|
|
6716
|
+
* @dbxUtilCategory string
|
|
6717
|
+
* @dbxUtilKind factory
|
|
6718
|
+
* @dbxUtilTags string, suffix, add, factory
|
|
6719
|
+
* @dbxUtilRelated add-suffix, add-prefix-function
|
|
6720
|
+
*
|
|
6286
6721
|
* @param suffix The suffix to add.
|
|
6287
6722
|
* @returns A function that adds the suffix to a string.
|
|
6723
|
+
* @__NO_SIDE_EFFECTS__
|
|
6288
6724
|
*/ function addSuffixFunction(suffix) {
|
|
6289
6725
|
return function(input) {
|
|
6290
6726
|
return input.endsWith(suffix) ? input : input + suffix;
|
|
@@ -6293,9 +6729,16 @@ function caseInsensitiveString(input) {
|
|
|
6293
6729
|
/**
|
|
6294
6730
|
* Pads the start of a string to a minimum length.
|
|
6295
6731
|
*
|
|
6732
|
+
* @dbxUtil
|
|
6733
|
+
* @dbxUtilCategory string
|
|
6734
|
+
* @dbxUtilKind factory
|
|
6735
|
+
* @dbxUtilTags string, pad, start, factory, minimum-length
|
|
6736
|
+
* @dbxUtilRelated transform-string-function
|
|
6737
|
+
*
|
|
6296
6738
|
* @param minLength The minimum length of the string.
|
|
6297
6739
|
* @param padCharacter The character to use for padding.
|
|
6298
6740
|
* @returns A function that pads the start of a string.
|
|
6741
|
+
* @__NO_SIDE_EFFECTS__
|
|
6299
6742
|
*/ function padStartFunction(minLength, padCharacter) {
|
|
6300
6743
|
return function(input) {
|
|
6301
6744
|
return input.padStart(minLength, padCharacter);
|
|
@@ -6304,8 +6747,15 @@ function caseInsensitiveString(input) {
|
|
|
6304
6747
|
/**
|
|
6305
6748
|
* Creates a function that slices and concats parts of a string based on the configuration.
|
|
6306
6749
|
*
|
|
6750
|
+
* @dbxUtil
|
|
6751
|
+
* @dbxUtilCategory string
|
|
6752
|
+
* @dbxUtilKind factory
|
|
6753
|
+
* @dbxUtilTags string, slice, take, factory, from-start, from-end
|
|
6754
|
+
* @dbxUtilRelated transform-string-function
|
|
6755
|
+
*
|
|
6307
6756
|
* @param config The configuration for the slice function.
|
|
6308
6757
|
* @returns A SliceStringFunction.
|
|
6758
|
+
* @__NO_SIDE_EFFECTS__
|
|
6309
6759
|
*/ function sliceStringFunction(config) {
|
|
6310
6760
|
var fromStart = config.fromStart, fromEnd = config.fromEnd;
|
|
6311
6761
|
var takeFromStart = Math.abs(fromStart !== null && fromStart !== void 0 ? fromStart : 0);
|
|
@@ -6853,8 +7303,15 @@ function _object_spread$f(target) {
|
|
|
6853
7303
|
* The merged function returns true only if all individual filters pass (AND logic).
|
|
6854
7304
|
* Null/undefined filters are ignored.
|
|
6855
7305
|
*
|
|
7306
|
+
* @dbxUtil
|
|
7307
|
+
* @dbxUtilCategory value
|
|
7308
|
+
* @dbxUtilKind factory
|
|
7309
|
+
* @dbxUtilTags filter, merge, compose, factory, and
|
|
7310
|
+
* @dbxUtilRelated invert-filter, invert-boolean-return-function
|
|
7311
|
+
*
|
|
6856
7312
|
* @param inputFilters - The filter functions to merge
|
|
6857
7313
|
* @returns A single FilterFunction that applies all filters
|
|
7314
|
+
* @__NO_SIDE_EFFECTS__
|
|
6858
7315
|
*/ function mergeFilterFunctions() {
|
|
6859
7316
|
for(var _len = arguments.length, inputFilters = new Array(_len), _key = 0; _key < _len; _key++){
|
|
6860
7317
|
inputFilters[_key] = arguments[_key];
|
|
@@ -6991,6 +7448,14 @@ function _unsupported_iterable_to_array$r(o, minLen) {
|
|
|
6991
7448
|
* const tuples = getDefinedTuples({ a: 1, b: undefined, c: 'hello' });
|
|
6992
7449
|
* // tuples: [['a', 1], ['c', 'hello']]
|
|
6993
7450
|
* ```
|
|
7451
|
+
*
|
|
7452
|
+
* @dbxUtil
|
|
7453
|
+
* @dbxUtilCategory object
|
|
7454
|
+
* @dbxUtilKind factory
|
|
7455
|
+
* @dbxUtilTags object, tuples, filter, factory, key-value
|
|
7456
|
+
* @dbxUtilRelated filter-key-value-tuple-function, for-each-key-value
|
|
7457
|
+
*
|
|
7458
|
+
* @__NO_SIDE_EFFECTS__
|
|
6994
7459
|
*/ function filterKeyValueTuplesFunction(filter) {
|
|
6995
7460
|
var result;
|
|
6996
7461
|
if (filter != null) {
|
|
@@ -7075,6 +7540,14 @@ function _unsupported_iterable_to_array$r(o, minLen) {
|
|
|
7075
7540
|
* isNotNull(['a', 1], 0); // true
|
|
7076
7541
|
* isNotNull(['b', null], 0); // false
|
|
7077
7542
|
* ```
|
|
7543
|
+
*
|
|
7544
|
+
* @dbxUtil
|
|
7545
|
+
* @dbxUtilCategory object
|
|
7546
|
+
* @dbxUtilKind factory
|
|
7547
|
+
* @dbxUtilTags object, tuple, filter, predicate, factory, key-value
|
|
7548
|
+
* @dbxUtilRelated filter-key-value-tuples-function
|
|
7549
|
+
*
|
|
7550
|
+
* @__NO_SIDE_EFFECTS__
|
|
7078
7551
|
*/ function filterKeyValueTupleFunction(inputFilter) {
|
|
7079
7552
|
var filter = filterKeyValueTuplesInputToFilter(inputFilter);
|
|
7080
7553
|
var tmp = filter.valueFilter, type = tmp === void 0 ? exports.KeyValueTypleValueFilter.UNDEFINED : tmp, tmp1 = filter.invertFilter, inverseFilter = tmp1 === void 0 ? false : tmp1, keysFilter = filter.keysFilter;
|
|
@@ -7145,8 +7618,15 @@ function _unsupported_iterable_to_array$r(o, minLen) {
|
|
|
7145
7618
|
/**
|
|
7146
7619
|
* Creates a factory that returns a random element from the given array on each call.
|
|
7147
7620
|
*
|
|
7621
|
+
* @dbxUtil
|
|
7622
|
+
* @dbxUtilCategory getter
|
|
7623
|
+
* @dbxUtilKind factory
|
|
7624
|
+
* @dbxUtilTags getter, factory, random, array, sample
|
|
7625
|
+
* @dbxUtilRelated random-number-factory, random-array-factory
|
|
7626
|
+
*
|
|
7148
7627
|
* @param values - The array of values to randomly select from
|
|
7149
7628
|
* @returns A factory that returns a random element from the array
|
|
7629
|
+
* @__NO_SIDE_EFFECTS__
|
|
7150
7630
|
*/ function randomFromArrayFactory(values) {
|
|
7151
7631
|
var randomIndex = randomNumberFactory({
|
|
7152
7632
|
min: 0,
|
|
@@ -7198,8 +7678,15 @@ function cachedGetter(factory) {
|
|
|
7198
7678
|
/**
|
|
7199
7679
|
* Creates a factory that wraps Getters with a mapping function.
|
|
7200
7680
|
*
|
|
7681
|
+
* @dbxUtil
|
|
7682
|
+
* @dbxUtilCategory getter
|
|
7683
|
+
* @dbxUtilKind factory
|
|
7684
|
+
* @dbxUtilTags getter, map, transform, factory
|
|
7685
|
+
* @dbxUtilRelated map-getter
|
|
7686
|
+
*
|
|
7201
7687
|
* @param mapFn - The mapping function to apply
|
|
7202
7688
|
* @returns A factory that transforms Getters of type I to Getters of type O
|
|
7689
|
+
* @__NO_SIDE_EFFECTS__
|
|
7203
7690
|
*/ function mapGetterFactory(mapFn) {
|
|
7204
7691
|
return function(getter) {
|
|
7205
7692
|
return function() {
|
|
@@ -7297,12 +7784,19 @@ function _unsupported_iterable_to_array$q(o, minLen) {
|
|
|
7297
7784
|
* @param copy - When true (default), the returned function shallow-copies the input before filtering instead of mutating it.
|
|
7298
7785
|
* @returns A function that returns the stripped object, or `undefined` when filtering removed every key.
|
|
7299
7786
|
*
|
|
7787
|
+
* @dbxUtil
|
|
7788
|
+
* @dbxUtilCategory object
|
|
7789
|
+
* @dbxUtilKind factory
|
|
7790
|
+
* @dbxUtilTags object, strip, filter, factory, undefined, empty
|
|
7791
|
+
* @dbxUtilRelated strip-object, filter-from-pojo-function
|
|
7792
|
+
*
|
|
7300
7793
|
* @example
|
|
7301
7794
|
* ```ts
|
|
7302
7795
|
* const stripUndef = stripObjectFunction(KeyValueTypleValueFilter.UNDEFINED);
|
|
7303
7796
|
* stripUndef({ a: 1, b: undefined }); // { a: 1 }
|
|
7304
7797
|
* stripUndef({ a: undefined }); // undefined
|
|
7305
7798
|
* ```
|
|
7799
|
+
* @__NO_SIDE_EFFECTS__
|
|
7306
7800
|
*/ function stripObjectFunction(filter) {
|
|
7307
7801
|
var copy = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
|
|
7308
7802
|
var filterFn = filterFromPOJOFunction({
|
|
@@ -7391,6 +7885,14 @@ function _unsupported_iterable_to_array$q(o, minLen) {
|
|
|
7391
7885
|
* const result = overrideFn({ color: 'blue', size: 5 });
|
|
7392
7886
|
* // result is { color: 'red', size: 10 } (a new copy)
|
|
7393
7887
|
* ```
|
|
7888
|
+
*
|
|
7889
|
+
* @dbxUtil
|
|
7890
|
+
* @dbxUtilCategory object
|
|
7891
|
+
* @dbxUtilKind factory
|
|
7892
|
+
* @dbxUtilTags object, override, factory, merge, template, cached
|
|
7893
|
+
* @dbxUtilRelated override-in-object, merge-objects-function, filter-from-pojo-function
|
|
7894
|
+
*
|
|
7895
|
+
* @__NO_SIDE_EFFECTS__
|
|
7394
7896
|
*/ function overrideInObjectFunctionFactory(param) {
|
|
7395
7897
|
var filter = param.filter, copy = param.copy, _param_dynamic = param.dynamic, dynamic = _param_dynamic === void 0 ? false : _param_dynamic;
|
|
7396
7898
|
var filterToRelevantValuesObject = filter != null ? filterFromPOJOFunction({
|
|
@@ -7460,6 +7962,14 @@ function _unsupported_iterable_to_array$q(o, minLen) {
|
|
|
7460
7962
|
* // With null filter to also exclude null values:
|
|
7461
7963
|
* const mergeNoNulls = mergeObjectsFunction(KeyValueTypleValueFilter.NULL);
|
|
7462
7964
|
* ```
|
|
7965
|
+
*
|
|
7966
|
+
* @dbxUtil
|
|
7967
|
+
* @dbxUtilCategory object
|
|
7968
|
+
* @dbxUtilKind factory
|
|
7969
|
+
* @dbxUtilTags object, merge, factory, filter
|
|
7970
|
+
* @dbxUtilRelated merge-objects, override-in-object-function-factory
|
|
7971
|
+
*
|
|
7972
|
+
* @__NO_SIDE_EFFECTS__
|
|
7463
7973
|
*/ function mergeObjectsFunction(filter) {
|
|
7464
7974
|
var overrideFn = overrideInObjectFunctionFactory({
|
|
7465
7975
|
filter: filter,
|
|
@@ -7624,6 +8134,14 @@ function _unsupported_iterable_to_array$q(o, minLen) {
|
|
|
7624
8134
|
* findDefinedKeys({ a: 1, b: undefined, c: 'hello' });
|
|
7625
8135
|
* // ['a', 'c']
|
|
7626
8136
|
* ```
|
|
8137
|
+
*
|
|
8138
|
+
* @dbxUtil
|
|
8139
|
+
* @dbxUtilCategory object
|
|
8140
|
+
* @dbxUtilKind factory
|
|
8141
|
+
* @dbxUtilTags object, pojo, keys, find, factory, filter
|
|
8142
|
+
* @dbxUtilRelated find-pojo-keys, count-pojo-keys-function, for-each-key-value-on-pojo-function
|
|
8143
|
+
*
|
|
8144
|
+
* @__NO_SIDE_EFFECTS__
|
|
7627
8145
|
*/ function findPOJOKeysFunction(filter) {
|
|
7628
8146
|
var findEachMatchingKeyOnTarget = forEachKeyValueOnPOJOFunction({
|
|
7629
8147
|
filter: filter,
|
|
@@ -7677,6 +8195,14 @@ function _unsupported_iterable_to_array$q(o, minLen) {
|
|
|
7677
8195
|
* countDefined({ a: 1, b: undefined, c: 'test' });
|
|
7678
8196
|
* // 2
|
|
7679
8197
|
* ```
|
|
8198
|
+
*
|
|
8199
|
+
* @dbxUtil
|
|
8200
|
+
* @dbxUtilCategory object
|
|
8201
|
+
* @dbxUtilKind factory
|
|
8202
|
+
* @dbxUtilTags object, pojo, keys, count, factory, filter
|
|
8203
|
+
* @dbxUtilRelated count-pojo-keys, find-pojo-keys-function
|
|
8204
|
+
*
|
|
8205
|
+
* @__NO_SIDE_EFFECTS__
|
|
7680
8206
|
*/ function countPOJOKeysFunction() {
|
|
7681
8207
|
var filter = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : exports.KeyValueTypleValueFilter.UNDEFINED;
|
|
7682
8208
|
var countEachMatchingKeyOnTarget = forEachKeyValueOnPOJOFunction({
|
|
@@ -7743,6 +8269,14 @@ function _unsupported_iterable_to_array$q(o, minLen) {
|
|
|
7743
8269
|
* const result = filterNulls({ a: 1, b: null, c: undefined });
|
|
7744
8270
|
* // result is { a: 1 }, original is unchanged
|
|
7745
8271
|
* ```
|
|
8272
|
+
*
|
|
8273
|
+
* @dbxUtil
|
|
8274
|
+
* @dbxUtilCategory object
|
|
8275
|
+
* @dbxUtilKind factory
|
|
8276
|
+
* @dbxUtilTags object, pojo, filter, factory, remove, copy
|
|
8277
|
+
* @dbxUtilRelated filter-from-pojo, strip-object-function, assign-values-to-pojo-function
|
|
8278
|
+
*
|
|
8279
|
+
* @__NO_SIDE_EFFECTS__
|
|
7746
8280
|
*/ function filterFromPOJOFunction() {
|
|
7747
8281
|
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 ? {
|
|
7748
8282
|
valueFilter: exports.KeyValueTypleValueFilter.UNDEFINED
|
|
@@ -7820,6 +8354,14 @@ function _unsupported_iterable_to_array$q(o, minLen) {
|
|
|
7820
8354
|
* // With NULL filter and no copy:
|
|
7821
8355
|
* const assignNoNulls = assignValuesToPOJOFunction({ valueFilter: KeyValueTypleValueFilter.NULL, copy: false });
|
|
7822
8356
|
* ```
|
|
8357
|
+
*
|
|
8358
|
+
* @dbxUtil
|
|
8359
|
+
* @dbxUtilCategory object
|
|
8360
|
+
* @dbxUtilKind factory
|
|
8361
|
+
* @dbxUtilTags object, pojo, assign, factory, filter, copy
|
|
8362
|
+
* @dbxUtilRelated assign-values-to-pojo, filter-from-pojo-function
|
|
8363
|
+
*
|
|
8364
|
+
* @__NO_SIDE_EFFECTS__
|
|
7823
8365
|
*/ function assignValuesToPOJOFunction() {
|
|
7824
8366
|
var input = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : exports.KeyValueTypleValueFilter.UNDEFINED;
|
|
7825
8367
|
var _ref;
|
|
@@ -7885,6 +8427,14 @@ function _unsupported_iterable_to_array$q(o, minLen) {
|
|
|
7885
8427
|
* getNonNullValues({ a: 1, b: null, c: undefined });
|
|
7886
8428
|
* // [1]
|
|
7887
8429
|
* ```
|
|
8430
|
+
*
|
|
8431
|
+
* @dbxUtil
|
|
8432
|
+
* @dbxUtilCategory object
|
|
8433
|
+
* @dbxUtilKind factory
|
|
8434
|
+
* @dbxUtilTags object, pojo, values, factory, filter, extract
|
|
8435
|
+
* @dbxUtilRelated values-from-pojo, find-pojo-keys-function
|
|
8436
|
+
*
|
|
8437
|
+
* @__NO_SIDE_EFFECTS__
|
|
7888
8438
|
*/ function valuesFromPOJOFunction() {
|
|
7889
8439
|
var filter = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : exports.KeyValueTypleValueFilter.UNDEFINED;
|
|
7890
8440
|
var addValuesFromObjectToContext = forEachKeyValueOnPOJOFunction({
|
|
@@ -7924,6 +8474,14 @@ function _unsupported_iterable_to_array$q(o, minLen) {
|
|
|
7924
8474
|
* omitAB({ a: 1, b: 2, c: 3 });
|
|
7925
8475
|
* // { c: 3 }
|
|
7926
8476
|
* ```
|
|
8477
|
+
*
|
|
8478
|
+
* @dbxUtil
|
|
8479
|
+
* @dbxUtilCategory object
|
|
8480
|
+
* @dbxUtilKind factory
|
|
8481
|
+
* @dbxUtilTags object, pojo, keys, filter, pick, omit, factory
|
|
8482
|
+
* @dbxUtilRelated filter-tuples-on-pojo-function, filter-from-pojo-function
|
|
8483
|
+
*
|
|
8484
|
+
* @__NO_SIDE_EFFECTS__
|
|
7927
8485
|
*/ function filterKeysOnPOJOFunction(keysToFilter) {
|
|
7928
8486
|
var invertFilter = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
7929
8487
|
var keysSet = new Set(keysToFilter);
|
|
@@ -7948,6 +8506,14 @@ function _unsupported_iterable_to_array$q(o, minLen) {
|
|
|
7948
8506
|
* keepStrings({ a: 'hello', b: 42, c: 'world' });
|
|
7949
8507
|
* // { a: 'hello', c: 'world' }
|
|
7950
8508
|
* ```
|
|
8509
|
+
*
|
|
8510
|
+
* @dbxUtil
|
|
8511
|
+
* @dbxUtilCategory object
|
|
8512
|
+
* @dbxUtilKind factory
|
|
8513
|
+
* @dbxUtilTags object, pojo, tuples, filter, predicate, factory
|
|
8514
|
+
* @dbxUtilRelated filter-keys-on-pojo-function, filter-from-pojo-function
|
|
8515
|
+
*
|
|
8516
|
+
* @__NO_SIDE_EFFECTS__
|
|
7951
8517
|
*/ function filterTuplesOnPOJOFunction(filterTupleOnObject) {
|
|
7952
8518
|
return function(input) {
|
|
7953
8519
|
var result = {};
|
|
@@ -7982,6 +8548,14 @@ function _unsupported_iterable_to_array$q(o, minLen) {
|
|
|
7982
8548
|
* logDefined({ a: 1, b: undefined, c: 'test' });
|
|
7983
8549
|
* // logs: 'a' 1, 'c' 'test'
|
|
7984
8550
|
* ```
|
|
8551
|
+
*
|
|
8552
|
+
* @dbxUtil
|
|
8553
|
+
* @dbxUtilCategory object
|
|
8554
|
+
* @dbxUtilKind factory
|
|
8555
|
+
* @dbxUtilTags object, pojo, for-each, iterate, factory, callback
|
|
8556
|
+
* @dbxUtilRelated find-pojo-keys-function, count-pojo-keys-function, filter-key-value-tuples-function
|
|
8557
|
+
*
|
|
8558
|
+
* @__NO_SIDE_EFFECTS__
|
|
7985
8559
|
*/ function forEachKeyValueOnPOJOFunction(param) {
|
|
7986
8560
|
var forEach = param.forEach, filter = param.filter;
|
|
7987
8561
|
var filterKeyValues = filterKeyValueTuplesFunction(filter);
|
|
@@ -8041,8 +8615,15 @@ function isInSetDecisionFunction(set, inputReadValue) {
|
|
|
8041
8615
|
* Creates a {@link SetDeltaFunction} that computes the differences between two iterables,
|
|
8042
8616
|
* identifying which items were added, removed, or unchanged.
|
|
8043
8617
|
*
|
|
8618
|
+
* @dbxUtil
|
|
8619
|
+
* @dbxUtilCategory set
|
|
8620
|
+
* @dbxUtilKind factory
|
|
8621
|
+
* @dbxUtilTags set, delta, diff, factory, change, added, removed
|
|
8622
|
+
* @dbxUtilRelated index-delta-group-function, set-has-value-function
|
|
8623
|
+
*
|
|
8044
8624
|
* @param config - Configuration with the key reader and optional modification detector.
|
|
8045
8625
|
* @returns A function that compares two iterables and returns an array of change pairs.
|
|
8626
|
+
* @__NO_SIDE_EFFECTS__
|
|
8046
8627
|
*/ function setDeltaFunction(config) {
|
|
8047
8628
|
var readKey = config.readKey, _config_isModifiedFunction = config.isModifiedFunction, isModifiedFunction = _config_isModifiedFunction === void 0 ? function() {
|
|
8048
8629
|
return undefined;
|
|
@@ -8189,9 +8770,16 @@ var AUTH_ROLE_CLAIMS_DEFAULT_EMPTY_VALUE = null;
|
|
|
8189
8770
|
* Each key in the config maps a claim key to role(s). Simple entries map a claim value to one or more roles,
|
|
8190
8771
|
* while encode/decode entries allow custom bidirectional conversion logic.
|
|
8191
8772
|
*
|
|
8773
|
+
* @dbxUtil
|
|
8774
|
+
* @dbxUtilCategory auth
|
|
8775
|
+
* @dbxUtilKind factory
|
|
8776
|
+
* @dbxUtilTags auth, role, claims, jwt, factory, bidirectional
|
|
8777
|
+
* @dbxUtilRelated auth-role
|
|
8778
|
+
*
|
|
8192
8779
|
* @param config - Mapping of claim keys to their role configuration entries (or null to ignore)
|
|
8193
8780
|
* @param defaults - Optional default values for claim presence and absence
|
|
8194
8781
|
* @returns A service with `toClaims` and `toRoles` conversion functions
|
|
8782
|
+
* @__NO_SIDE_EFFECTS__
|
|
8195
8783
|
*/ function authRoleClaimsService(config) {
|
|
8196
8784
|
var defaults = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
8197
8785
|
var _ref, _ref1;
|
|
@@ -9899,9 +10487,16 @@ function _unsupported_iterable_to_array$o(o, minLen) {
|
|
|
9899
10487
|
* Creates a function that replaces the last character of a string with the replacement string
|
|
9900
10488
|
* if that character matches any of the specified values.
|
|
9901
10489
|
*
|
|
10490
|
+
* @dbxUtil
|
|
10491
|
+
* @dbxUtilCategory string
|
|
10492
|
+
* @dbxUtilKind factory
|
|
10493
|
+
* @dbxUtilTags string, replace, last, character, conditional, factory
|
|
10494
|
+
* @dbxUtilRelated replace-last-character-if, replace-character-at-index-if
|
|
10495
|
+
*
|
|
9902
10496
|
* @param replacement - string to substitute for the last character
|
|
9903
10497
|
* @param is - character(s) that trigger the replacement
|
|
9904
10498
|
* @returns a function that conditionally replaces the last character
|
|
10499
|
+
* @__NO_SIDE_EFFECTS__
|
|
9905
10500
|
*/ function replaceLastCharacterIfIsFunction(replacement, is) {
|
|
9906
10501
|
var matches = new Set(is);
|
|
9907
10502
|
return function(input) {
|
|
@@ -10071,8 +10666,15 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10071
10666
|
/**
|
|
10072
10667
|
* Creates a function that replaces all occurrences of the configured target strings with a replacement value.
|
|
10073
10668
|
*
|
|
10669
|
+
* @dbxUtil
|
|
10670
|
+
* @dbxUtilCategory string
|
|
10671
|
+
* @dbxUtilKind factory
|
|
10672
|
+
* @dbxUtilTags string, replace, regex, substitute, factory
|
|
10673
|
+
* @dbxUtilRelated find-strings-regex-string, escape-string-for-regex
|
|
10674
|
+
*
|
|
10074
10675
|
* @param config - Configuration specifying strings to find and the replacement value.
|
|
10075
10676
|
* @returns A function that performs the configured replacements on an input string.
|
|
10677
|
+
* @__NO_SIDE_EFFECTS__
|
|
10076
10678
|
*/ function replaceStringsFunction(config) {
|
|
10077
10679
|
var replaceInput = config.replace, replaceWith = config.replaceWith;
|
|
10078
10680
|
var replaceRegexString = findStringsRegexString(replaceInput);
|
|
@@ -10105,6 +10707,11 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10105
10707
|
/**
|
|
10106
10708
|
* Creates an escaped regex string that matches any of the input values, joined with the OR (`|`) operator.
|
|
10107
10709
|
*
|
|
10710
|
+
* @dbxUtil
|
|
10711
|
+
* @dbxUtilCategory string
|
|
10712
|
+
* @dbxUtilTags string, regex, escape, alternation, pattern
|
|
10713
|
+
* @dbxUtilRelated escape-string-for-regex, replace-strings-function
|
|
10714
|
+
*
|
|
10108
10715
|
* @param find - One or more strings to create a matching regex pattern for.
|
|
10109
10716
|
* @returns A regex-compatible string with special characters escaped and values joined by `|`.
|
|
10110
10717
|
*/ function findStringsRegexString(find) {
|
|
@@ -10115,8 +10722,15 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10115
10722
|
/**
|
|
10116
10723
|
* Creates an {@link EscapeStringCharactersFunction} that escapes specific characters in a string using the configured escape strategy.
|
|
10117
10724
|
*
|
|
10725
|
+
* @dbxUtil
|
|
10726
|
+
* @dbxUtilCategory string
|
|
10727
|
+
* @dbxUtilKind factory
|
|
10728
|
+
* @dbxUtilTags string, escape, characters, factory, transform
|
|
10729
|
+
* @dbxUtilRelated escape-string-for-regex, find-all-character-occurences-function
|
|
10730
|
+
*
|
|
10118
10731
|
* @param config - Configuration specifying which characters to escape and how to escape them.
|
|
10119
10732
|
* @returns A function that escapes the configured characters in any input string.
|
|
10733
|
+
* @__NO_SIDE_EFFECTS__
|
|
10120
10734
|
*/ function escapeStringCharactersFunction(config) {
|
|
10121
10735
|
var inputEscapeTargets = config.escapeTargets, escapeCharacter = config.escapeCharacter;
|
|
10122
10736
|
var escapeTargets = _instanceof$3(inputEscapeTargets, Set) ? inputEscapeTargets : new Set(inputEscapeTargets);
|
|
@@ -10164,6 +10778,12 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10164
10778
|
*
|
|
10165
10779
|
* For instance, `'hello.world'` will be escaped to `'hello\\.world'`.
|
|
10166
10780
|
*
|
|
10781
|
+
* @dbxUtil
|
|
10782
|
+
* @dbxUtilCategory string
|
|
10783
|
+
* @dbxUtilKind const
|
|
10784
|
+
* @dbxUtilTags string, regex, escape, sanitize, pattern
|
|
10785
|
+
* @dbxUtilRelated escape-string-characters-function, find-strings-regex-string
|
|
10786
|
+
*
|
|
10167
10787
|
* @param input - The string to escape for regex use.
|
|
10168
10788
|
* @returns The escaped string with all regex special characters prefixed with a backslash.
|
|
10169
10789
|
*/ var escapeStringForRegex = escapeStringCharactersFunction({
|
|
@@ -10175,8 +10795,15 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10175
10795
|
/**
|
|
10176
10796
|
* Creates a {@link FindAllCharacterOccurencesFunction} that searches for characters from the given set.
|
|
10177
10797
|
*
|
|
10798
|
+
* @dbxUtil
|
|
10799
|
+
* @dbxUtilCategory string
|
|
10800
|
+
* @dbxUtilKind factory
|
|
10801
|
+
* @dbxUtilTags string, search, characters, indices, factory, occurrences
|
|
10802
|
+
* @dbxUtilRelated find-all-character-occurences, find-first-character-occurence
|
|
10803
|
+
*
|
|
10178
10804
|
* @param characterSet - The set of characters to search for.
|
|
10179
10805
|
* @returns A function that finds all occurrences of the configured characters in an input string.
|
|
10806
|
+
* @__NO_SIDE_EFFECTS__
|
|
10180
10807
|
*/ function findAllCharacterOccurencesFunction(characterSet) {
|
|
10181
10808
|
return function(input, maxToReturn) {
|
|
10182
10809
|
var max = maxToReturn !== null && maxToReturn !== void 0 ? maxToReturn : Number.MAX_SAFE_INTEGER;
|
|
@@ -10213,6 +10840,11 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10213
10840
|
/**
|
|
10214
10841
|
* Finds all indices of characters from the set that appear in the input string.
|
|
10215
10842
|
*
|
|
10843
|
+
* @dbxUtil
|
|
10844
|
+
* @dbxUtilCategory string
|
|
10845
|
+
* @dbxUtilTags string, search, characters, indices, occurrences
|
|
10846
|
+
* @dbxUtilRelated find-all-character-occurences-function, find-first-character-occurence
|
|
10847
|
+
*
|
|
10216
10848
|
* @param set - The set of characters to search for.
|
|
10217
10849
|
* @param input - The string to search through.
|
|
10218
10850
|
* @param max - Optional maximum number of occurrences to return.
|
|
@@ -10223,6 +10855,11 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10223
10855
|
/**
|
|
10224
10856
|
* Finds the index of the first occurrence of any character from the set in the input string.
|
|
10225
10857
|
*
|
|
10858
|
+
* @dbxUtil
|
|
10859
|
+
* @dbxUtilCategory string
|
|
10860
|
+
* @dbxUtilTags string, search, characters, first, index, occurrence
|
|
10861
|
+
* @dbxUtilRelated find-all-character-occurences, find-all-character-occurences-function
|
|
10862
|
+
*
|
|
10226
10863
|
* @param set - The set of characters to search for.
|
|
10227
10864
|
* @param input - The string to search through.
|
|
10228
10865
|
* @returns The zero-based index of the first matching character, or `undefined` if none found.
|
|
@@ -10232,8 +10869,15 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10232
10869
|
/**
|
|
10233
10870
|
* Creates a function that splits a string into two parts at the first occurrence of any character in the configured set.
|
|
10234
10871
|
*
|
|
10872
|
+
* @dbxUtil
|
|
10873
|
+
* @dbxUtilCategory string
|
|
10874
|
+
* @dbxUtilKind factory
|
|
10875
|
+
* @dbxUtilTags string, split, characters, occurrence, factory
|
|
10876
|
+
* @dbxUtilRelated split-string-at-first-character-occurence, keep-characters-after-first-character-occurence-function
|
|
10877
|
+
*
|
|
10235
10878
|
* @param splitAt - A single character or set of characters to split on.
|
|
10236
10879
|
* @returns A function that splits input strings at the first matching character.
|
|
10880
|
+
* @__NO_SIDE_EFFECTS__
|
|
10237
10881
|
*/ function splitStringAtFirstCharacterOccurenceFunction(splitAt) {
|
|
10238
10882
|
return function(input) {
|
|
10239
10883
|
var splitSet = typeof splitAt === 'string' ? new Set([
|
|
@@ -10255,6 +10899,11 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10255
10899
|
/**
|
|
10256
10900
|
* Splits the input string into two parts at the first occurrence of any character in the split set.
|
|
10257
10901
|
*
|
|
10902
|
+
* @dbxUtil
|
|
10903
|
+
* @dbxUtilCategory string
|
|
10904
|
+
* @dbxUtilTags string, split, characters, occurrence, tuple
|
|
10905
|
+
* @dbxUtilRelated split-string-at-first-character-occurence-function, find-first-character-occurence
|
|
10906
|
+
*
|
|
10258
10907
|
* @param input - The string to split.
|
|
10259
10908
|
* @param splitAt - A single character or set of characters to split on.
|
|
10260
10909
|
* @returns A tuple of [before, after], where `after` is `undefined` if no split character was found.
|
|
@@ -10264,8 +10913,15 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10264
10913
|
/**
|
|
10265
10914
|
* Creates a function that returns only the characters after the first occurrence of any character in the configured set.
|
|
10266
10915
|
*
|
|
10916
|
+
* @dbxUtil
|
|
10917
|
+
* @dbxUtilCategory string
|
|
10918
|
+
* @dbxUtilKind factory
|
|
10919
|
+
* @dbxUtilTags string, keep, after, occurrence, factory, suffix
|
|
10920
|
+
* @dbxUtilRelated keep-characters-after-first-character-occurence, remove-characters-after-first-character-occurence-function
|
|
10921
|
+
*
|
|
10267
10922
|
* @param findCharacters - A single character or set of characters to search for.
|
|
10268
10923
|
* @returns A function that extracts the substring after the first matching character, or an empty string if none found.
|
|
10924
|
+
* @__NO_SIDE_EFFECTS__
|
|
10269
10925
|
*/ function keepCharactersAfterFirstCharacterOccurenceFunction(findCharacters) {
|
|
10270
10926
|
var splitStringAtFirstCharacterOccurence = splitStringAtFirstCharacterOccurenceFunction(findCharacters);
|
|
10271
10927
|
return function(input) {
|
|
@@ -10276,6 +10932,11 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10276
10932
|
/**
|
|
10277
10933
|
* Returns only the characters after the first occurrence of any character from the find set.
|
|
10278
10934
|
*
|
|
10935
|
+
* @dbxUtil
|
|
10936
|
+
* @dbxUtilCategory string
|
|
10937
|
+
* @dbxUtilTags string, keep, after, occurrence, suffix
|
|
10938
|
+
* @dbxUtilRelated keep-characters-after-first-character-occurence-function, remove-characters-after-first-character-occurence
|
|
10939
|
+
*
|
|
10279
10940
|
* @param input - The string to search through.
|
|
10280
10941
|
* @param findCharacters - A single character or set of characters to search for.
|
|
10281
10942
|
* @returns The substring after the first matching character, or an empty string if none found.
|
|
@@ -10285,8 +10946,15 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10285
10946
|
/**
|
|
10286
10947
|
* Creates a function that removes all characters after (and including) the first occurrence of any character in the configured set.
|
|
10287
10948
|
*
|
|
10949
|
+
* @dbxUtil
|
|
10950
|
+
* @dbxUtilCategory string
|
|
10951
|
+
* @dbxUtilKind factory
|
|
10952
|
+
* @dbxUtilTags string, remove, truncate, occurrence, factory, prefix
|
|
10953
|
+
* @dbxUtilRelated remove-characters-after-first-character-occurence, keep-characters-after-first-character-occurence-function
|
|
10954
|
+
*
|
|
10288
10955
|
* @param findCharacters - A single character or set of characters to search for.
|
|
10289
10956
|
* @returns A function that truncates input strings at the first matching character.
|
|
10957
|
+
* @__NO_SIDE_EFFECTS__
|
|
10290
10958
|
*/ function removeCharactersAfterFirstCharacterOccurenceFunction(findCharacters) {
|
|
10291
10959
|
var splitStringAtFirstCharacterOccurence = splitStringAtFirstCharacterOccurenceFunction(findCharacters);
|
|
10292
10960
|
return function(input) {
|
|
@@ -10296,6 +10964,11 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10296
10964
|
/**
|
|
10297
10965
|
* Removes all characters after (and including) the first occurrence of any character from the find set.
|
|
10298
10966
|
*
|
|
10967
|
+
* @dbxUtil
|
|
10968
|
+
* @dbxUtilCategory string
|
|
10969
|
+
* @dbxUtilTags string, remove, truncate, occurrence, prefix
|
|
10970
|
+
* @dbxUtilRelated remove-characters-after-first-character-occurence-function, keep-characters-after-first-character-occurence
|
|
10971
|
+
*
|
|
10299
10972
|
* @param input - The string to truncate.
|
|
10300
10973
|
* @param findCharacters - A single character or set of characters to search for.
|
|
10301
10974
|
* @returns The substring before the first matching character, or the full string if none found.
|
|
@@ -10445,6 +11118,7 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10445
11118
|
* const alwaysTrue = decisionFunction(true);
|
|
10446
11119
|
* alwaysTrue('anything'); // true
|
|
10447
11120
|
* ```
|
|
11121
|
+
* @__NO_SIDE_EFFECTS__
|
|
10448
11122
|
*/ function decisionFunction(decision) {
|
|
10449
11123
|
return function() {
|
|
10450
11124
|
return decision;
|
|
@@ -10487,6 +11161,8 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10487
11161
|
* const fn2 = asDecisionFunction(undefined, false);
|
|
10488
11162
|
* fn2('anything'); // false
|
|
10489
11163
|
* ```
|
|
11164
|
+
*
|
|
11165
|
+
* @__NO_SIDE_EFFECTS__
|
|
10490
11166
|
*/ function asDecisionFunction(valueOrFunction) {
|
|
10491
11167
|
var defaultIfUndefined = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
|
|
10492
11168
|
var input = valueOrFunction !== null && valueOrFunction !== void 0 ? valueOrFunction : defaultIfUndefined;
|
|
@@ -10751,6 +11427,7 @@ function _unsupported_iterable_to_array$m(o, minLen) {
|
|
|
10751
11427
|
*
|
|
10752
11428
|
* @param type - The start type to enforce.
|
|
10753
11429
|
* @returns A function that transforms paths to the specified start type.
|
|
11430
|
+
* @__NO_SIDE_EFFECTS__
|
|
10754
11431
|
*/ function slashPathStartTypeFactory(type) {
|
|
10755
11432
|
var fn;
|
|
10756
11433
|
switch(type){
|
|
@@ -10797,6 +11474,7 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
10797
11474
|
*
|
|
10798
11475
|
* @param config Configuration options for the factory.
|
|
10799
11476
|
* @returns A SlashPathFolderFactory.
|
|
11477
|
+
* @__NO_SIDE_EFFECTS__
|
|
10800
11478
|
*/ function slashPathFolderFactory() {
|
|
10801
11479
|
var config = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
10802
11480
|
var startType = config.startType, validationConfig = config.validationConfig, inputInvalidPathValue = config.invalidPathValue, treatUntypedFilesAsFolders = config.treatUntypedFilesAsFolders;
|
|
@@ -10966,6 +11644,7 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
10966
11644
|
* @param input
|
|
10967
11645
|
* @param replaceWith
|
|
10968
11646
|
* @returns
|
|
11647
|
+
* @__NO_SIDE_EFFECTS__
|
|
10969
11648
|
*/ function replaceInvalidFilePathTypeSeparatorsInSlashPathFunction() {
|
|
10970
11649
|
var replaceWith = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : DEFAULT_SLASH_PATH_ILLEGAL_CHARACTER_REPLACEMENT;
|
|
10971
11650
|
return function(input) {
|
|
@@ -11011,6 +11690,7 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
11011
11690
|
*
|
|
11012
11691
|
* @param config - Configuration for validation behavior.
|
|
11013
11692
|
* @returns A function that validates and fixes a slash path.
|
|
11693
|
+
* @__NO_SIDE_EFFECTS__
|
|
11014
11694
|
*/ function slashPathValidationFactory(config) {
|
|
11015
11695
|
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;
|
|
11016
11696
|
var fns = [];
|
|
@@ -11042,6 +11722,7 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
11042
11722
|
*
|
|
11043
11723
|
* @param config - Configuration for path generation.
|
|
11044
11724
|
* @returns A factory function that merges input paths into a single validated slash path.
|
|
11725
|
+
* @__NO_SIDE_EFFECTS__
|
|
11045
11726
|
*/ function slashPathFactory(config) {
|
|
11046
11727
|
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;
|
|
11047
11728
|
var basePath = inputBasePaths ? mergeSlashPaths(asArray(inputBasePaths)) : undefined;
|
|
@@ -11108,6 +11789,7 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
11108
11789
|
*
|
|
11109
11790
|
* @param config - Configuration with range, optional start type, and file mode.
|
|
11110
11791
|
* @returns A function that isolates path segments within the configured range.
|
|
11792
|
+
* @__NO_SIDE_EFFECTS__
|
|
11111
11793
|
*/ function isolateSlashPathFunction(config) {
|
|
11112
11794
|
var startType = config.startType, asFile = config.asFile;
|
|
11113
11795
|
var range = indexRange(config.range);
|
|
@@ -11210,6 +11892,7 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
11210
11892
|
*
|
|
11211
11893
|
* @param path - Matcher path parts to expand into decision functions.
|
|
11212
11894
|
* @returns Array of decision functions for each path part.
|
|
11895
|
+
* @__NO_SIDE_EFFECTS__
|
|
11213
11896
|
*/ function expandSlashPathPathMatcherPartToDecisionFunctions(path) {
|
|
11214
11897
|
var targetPathPartsInput = asArray(path);
|
|
11215
11898
|
var indexMatchingDecisionFunctions = [];
|
|
@@ -11292,6 +11975,7 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
11292
11975
|
*
|
|
11293
11976
|
* @param input - the matcher configuration, which may be a target path string, an array of path parts, or a full config object
|
|
11294
11977
|
* @returns The matcher.
|
|
11978
|
+
* @__NO_SIDE_EFFECTS__
|
|
11295
11979
|
*/ function slashPathPathMatcher(input) {
|
|
11296
11980
|
var _config_matchRemaining, _config_nonMatchingFillValue;
|
|
11297
11981
|
var config = slashPathPathMatcherConfig(input);
|
|
@@ -11353,6 +12037,7 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
11353
12037
|
*
|
|
11354
12038
|
* @param config The configuration for the matcher.
|
|
11355
12039
|
* @returns The matcher.
|
|
12040
|
+
* @__NO_SIDE_EFFECTS__
|
|
11356
12041
|
*/ function slashPathSubPathMatcher(config) {
|
|
11357
12042
|
var targetPathIndexMatchingDecisionFunctions = expandSlashPathPathMatcherPartToDecisionFunctions(config.basePath);
|
|
11358
12043
|
var basePathPartsCount = targetPathIndexMatchingDecisionFunctions.length;
|
|
@@ -11606,8 +12291,15 @@ function _unsupported_iterable_to_array$l(o, minLen) {
|
|
|
11606
12291
|
/**
|
|
11607
12292
|
* Creates an {@link IsolateWebsitePathFunction} that extracts and transforms a path from a website URL based on the configuration.
|
|
11608
12293
|
*
|
|
12294
|
+
* @dbxUtil
|
|
12295
|
+
* @dbxUtilCategory string
|
|
12296
|
+
* @dbxUtilKind factory
|
|
12297
|
+
* @dbxUtilTags string, url, path, isolate, transform, factory, query
|
|
12298
|
+
* @dbxUtilRelated website-path-from-website-url, website-path-and-query-pair, fix-extra-query-parameters
|
|
12299
|
+
*
|
|
11609
12300
|
* @param config - Configuration for path isolation, including base path removal, component range, query handling, and trailing slash behavior.
|
|
11610
12301
|
* @returns A function that isolates the configured portion of a website path.
|
|
12302
|
+
* @__NO_SIDE_EFFECTS__
|
|
11611
12303
|
*/ function isolateWebsitePathFunction() {
|
|
11612
12304
|
var config = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
11613
12305
|
var removeQueryParameters = config.removeQueryParameters, ignoredBasePath = config.ignoredBasePath, isolatePathComponents = config.isolatePathComponents, removeTrailingSlash = config.removeTrailingSlash;
|
|
@@ -11987,8 +12679,15 @@ function _unsupported_iterable_to_array$k(o, minLen) {
|
|
|
11987
12679
|
/**
|
|
11988
12680
|
* Creates a factory that generates random email addresses using configurable prefixes, domains, and number generators.
|
|
11989
12681
|
*
|
|
12682
|
+
* @dbxUtil
|
|
12683
|
+
* @dbxUtilCategory contact
|
|
12684
|
+
* @dbxUtilKind factory
|
|
12685
|
+
* @dbxUtilTags contact, email, random, factory, generate
|
|
12686
|
+
* @dbxUtilRelated random-phone-number-factory, incrementing-number-factory
|
|
12687
|
+
*
|
|
11990
12688
|
* @param inputConfig - Optional configuration overrides
|
|
11991
12689
|
* @returns A factory function that produces random email address strings
|
|
12690
|
+
* @__NO_SIDE_EFFECTS__
|
|
11992
12691
|
*/ function randomEmailFactory(inputConfig) {
|
|
11993
12692
|
var _config_prefixes, _config_domains;
|
|
11994
12693
|
var config = mergeObjects([
|
|
@@ -12024,8 +12723,15 @@ function _unsupported_iterable_to_array$k(o, minLen) {
|
|
|
12024
12723
|
/**
|
|
12025
12724
|
* Creates a factory that generates random E.164 phone numbers using configurable area codes and number generators.
|
|
12026
12725
|
*
|
|
12726
|
+
* @dbxUtil
|
|
12727
|
+
* @dbxUtilCategory contact
|
|
12728
|
+
* @dbxUtilKind factory
|
|
12729
|
+
* @dbxUtilTags contact, phone, e164, random, factory, generate
|
|
12730
|
+
* @dbxUtilRelated random-email-factory, random-number-factory
|
|
12731
|
+
*
|
|
12027
12732
|
* @param inputConfig - Optional configuration overrides
|
|
12028
12733
|
* @returns A factory function that produces random E.164 phone number strings
|
|
12734
|
+
* @__NO_SIDE_EFFECTS__
|
|
12029
12735
|
*/ function randomPhoneNumberFactory(inputConfig) {
|
|
12030
12736
|
var _config_internationalAreaCodes;
|
|
12031
12737
|
var config = mergeObjects([
|
|
@@ -12312,8 +13018,15 @@ function toReadableError(inputError) {
|
|
|
12312
13018
|
/**
|
|
12313
13019
|
* Creates a function that checks if an error's message contains the target string.
|
|
12314
13020
|
*
|
|
13021
|
+
* @dbxUtil
|
|
13022
|
+
* @dbxUtilCategory error
|
|
13023
|
+
* @dbxUtilKind factory
|
|
13024
|
+
* @dbxUtilTags error, message, contains, factory, predicate, regex
|
|
13025
|
+
* @dbxUtilRelated escape-string-for-regex
|
|
13026
|
+
*
|
|
12315
13027
|
* @param target - The string to search for
|
|
12316
13028
|
* @returns A function that checks error messages for the target string
|
|
13029
|
+
* @__NO_SIDE_EFFECTS__
|
|
12317
13030
|
*/ function errorMessageContainsStringFunction(target) {
|
|
12318
13031
|
var regex = new RegExp(escapeStringForRegex(target));
|
|
12319
13032
|
return function(input) {
|
|
@@ -12427,8 +13140,15 @@ function _unsupported_iterable_to_array$j(o, minLen) {
|
|
|
12427
13140
|
*
|
|
12428
13141
|
* Useful for late-binding or circular dependency resolution.
|
|
12429
13142
|
*
|
|
13143
|
+
* @dbxUtil
|
|
13144
|
+
* @dbxUtilCategory function
|
|
13145
|
+
* @dbxUtilKind factory
|
|
13146
|
+
* @dbxUtilTags function, forward, late-binding, factory, lazy
|
|
13147
|
+
* @dbxUtilRelated default-forward-function-factory
|
|
13148
|
+
*
|
|
12430
13149
|
* @param getter - A Getter that provides the target function
|
|
12431
13150
|
* @returns A forwarding function with the same signature as the target
|
|
13151
|
+
* @__NO_SIDE_EFFECTS__
|
|
12432
13152
|
*/ function forwardFunction(getter) {
|
|
12433
13153
|
return function() {
|
|
12434
13154
|
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
@@ -12442,8 +13162,15 @@ function _unsupported_iterable_to_array$j(o, minLen) {
|
|
|
12442
13162
|
* Creates a factory that produces forwarding functions which use the provided function
|
|
12443
13163
|
* or fall back to the default function when not provided.
|
|
12444
13164
|
*
|
|
13165
|
+
* @dbxUtil
|
|
13166
|
+
* @dbxUtilCategory function
|
|
13167
|
+
* @dbxUtilKind factory
|
|
13168
|
+
* @dbxUtilTags function, forward, factory, default, fallback
|
|
13169
|
+
* @dbxUtilRelated forward-function
|
|
13170
|
+
*
|
|
12445
13171
|
* @param defaultFn - The default function to use as fallback
|
|
12446
13172
|
* @returns A factory that wraps optional functions with a default fallback
|
|
13173
|
+
* @__NO_SIDE_EFFECTS__
|
|
12447
13174
|
*/ function defaultForwardFunctionFactory(defaultFn) {
|
|
12448
13175
|
return function(fn) {
|
|
12449
13176
|
return forwardFunction(function() {
|
|
@@ -12979,9 +13706,16 @@ function _ts_generator$8(thisArg, body) {
|
|
|
12979
13706
|
* The factory generates identifiers in batches, filters them for uniqueness, and verifies each batch
|
|
12980
13707
|
* using the configured verifier. Throws if uniqueness generation fails repeatedly (after 20 attempts).
|
|
12981
13708
|
*
|
|
13709
|
+
* @dbxUtil
|
|
13710
|
+
* @dbxUtilCategory model
|
|
13711
|
+
* @dbxUtilKind factory
|
|
13712
|
+
* @dbxUtilTags model, id, batch, factory, async, unique, identifier
|
|
13713
|
+
* @dbxUtilRelated sequential-incrementing-number-string-model-id-factory
|
|
13714
|
+
*
|
|
12982
13715
|
* @param config - Configuration with the base factory for generating candidates and the verifier for validating them
|
|
12983
13716
|
* @returns An async factory function that produces the requested number of valid identifiers
|
|
12984
13717
|
* @throws Error if the factory cannot produce enough unique values after repeated attempts
|
|
13718
|
+
* @__NO_SIDE_EFFECTS__
|
|
12985
13719
|
*/ function idBatchFactory(config) {
|
|
12986
13720
|
var factory = config.factory, verifier = config.verifier;
|
|
12987
13721
|
var tagsToGeneratePerBatch = verifier.maxBatchSize, _verifier_filterUnique = verifier.filterUnique, filterUnique = _verifier_filterUnique === void 0 ? function(x) {
|
|
@@ -13188,9 +13922,16 @@ function _unsupported_iterable_to_array$g(o, minLen) {
|
|
|
13188
13922
|
* Creates a new {@link PrimativeKeyDencoderFunction} that can bidirectionally encode/decode
|
|
13189
13923
|
* primitive key values based on the configured value pairs.
|
|
13190
13924
|
*
|
|
13925
|
+
* @dbxUtil
|
|
13926
|
+
* @dbxUtilCategory string
|
|
13927
|
+
* @dbxUtilKind factory
|
|
13928
|
+
* @dbxUtilTags string, encode, decode, dencoder, bidirectional, factory, primitive
|
|
13929
|
+
* @dbxUtilRelated primative-key-dencoder-map, primative-key-string-dencoder
|
|
13930
|
+
*
|
|
13191
13931
|
* @param config - configuration with value pairs and optional default fallback
|
|
13192
13932
|
* @returns a function that encodes or decodes single values or arrays
|
|
13193
13933
|
* @throws Error if a single value lookup produces a null result and no default handles it
|
|
13934
|
+
* @__NO_SIDE_EFFECTS__
|
|
13194
13935
|
*/ function primativeKeyDencoder(config) {
|
|
13195
13936
|
var _config_defaultValue = config.defaultValue, defaultValue = _config_defaultValue === void 0 ? PRIMATIVE_KEY_DENCODER_VALUE : _config_defaultValue;
|
|
13196
13937
|
var map = primativeKeyDencoderMap(config.values);
|
|
@@ -13219,9 +13960,16 @@ function _unsupported_iterable_to_array$g(o, minLen) {
|
|
|
13219
13960
|
* When no splitter is defined, all encoded values must be exactly one character long so the string
|
|
13220
13961
|
* can be split character-by-character.
|
|
13221
13962
|
*
|
|
13963
|
+
* @dbxUtil
|
|
13964
|
+
* @dbxUtilCategory string
|
|
13965
|
+
* @dbxUtilKind factory
|
|
13966
|
+
* @dbxUtilTags string, encode, decode, dencoder, splitter, factory, primitive
|
|
13967
|
+
* @dbxUtilRelated primative-key-dencoder, primative-key-dencoder-map
|
|
13968
|
+
*
|
|
13222
13969
|
* @param config - configuration with dencoder and optional splitter
|
|
13223
13970
|
* @returns a bidirectional function for string-to-array and array-to-string conversion
|
|
13224
13971
|
* @throws Error if encoded values contain the splitter character, or if values exceed one character when no splitter is defined
|
|
13972
|
+
* @__NO_SIDE_EFFECTS__
|
|
13225
13973
|
*/ function primativeKeyStringDencoder(config) {
|
|
13226
13974
|
var dencoder = typeof config.dencoder === 'function' ? config.dencoder : primativeKeyDencoder(config.dencoder);
|
|
13227
13975
|
var splitter = config.splitter;
|
|
@@ -13326,8 +14074,15 @@ function _unsupported_iterable_to_array$g(o, minLen) {
|
|
|
13326
14074
|
* Creates a {@link NumberStringDencoderFunction} from the given dencoder.
|
|
13327
14075
|
* The returned function auto-detects the input type: numbers are encoded, strings are decoded.
|
|
13328
14076
|
*
|
|
14077
|
+
* @dbxUtil
|
|
14078
|
+
* @dbxUtilCategory string
|
|
14079
|
+
* @dbxUtilKind factory
|
|
14080
|
+
* @dbxUtilTags string, number, encode, decode, dencoder, bidirectional, factory
|
|
14081
|
+
* @dbxUtilRelated number-string-dencoder, number-string-dencoder-encoded-string-value-function, number-string-dencoder-decoded-number-value-function
|
|
14082
|
+
*
|
|
13329
14083
|
* @param dencoder - the NumberStringDencoder to wrap
|
|
13330
14084
|
* @returns a bidirectional encode/decode function
|
|
14085
|
+
* @__NO_SIDE_EFFECTS__
|
|
13331
14086
|
*/ function numberStringDencoderFunction(dencoder) {
|
|
13332
14087
|
var fn = function fn(input) {
|
|
13333
14088
|
var result = typeof input === 'number' ? dencoder.encodeNumber(input) : dencoder.decodeNumber(input);
|
|
@@ -13339,8 +14094,15 @@ function _unsupported_iterable_to_array$g(o, minLen) {
|
|
|
13339
14094
|
* Creates a function that always returns the encoded string form of the input.
|
|
13340
14095
|
* Numbers are encoded; strings are passed through as-is.
|
|
13341
14096
|
*
|
|
14097
|
+
* @dbxUtil
|
|
14098
|
+
* @dbxUtilCategory string
|
|
14099
|
+
* @dbxUtilKind factory
|
|
14100
|
+
* @dbxUtilTags string, number, encode, normalize, factory
|
|
14101
|
+
* @dbxUtilRelated number-string-dencoder-function, number-string-dencoder-decoded-number-value-function
|
|
14102
|
+
*
|
|
13342
14103
|
* @param dencoder - the NumberStringDencoder to use for encoding
|
|
13343
14104
|
* @returns a function that normalizes input to an encoded string
|
|
14105
|
+
* @__NO_SIDE_EFFECTS__
|
|
13344
14106
|
*/ function numberStringDencoderEncodedStringValueFunction(dencoder) {
|
|
13345
14107
|
return function(input) {
|
|
13346
14108
|
return typeof input === 'number' ? dencoder.encodeNumber(input) : input;
|
|
@@ -13350,8 +14112,15 @@ function _unsupported_iterable_to_array$g(o, minLen) {
|
|
|
13350
14112
|
* Creates a function that always returns the decoded number form of the input.
|
|
13351
14113
|
* Strings are decoded; numbers are passed through as-is.
|
|
13352
14114
|
*
|
|
14115
|
+
* @dbxUtil
|
|
14116
|
+
* @dbxUtilCategory string
|
|
14117
|
+
* @dbxUtilKind factory
|
|
14118
|
+
* @dbxUtilTags string, number, decode, normalize, factory
|
|
14119
|
+
* @dbxUtilRelated number-string-dencoder-function, number-string-dencoder-encoded-string-value-function
|
|
14120
|
+
*
|
|
13353
14121
|
* @param dencoder - the NumberStringDencoder to use for decoding
|
|
13354
14122
|
* @returns a function that normalizes input to a decoded number
|
|
14123
|
+
* @__NO_SIDE_EFFECTS__
|
|
13355
14124
|
*/ function numberStringDencoderDecodedNumberValueFunction(dencoder) {
|
|
13356
14125
|
return function(input) {
|
|
13357
14126
|
return typeof input === 'number' ? input : dencoder.decodeNumber(input);
|
|
@@ -13476,12 +14245,19 @@ function _unsupported_iterable_to_array$g(o, minLen) {
|
|
|
13476
14245
|
* @param minSize - the minimum dimensions to enforce
|
|
13477
14246
|
* @returns a resize function that clamps each axis to the specified minimum
|
|
13478
14247
|
*
|
|
14248
|
+
* @dbxUtil
|
|
14249
|
+
* @dbxUtilCategory value
|
|
14250
|
+
* @dbxUtilKind factory
|
|
14251
|
+
* @dbxUtilTags value, vector, resize, minimum, factory, clamp
|
|
14252
|
+
* @dbxUtilRelated vector
|
|
14253
|
+
*
|
|
13479
14254
|
* @example
|
|
13480
14255
|
* ```ts
|
|
13481
14256
|
* const resize = vectorMinimumSizeResizeFunction({ x: 5 });
|
|
13482
14257
|
* resize({ x: 3, y: 10 });
|
|
13483
14258
|
* // { x: 5, y: 10 }
|
|
13484
14259
|
* ```
|
|
14260
|
+
* @__NO_SIDE_EFFECTS__
|
|
13485
14261
|
*/ function vectorMinimumSizeResizeFunction(minSize) {
|
|
13486
14262
|
return function(input) {
|
|
13487
14263
|
return {
|
|
@@ -13953,8 +14729,15 @@ function _wrap_reg_exp(re, groups, source) {
|
|
|
13953
14729
|
* Creates a {@link LatLngTupleFunction} that converts various input formats into `[lat, lng]` tuples,
|
|
13954
14730
|
* applying optional precision configuration.
|
|
13955
14731
|
*
|
|
14732
|
+
* @dbxUtil
|
|
14733
|
+
* @dbxUtilCategory value
|
|
14734
|
+
* @dbxUtilKind factory
|
|
14735
|
+
* @dbxUtilTags value, lat-lng, tuple, factory, geographic, normalize
|
|
14736
|
+
* @dbxUtilRelated lat-lng-point-function, lat-lng-string-function
|
|
14737
|
+
*
|
|
13956
14738
|
* @param config - optional configuration for precision and wrapping behavior
|
|
13957
14739
|
* @returns a function that produces lat/lng tuples from flexible inputs
|
|
14740
|
+
* @__NO_SIDE_EFFECTS__
|
|
13958
14741
|
*/ function latLngTupleFunction(config) {
|
|
13959
14742
|
var fn = latLngPointFunction(config);
|
|
13960
14743
|
return function(lat, lng) {
|
|
@@ -14037,9 +14820,16 @@ function latLngString(lat, lng) {
|
|
|
14037
14820
|
* Creates a {@link LatLngPointPrecisionFunction} that rounds both lat and lng values
|
|
14038
14821
|
* to the specified number of decimal places.
|
|
14039
14822
|
*
|
|
14823
|
+
* @dbxUtil
|
|
14824
|
+
* @dbxUtilCategory value
|
|
14825
|
+
* @dbxUtilKind factory
|
|
14826
|
+
* @dbxUtilTags value, lat-lng, precision, round, factory, geographic
|
|
14827
|
+
* @dbxUtilRelated lat-lng-point-function, cut-value-to-precision-function
|
|
14828
|
+
*
|
|
14040
14829
|
* @param precision - number of decimal places to retain
|
|
14041
14830
|
* @param precisionRounding - optional rounding strategy (e.g., floor, ceil, round)
|
|
14042
14831
|
* @returns a function that rounds points to the given precision
|
|
14832
|
+
* @__NO_SIDE_EFFECTS__
|
|
14043
14833
|
*/ function latLngPointPrecisionFunction(precision, precisionRounding) {
|
|
14044
14834
|
var precisionFunction = cutValueToPrecisionFunction(precision, precisionRounding);
|
|
14045
14835
|
return function(latLng) {
|
|
@@ -14056,8 +14846,15 @@ function latLngString(lat, lng) {
|
|
|
14056
14846
|
* Creates a {@link LatLngStringFunction} that converts various input formats into comma-separated lat/lng strings,
|
|
14057
14847
|
* applying optional precision configuration.
|
|
14058
14848
|
*
|
|
14849
|
+
* @dbxUtil
|
|
14850
|
+
* @dbxUtilCategory value
|
|
14851
|
+
* @dbxUtilKind factory
|
|
14852
|
+
* @dbxUtilTags value, lat-lng, string, factory, geographic, normalize
|
|
14853
|
+
* @dbxUtilRelated lat-lng-point-function, lat-lng-tuple-function
|
|
14854
|
+
*
|
|
14059
14855
|
* @param config - optional configuration for precision and wrapping behavior
|
|
14060
14856
|
* @returns a function that produces lat/lng strings from flexible inputs
|
|
14857
|
+
* @__NO_SIDE_EFFECTS__
|
|
14061
14858
|
*/ function latLngStringFunction(config) {
|
|
14062
14859
|
var fn = latLngPointFunction(config);
|
|
14063
14860
|
return function(lat, lng) {
|
|
@@ -14088,12 +14885,19 @@ function latLngString(lat, lng) {
|
|
|
14088
14885
|
* @returns a function that produces points from flexible inputs
|
|
14089
14886
|
* @throws {Error} when the input cannot be parsed into a valid point
|
|
14090
14887
|
*
|
|
14888
|
+
* @dbxUtil
|
|
14889
|
+
* @dbxUtilCategory value
|
|
14890
|
+
* @dbxUtilKind factory
|
|
14891
|
+
* @dbxUtilTags value, lat-lng, point, factory, geographic, normalize
|
|
14892
|
+
* @dbxUtilRelated lat-lng-point, lat-lng-tuple-function, lat-lng-string-function, lat-lng-point-precision-function
|
|
14893
|
+
*
|
|
14091
14894
|
* @example
|
|
14092
14895
|
* ```ts
|
|
14093
14896
|
* const fn = latLngPointFunction({ precision: 3 });
|
|
14094
14897
|
* const result = fn(30.59929, -96.38315);
|
|
14095
14898
|
* // result.lat === 30.599, result.lng === -96.383
|
|
14096
14899
|
* ```
|
|
14900
|
+
* @__NO_SIDE_EFFECTS__
|
|
14097
14901
|
*/ function latLngPointFunction(config) {
|
|
14098
14902
|
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;
|
|
14099
14903
|
var precisionFunction = precision != null ? latLngPointPrecisionFunction(precision, precisionRounding) : mapIdentityFunction();
|
|
@@ -14164,8 +14968,15 @@ function latLngString(lat, lng) {
|
|
|
14164
14968
|
/**
|
|
14165
14969
|
* Creates a {@link ValidLatLngPointFunction} that returns the input point when valid, or a default point otherwise.
|
|
14166
14970
|
*
|
|
14971
|
+
* @dbxUtil
|
|
14972
|
+
* @dbxUtilCategory value
|
|
14973
|
+
* @dbxUtilKind factory
|
|
14974
|
+
* @dbxUtilTags value, lat-lng, validate, fallback, factory, geographic
|
|
14975
|
+
* @dbxUtilRelated valid-lat-lng-point, is-valid-lat-lng-point
|
|
14976
|
+
*
|
|
14167
14977
|
* @param defaultValue - factory for the fallback point; defaults to `defaultLatLngPoint`
|
|
14168
14978
|
* @returns a validation function
|
|
14979
|
+
* @__NO_SIDE_EFFECTS__
|
|
14169
14980
|
*/ function validLatLngPointFunction() {
|
|
14170
14981
|
var defaultValue = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : defaultLatLngPoint;
|
|
14171
14982
|
return function(latLngPoint) {
|
|
@@ -14175,8 +14986,15 @@ function latLngString(lat, lng) {
|
|
|
14175
14986
|
/**
|
|
14176
14987
|
* Creates a {@link LatLngDataPointFunction} that wraps a {@link LatLngRef} object with its resolved point coordinates.
|
|
14177
14988
|
*
|
|
14989
|
+
* @dbxUtil
|
|
14990
|
+
* @dbxUtilCategory value
|
|
14991
|
+
* @dbxUtilKind factory
|
|
14992
|
+
* @dbxUtilTags value, lat-lng, data-point, factory, geographic, ref
|
|
14993
|
+
* @dbxUtilRelated lat-lng-point-function
|
|
14994
|
+
*
|
|
14178
14995
|
* @param config - optional configuration for precision and wrapping behavior
|
|
14179
14996
|
* @returns a function that produces data points from lat/lng references
|
|
14997
|
+
* @__NO_SIDE_EFFECTS__
|
|
14180
14998
|
*/ function latLngDataPointFunction(config) {
|
|
14181
14999
|
var fn = latLngPointFunction(config);
|
|
14182
15000
|
return function(data) {
|
|
@@ -14191,8 +15009,15 @@ function latLngString(lat, lng) {
|
|
|
14191
15009
|
* Creates a {@link RandomLatLngFactory} that generates random points within the specified bounding box.
|
|
14192
15010
|
* The bounding box corners are capped/wrapped to valid coordinate ranges.
|
|
14193
15011
|
*
|
|
15012
|
+
* @dbxUtil
|
|
15013
|
+
* @dbxUtilCategory value
|
|
15014
|
+
* @dbxUtilKind factory
|
|
15015
|
+
* @dbxUtilTags value, lat-lng, random, factory, geographic, bounding-box
|
|
15016
|
+
* @dbxUtilRelated random-lat-lng-from-center-factory, random-number-factory
|
|
15017
|
+
*
|
|
14194
15018
|
* @param config - optional bounding box and precision configuration
|
|
14195
15019
|
* @returns a factory that produces random points within the bounds
|
|
15020
|
+
* @__NO_SIDE_EFFECTS__
|
|
14196
15021
|
*/ function randomLatLngFactory(config) {
|
|
14197
15022
|
var _$_object_spread_props = _object_spread_props$4(_object_spread$8({}, config), {
|
|
14198
15023
|
sw: _object_spread$8({
|
|
@@ -14224,8 +15049,15 @@ function latLngString(lat, lng) {
|
|
|
14224
15049
|
* Creates a {@link RandomLatLngFactory} that generates random points within a rectangle
|
|
14225
15050
|
* centered on the given point, extending by `latDistance` and `lngDistance` in each direction.
|
|
14226
15051
|
*
|
|
15052
|
+
* @dbxUtil
|
|
15053
|
+
* @dbxUtilCategory value
|
|
15054
|
+
* @dbxUtilKind factory
|
|
15055
|
+
* @dbxUtilTags value, lat-lng, random, factory, geographic, center
|
|
15056
|
+
* @dbxUtilRelated random-lat-lng-factory, random-number-factory
|
|
15057
|
+
*
|
|
14227
15058
|
* @param config - center point, distances, and optional precision
|
|
14228
15059
|
* @returns a factory that produces random points near the center
|
|
15060
|
+
* @__NO_SIDE_EFFECTS__
|
|
14229
15061
|
*/ function randomLatLngFromCenterFactory(config) {
|
|
14230
15062
|
var center = config.center, latDistance = config.latDistance, lngDistance = config.lngDistance, precision = config.precision;
|
|
14231
15063
|
var sw = {
|
|
@@ -14477,8 +15309,15 @@ function _unsupported_iterable_to_array$e(o, minLen) {
|
|
|
14477
15309
|
* Creates a {@link LatLngBoundTupleFunction} that converts various bound inputs into a `[sw, ne]` tuple,
|
|
14478
15310
|
* applying optional precision to the resulting points.
|
|
14479
15311
|
*
|
|
15312
|
+
* @dbxUtil
|
|
15313
|
+
* @dbxUtilCategory value
|
|
15314
|
+
* @dbxUtilKind factory
|
|
15315
|
+
* @dbxUtilTags value, lat-lng, bound, tuple, factory, geographic
|
|
15316
|
+
* @dbxUtilRelated lat-lng-bound-function, lat-lng-bound
|
|
15317
|
+
*
|
|
14480
15318
|
* @param config - optional configuration for point precision
|
|
14481
15319
|
* @returns a function that produces bound tuples from flexible inputs
|
|
15320
|
+
* @__NO_SIDE_EFFECTS__
|
|
14482
15321
|
*/ function latLngBoundTupleFunction(config) {
|
|
14483
15322
|
var fn = latLngBoundFunction(config);
|
|
14484
15323
|
return function(input, inputNe) {
|
|
@@ -14515,12 +15354,19 @@ function _unsupported_iterable_to_array$e(o, minLen) {
|
|
|
14515
15354
|
* @returns a function that produces bounds from flexible inputs
|
|
14516
15355
|
* @throws {Error} when the input cannot be parsed into a valid bound
|
|
14517
15356
|
*
|
|
15357
|
+
* @dbxUtil
|
|
15358
|
+
* @dbxUtilCategory value
|
|
15359
|
+
* @dbxUtilKind factory
|
|
15360
|
+
* @dbxUtilTags value, lat-lng, bound, factory, geographic, normalize
|
|
15361
|
+
* @dbxUtilRelated lat-lng-bound, lat-lng-bound-tuple-function, lat-lng-point-function
|
|
15362
|
+
*
|
|
14518
15363
|
* @example
|
|
14519
15364
|
* ```ts
|
|
14520
15365
|
* const fn = latLngBoundFunction({ precision: 3 });
|
|
14521
15366
|
* const result = fn([{ lat: 20, lng: 20 }, { lat: 30, lng: 30 }]);
|
|
14522
15367
|
* // result.sw.lat === 20, result.ne.lat === 30
|
|
14523
15368
|
* ```
|
|
15369
|
+
* @__NO_SIDE_EFFECTS__
|
|
14524
15370
|
*/ function latLngBoundFunction(config) {
|
|
14525
15371
|
var _ref = config !== null && config !== void 0 ? config : {}, pointFunction = _ref.pointFunction, precision = _ref.precision;
|
|
14526
15372
|
var latLngPoint = pointFunction !== null && pointFunction !== void 0 ? pointFunction : latLngPointFunction({
|
|
@@ -14642,8 +15488,15 @@ function _unsupported_iterable_to_array$e(o, minLen) {
|
|
|
14642
15488
|
* falls entirely within the specified bound. Points are checked directly; bounds require
|
|
14643
15489
|
* both corners to be within.
|
|
14644
15490
|
*
|
|
15491
|
+
* @dbxUtil
|
|
15492
|
+
* @dbxUtilCategory value
|
|
15493
|
+
* @dbxUtilKind factory
|
|
15494
|
+
* @dbxUtilTags value, lat-lng, bound, contains, decision, factory, geographic
|
|
15495
|
+
* @dbxUtilRelated overlaps-lat-lng-bound-function, is-lat-lng-point-within-lat-lng-bound
|
|
15496
|
+
*
|
|
14645
15497
|
* @param bound - the reference bound to check containment against
|
|
14646
15498
|
* @returns a function that returns `true` if the input is within the reference bound
|
|
15499
|
+
* @__NO_SIDE_EFFECTS__
|
|
14647
15500
|
*/ function isWithinLatLngBoundFunction(bound) {
|
|
14648
15501
|
var fn = function fn(boundOrPoint) {
|
|
14649
15502
|
return isLatLngPoint(boundOrPoint) ? isLatLngPointWithinLatLngBound(boundOrPoint, bound) : isLatLngBoundWithinLatLngBound(boundOrPoint, bound);
|
|
@@ -14701,8 +15554,15 @@ function _unsupported_iterable_to_array$e(o, minLen) {
|
|
|
14701
15554
|
* overlaps the reference bound. Internally converts bounds to rectangles for overlap detection,
|
|
14702
15555
|
* handling antimeridian wrapping.
|
|
14703
15556
|
*
|
|
15557
|
+
* @dbxUtil
|
|
15558
|
+
* @dbxUtilCategory value
|
|
15559
|
+
* @dbxUtilKind factory
|
|
15560
|
+
* @dbxUtilTags value, lat-lng, bound, overlap, decision, factory, geographic
|
|
15561
|
+
* @dbxUtilRelated is-within-lat-lng-bound-function, lat-lng-bound-overlaps-lat-lng-bound
|
|
15562
|
+
*
|
|
14704
15563
|
* @param bound - the reference bound to check overlap against
|
|
14705
15564
|
* @returns a function that returns `true` if the input overlaps the reference bound
|
|
15565
|
+
* @__NO_SIDE_EFFECTS__
|
|
14706
15566
|
*/ function overlapsLatLngBoundFunction(bound) {
|
|
14707
15567
|
var a = boundToRectangle(bound);
|
|
14708
15568
|
var fn = function fn(boundOrPoint) {
|
|
@@ -14774,6 +15634,7 @@ function _unsupported_iterable_to_array$e(o, minLen) {
|
|
|
14774
15634
|
* safeCompare(null, null); // true
|
|
14775
15635
|
* safeCompare(null, undefined); // false
|
|
14776
15636
|
* ```
|
|
15637
|
+
* @__NO_SIDE_EFFECTS__
|
|
14777
15638
|
*/ function safeEqualityComparatorFunction(compare) {
|
|
14778
15639
|
return function(a, b) {
|
|
14779
15640
|
return a != null && b != null ? compare(a, b) : a === b;
|
|
@@ -14812,9 +15673,16 @@ function _unsupported_iterable_to_array$e(o, minLen) {
|
|
|
14812
15673
|
* This is a convenience wrapper around {@link compareEqualityWithValueFromItemsFunctionFactory} that
|
|
14813
15674
|
* accepts both the value reader and comparator in a single call.
|
|
14814
15675
|
*
|
|
15676
|
+
* @dbxUtil
|
|
15677
|
+
* @dbxUtilCategory value
|
|
15678
|
+
* @dbxUtilKind factory
|
|
15679
|
+
* @dbxUtilTags value, comparator, equality, factory, read
|
|
15680
|
+
* @dbxUtilRelated compare-equality-with-value-from-items-function-factory, safe-equality-comparator-function
|
|
15681
|
+
*
|
|
14815
15682
|
* @param readValues - extracts the comparable value from each item
|
|
14816
15683
|
* @param equalityComparator - compares the extracted values for equality
|
|
14817
15684
|
* @returns a function that compares two items by their extracted values
|
|
15685
|
+
* @__NO_SIDE_EFFECTS__
|
|
14818
15686
|
*/ function compareEqualityWithValueFromItemsFunction(readValues, equalityComparator) {
|
|
14819
15687
|
return compareEqualityWithValueFromItemsFunctionFactory(readValues)(equalityComparator);
|
|
14820
15688
|
}
|
|
@@ -14837,6 +15705,14 @@ function _unsupported_iterable_to_array$e(o, minLen) {
|
|
|
14837
15705
|
* fn(undefined, undefined); // true
|
|
14838
15706
|
* fn(0, 1); // false
|
|
14839
15707
|
* ```
|
|
15708
|
+
*
|
|
15709
|
+
* @dbxUtil
|
|
15710
|
+
* @dbxUtilCategory value
|
|
15711
|
+
* @dbxUtilKind factory
|
|
15712
|
+
* @dbxUtilTags value, comparator, equality, factory, read, reuse
|
|
15713
|
+
* @dbxUtilRelated compare-equality-with-value-from-items-function, safe-equality-comparator-function
|
|
15714
|
+
*
|
|
15715
|
+
* @__NO_SIDE_EFFECTS__
|
|
14840
15716
|
*/ function compareEqualityWithValueFromItemsFunctionFactory(readValues) {
|
|
14841
15717
|
var fn = function fn(equalityComparator) {
|
|
14842
15718
|
var fn = safeEqualityComparatorFunction(function(a, b) {
|
|
@@ -15136,8 +16012,14 @@ function dateFromDateOrTimeMillisecondsNumber(input) {
|
|
|
15136
16012
|
/**
|
|
15137
16013
|
* Converts a MonthOfYear (1-12) to a JavaScript Date month (0-11).
|
|
15138
16014
|
*
|
|
16015
|
+
* @dbxUtil
|
|
16016
|
+
* @dbxUtilCategory date
|
|
16017
|
+
* @dbxUtilTags date, month, convert, javascript
|
|
16018
|
+
* @dbxUtilRelated month-of-year-from-date-month
|
|
16019
|
+
*
|
|
15139
16020
|
* @param monthOfYear - Month of year (1-12)
|
|
15140
16021
|
* @returns JavaScript Date month (0-11)
|
|
16022
|
+
* @__NO_SIDE_EFFECTS__
|
|
15141
16023
|
*/ function makeDateMonthForMonthOfYear(monthOfYear) {
|
|
15142
16024
|
return monthOfYear - 1;
|
|
15143
16025
|
}
|
|
@@ -15366,6 +16248,7 @@ var MINUTE_OF_DAY_MAXMIMUM = MINUTES_IN_DAY - 1;
|
|
|
15366
16248
|
* context(0); // true
|
|
15367
16249
|
* context(10); // false
|
|
15368
16250
|
* ```
|
|
16251
|
+
* @__NO_SIDE_EFFECTS__
|
|
15369
16252
|
*/ function isEqualContext(contextValue, fn) {
|
|
15370
16253
|
return function(value) {
|
|
15371
16254
|
return fn(contextValue, value);
|
|
@@ -15395,6 +16278,7 @@ var MINUTE_OF_DAY_MAXMIMUM = MINUTES_IN_DAY - 1;
|
|
|
15395
16278
|
* context([0, 0, 0]); // true
|
|
15396
16279
|
* context([0, 1, 2]); // false
|
|
15397
16280
|
* ```
|
|
16281
|
+
* @__NO_SIDE_EFFECTS__
|
|
15398
16282
|
*/ function areEqualContext(contextValue, fn) {
|
|
15399
16283
|
var isEqual = isEqualContext(contextValue, fn);
|
|
15400
16284
|
return function(input) {
|
|
@@ -15563,6 +16447,13 @@ var MINUTE_OF_DAY_MAXMIMUM = MINUTES_IN_DAY - 1;
|
|
|
15563
16447
|
* fn(obj);
|
|
15564
16448
|
* // obj.x === 1
|
|
15565
16449
|
* ```
|
|
16450
|
+
*
|
|
16451
|
+
* @dbxUtil
|
|
16452
|
+
* @dbxUtilCategory value
|
|
16453
|
+
* @dbxUtilTags modifier, map, factory, compose
|
|
16454
|
+
* @dbxUtilRelated maybe-modifier-map-to-function, modifier
|
|
16455
|
+
*
|
|
16456
|
+
* @__NO_SIDE_EFFECTS__
|
|
15566
16457
|
*/ function modifierMapToFunction(map) {
|
|
15567
16458
|
var _maybeModifierMapToFunction;
|
|
15568
16459
|
return (_maybeModifierMapToFunction = maybeModifierMapToFunction(map)) !== null && _maybeModifierMapToFunction !== void 0 ? _maybeModifierMapToFunction : NOOP_MODIFIER;
|
|
@@ -15572,8 +16463,14 @@ var MINUTE_OF_DAY_MAXMIMUM = MINUTES_IN_DAY - 1;
|
|
|
15572
16463
|
*
|
|
15573
16464
|
* Returns undefined if no map is provided, allowing callers to distinguish "no modifiers" from "empty modifiers".
|
|
15574
16465
|
*
|
|
16466
|
+
* @dbxUtil
|
|
16467
|
+
* @dbxUtilCategory value
|
|
16468
|
+
* @dbxUtilTags modifier, map, factory, compose, optional
|
|
16469
|
+
* @dbxUtilRelated modifier-map-to-function, modifier
|
|
16470
|
+
*
|
|
15575
16471
|
* @param map - the modifier map to convert
|
|
15576
16472
|
* @returns a composed modifier function, or `undefined` if no map is provided
|
|
16473
|
+
* @__NO_SIDE_EFFECTS__
|
|
15577
16474
|
*/ function maybeModifierMapToFunction(map) {
|
|
15578
16475
|
var fn;
|
|
15579
16476
|
if (map != null) {
|
|
@@ -15845,6 +16742,14 @@ function _ts_generator$7(thisArg, body) {
|
|
|
15845
16742
|
* const fallback = mappedUseFn(undefined, () => 'wrong', 'default');
|
|
15846
16743
|
* // fallback === 'default'
|
|
15847
16744
|
* ```
|
|
16745
|
+
*
|
|
16746
|
+
* @dbxUtil
|
|
16747
|
+
* @dbxUtilCategory value
|
|
16748
|
+
* @dbxUtilKind factory
|
|
16749
|
+
* @dbxUtilTags value, use, map, factory, optional, fallback
|
|
16750
|
+
* @dbxUtilRelated wrap-use-function, use-context-function
|
|
16751
|
+
*
|
|
16752
|
+
* @__NO_SIDE_EFFECTS__
|
|
15848
16753
|
*/ function mappedUseFunction(map) {
|
|
15849
16754
|
return wrapUseFunction(useValue, map);
|
|
15850
16755
|
}
|
|
@@ -15852,9 +16757,16 @@ function _ts_generator$7(thisArg, body) {
|
|
|
15852
16757
|
* Wraps an existing {@link MappedUseFunction} with an additional mapping step, allowing further transformation
|
|
15853
16758
|
* of the intermediate value before it reaches the consumer.
|
|
15854
16759
|
*
|
|
16760
|
+
* @dbxUtil
|
|
16761
|
+
* @dbxUtilCategory value
|
|
16762
|
+
* @dbxUtilKind factory
|
|
16763
|
+
* @dbxUtilTags value, use, map, wrap, compose, factory
|
|
16764
|
+
* @dbxUtilRelated mapped-use-function, use-value
|
|
16765
|
+
*
|
|
15855
16766
|
* @param mappedUseFn - the existing mapped use function to wrap
|
|
15856
16767
|
* @param map - additional transformation applied to the intermediate value
|
|
15857
16768
|
* @returns a new MappedUseFunction with the extra mapping layer
|
|
16769
|
+
* @__NO_SIDE_EFFECTS__
|
|
15858
16770
|
*/ function wrapUseFunction(mappedUseFn, map) {
|
|
15859
16771
|
return function(input, useFn, defaultValue) {
|
|
15860
16772
|
return mappedUseFn(input, function(value) {
|
|
@@ -15866,9 +16778,16 @@ function _ts_generator$7(thisArg, body) {
|
|
|
15866
16778
|
* Creates a {@link UseContextFunction} by binding a consumer and optional default value, so callers
|
|
15867
16779
|
* only need to supply the input.
|
|
15868
16780
|
*
|
|
16781
|
+
* @dbxUtil
|
|
16782
|
+
* @dbxUtilCategory value
|
|
16783
|
+
* @dbxUtilKind factory
|
|
16784
|
+
* @dbxUtilTags value, use, context, factory, bind, default
|
|
16785
|
+
* @dbxUtilRelated use-value, mapped-use-function
|
|
16786
|
+
*
|
|
15869
16787
|
* @param use - the consumer function to bind
|
|
15870
16788
|
* @param defaultValue - fallback when input is null/undefined
|
|
15871
16789
|
* @returns a single-argument function that applies the bound consumer
|
|
16790
|
+
* @__NO_SIDE_EFFECTS__
|
|
15872
16791
|
*/ function useContextFunction(use, defaultValue) {
|
|
15873
16792
|
return function(input) {
|
|
15874
16793
|
var result;
|
|
@@ -15940,6 +16859,14 @@ function _ts_generator$7(thisArg, body) {
|
|
|
15940
16859
|
* const result = await mappedUseAsyncFn(1, () => Promise.resolve('hello'));
|
|
15941
16860
|
* // result === 'hello'
|
|
15942
16861
|
* ```
|
|
16862
|
+
*
|
|
16863
|
+
* @dbxUtil
|
|
16864
|
+
* @dbxUtilCategory value
|
|
16865
|
+
* @dbxUtilKind factory
|
|
16866
|
+
* @dbxUtilTags value, use, async, map, factory, promise
|
|
16867
|
+
* @dbxUtilRelated wrap-use-async-function, mapped-use-function
|
|
16868
|
+
*
|
|
16869
|
+
* @__NO_SIDE_EFFECTS__
|
|
15943
16870
|
*/ function mappedUseAsyncFunction(map) {
|
|
15944
16871
|
return wrapUseAsyncFunction(useAsync, map);
|
|
15945
16872
|
}
|
|
@@ -15947,9 +16874,16 @@ function _ts_generator$7(thisArg, body) {
|
|
|
15947
16874
|
* Wraps an existing {@link MappedUseAsyncFunction} with an additional async-capable mapping step,
|
|
15948
16875
|
* allowing further transformation of the intermediate value before it reaches the consumer.
|
|
15949
16876
|
*
|
|
16877
|
+
* @dbxUtil
|
|
16878
|
+
* @dbxUtilCategory value
|
|
16879
|
+
* @dbxUtilKind factory
|
|
16880
|
+
* @dbxUtilTags value, use, async, map, wrap, compose, factory, promise
|
|
16881
|
+
* @dbxUtilRelated mapped-use-async-function, wrap-use-function
|
|
16882
|
+
*
|
|
15950
16883
|
* @param mappedUsePromiseFn - the existing async mapped use function to wrap
|
|
15951
16884
|
* @param map - additional transformation (sync or async) applied to the intermediate value
|
|
15952
16885
|
* @returns a new MappedUseAsyncFunction with the extra mapping layer
|
|
16886
|
+
* @__NO_SIDE_EFFECTS__
|
|
15953
16887
|
*/ function wrapUseAsyncFunction(mappedUsePromiseFn, map) {
|
|
15954
16888
|
return function(input, useFn, defaultValue) {
|
|
15955
16889
|
return mappedUsePromiseFn(input, function(value) {
|
|
@@ -15988,12 +16922,19 @@ function _ts_generator$7(thisArg, body) {
|
|
|
15988
16922
|
* @returns A factory function that returns the next encoded string identifier on each call
|
|
15989
16923
|
* @throws Error if `increaseBy` is 0
|
|
15990
16924
|
*
|
|
16925
|
+
* @dbxUtil
|
|
16926
|
+
* @dbxUtilCategory model
|
|
16927
|
+
* @dbxUtilKind factory
|
|
16928
|
+
* @dbxUtilTags model, id, factory, sequential, incrementing, dencoder
|
|
16929
|
+
* @dbxUtilRelated id-batch-factory, number-string-dencoder-function
|
|
16930
|
+
*
|
|
15991
16931
|
* @example
|
|
15992
16932
|
* ```ts
|
|
15993
16933
|
* const factory = sequentialIncrementingNumberStringModelIdFactory({ startAt: 0 });
|
|
15994
16934
|
* const first = factory(); // encoded representation of 0
|
|
15995
16935
|
* const second = factory(); // encoded representation of 1
|
|
15996
16936
|
* ```
|
|
16937
|
+
* @__NO_SIDE_EFFECTS__
|
|
15997
16938
|
*/ function sequentialIncrementingNumberStringModelIdFactory() {
|
|
15998
16939
|
var config = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
15999
16940
|
var inputTranformFunction = config.transform, inputDencoder = config.dencoder, currentIndex = config.currentIndex, inputStartAt = config.startAt, inputIncreaseBy = config.increaseBy;
|
|
@@ -16048,8 +16989,15 @@ function _unsupported_iterable_to_array$c(o, minLen) {
|
|
|
16048
16989
|
* The first object is stored fully. Subsequent objects store only fields that changed from the previous entry.
|
|
16049
16990
|
* Null in a delta entry means the field was cleared. Undefined (missing key) means no change.
|
|
16050
16991
|
*
|
|
16992
|
+
* @dbxUtil
|
|
16993
|
+
* @dbxUtilCategory object
|
|
16994
|
+
* @dbxUtilKind factory
|
|
16995
|
+
* @dbxUtilTags object, delta, array, compress, expand, factory
|
|
16996
|
+
* @dbxUtilRelated equality-comparator-function, object-keys-equality-comparator-function
|
|
16997
|
+
*
|
|
16051
16998
|
* @param config - Configuration with the equality checker that defines which fields to track
|
|
16052
16999
|
* @returns A compressor with `compress` and `expand` methods
|
|
17000
|
+
* @__NO_SIDE_EFFECTS__
|
|
16053
17001
|
*/ function objectDeltaArrayCompressor(config) {
|
|
16054
17002
|
var _equalityChecker = config.equalityChecker;
|
|
16055
17003
|
var assignKnownValuesToCopy = assignValuesToPOJOFunction({
|
|
@@ -16692,8 +17640,15 @@ function _unsupported_iterable_to_array$b(o, minLen) {
|
|
|
16692
17640
|
/**
|
|
16693
17641
|
* Creates a function that returns the name for a given DayOfWeek.
|
|
16694
17642
|
*
|
|
17643
|
+
* @dbxUtil
|
|
17644
|
+
* @dbxUtilCategory date
|
|
17645
|
+
* @dbxUtilKind factory
|
|
17646
|
+
* @dbxUtilTags date, week, day-of-week, name, factory, format
|
|
17647
|
+
* @dbxUtilRelated days-of-week-name-map
|
|
17648
|
+
*
|
|
16695
17649
|
* @param transform - Optional configuration for abbreviation and casing
|
|
16696
17650
|
* @returns A function that maps DayOfWeek values to name strings
|
|
17651
|
+
* @__NO_SIDE_EFFECTS__
|
|
16697
17652
|
*/ function daysOfWeekNameFunction(transform) {
|
|
16698
17653
|
var map = daysOfWeekNameMap(transform);
|
|
16699
17654
|
return function(dayOfWeek) {
|
|
@@ -17211,9 +18166,16 @@ function _object_spread_props$3(target, source) {
|
|
|
17211
18166
|
/**
|
|
17212
18167
|
* Wraps an existing factory with a {@link ToStringFunction} to produce strings from the factory's output.
|
|
17213
18168
|
*
|
|
18169
|
+
* @dbxUtil
|
|
18170
|
+
* @dbxUtilCategory string
|
|
18171
|
+
* @dbxUtilKind factory
|
|
18172
|
+
* @dbxUtilTags string, factory, wrap, transform, to-string
|
|
18173
|
+
* @dbxUtilRelated string-from-date-factory, string-from-time-factory
|
|
18174
|
+
*
|
|
17214
18175
|
* @param factory - the original value factory
|
|
17215
18176
|
* @param toStringFunction - function to convert the factory's output to a string
|
|
17216
18177
|
* @returns a new factory that produces string values
|
|
18178
|
+
* @__NO_SIDE_EFFECTS__
|
|
17217
18179
|
*/ function stringFactoryFromFactory(factory, toStringFunction) {
|
|
17218
18180
|
return function() {
|
|
17219
18181
|
return toStringFunction(factory());
|
|
@@ -17221,9 +18183,16 @@ function _object_spread_props$3(target, source) {
|
|
|
17221
18183
|
}
|
|
17222
18184
|
/**
|
|
17223
18185
|
* Creates a factory that returns a string based on the input date.
|
|
17224
|
-
|
|
18186
|
+
*
|
|
18187
|
+
* @dbxUtil
|
|
18188
|
+
* @dbxUtilCategory string
|
|
18189
|
+
* @dbxUtilKind factory
|
|
18190
|
+
* @dbxUtilTags string, date, factory, transform, slice
|
|
18191
|
+
* @dbxUtilRelated string-from-time-factory, string-factory-from-factory, transform-string-function
|
|
18192
|
+
*
|
|
17225
18193
|
* @param config Configuration for the factory.
|
|
17226
18194
|
* @returns A factory that returns a string based on the input date.
|
|
18195
|
+
* @__NO_SIDE_EFFECTS__
|
|
17227
18196
|
*/ function stringFromDateFactory(config) {
|
|
17228
18197
|
var _ref;
|
|
17229
18198
|
var takeFromEnd = config.takeFromEnd, transformStringConfig = config.transformStringConfig, dateToString = config.dateToString;
|
|
@@ -17241,8 +18210,15 @@ function _object_spread_props$3(target, source) {
|
|
|
17241
18210
|
/**
|
|
17242
18211
|
* Creates a factory that returns a string based on the Unix timestamp of the input date.
|
|
17243
18212
|
*
|
|
18213
|
+
* @dbxUtil
|
|
18214
|
+
* @dbxUtilCategory string
|
|
18215
|
+
* @dbxUtilKind factory
|
|
18216
|
+
* @dbxUtilTags string, date, time, timestamp, factory, suffix
|
|
18217
|
+
* @dbxUtilRelated string-from-date-factory
|
|
18218
|
+
*
|
|
17244
18219
|
* @param digitsFromEnd The number of digits to return from the end of the generated string. Defaults to 7.
|
|
17245
18220
|
* @returns A StringFromDateFactory.
|
|
18221
|
+
* @__NO_SIDE_EFFECTS__
|
|
17246
18222
|
*/ function stringFromTimeFactory() {
|
|
17247
18223
|
var digitsFromEnd = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 7;
|
|
17248
18224
|
return stringFromDateFactory({
|
|
@@ -17850,8 +18826,15 @@ function _performAsyncTask(_0, _1) {
|
|
|
17850
18826
|
* Creates a reusable function that performs tasks in parallel with optional concurrency limits
|
|
17851
18827
|
* and non-concurrent task key constraints.
|
|
17852
18828
|
*
|
|
18829
|
+
* @dbxUtil
|
|
18830
|
+
* @dbxUtilCategory promise
|
|
18831
|
+
* @dbxUtilKind factory
|
|
18832
|
+
* @dbxUtilTags promise, parallel, factory, concurrency, async, tasks
|
|
18833
|
+
* @dbxUtilRelated perform-tasks-in-parallel, perform-async-tasks-function
|
|
18834
|
+
*
|
|
17853
18835
|
* @param config - Configuration for task factory, parallelism limits, and concurrency keys.
|
|
17854
18836
|
* @returns A function that accepts an array of inputs and returns a Promise resolving when all tasks complete.
|
|
18837
|
+
* @__NO_SIDE_EFFECTS__
|
|
17855
18838
|
*/ function performTasksInParallelFunction(config) {
|
|
17856
18839
|
var taskFactory = config.taskFactory, sequential = config.sequential, nonConcurrentTaskKeyFactory = config.nonConcurrentTaskKeyFactory, inputMaxParallelTasks = config.maxParallelTasks; config.waitBetweenTasks;
|
|
17857
18840
|
var defaultNonConcurrentTaskKeyFactory = makeDefaultNonConcurrentTaskKeyFactory();
|
|
@@ -17893,8 +18876,15 @@ function _performAsyncTask(_0, _1) {
|
|
|
17893
18876
|
* Creates a function that pulls task inputs from a factory and executes them in parallel
|
|
17894
18877
|
* with configurable concurrency limits and non-concurrent key constraints.
|
|
17895
18878
|
*
|
|
18879
|
+
* @dbxUtil
|
|
18880
|
+
* @dbxUtilCategory promise
|
|
18881
|
+
* @dbxUtilKind factory
|
|
18882
|
+
* @dbxUtilTags promise, parallel, factory, concurrency, async, pull-tasks
|
|
18883
|
+
* @dbxUtilRelated perform-tasks-in-parallel-function
|
|
18884
|
+
*
|
|
17896
18885
|
* @param config - Configuration for the task factory, parallelism, and concurrency behavior.
|
|
17897
18886
|
* @returns a function that accepts a task input factory and returns a Promise that resolves when all tasks complete
|
|
18887
|
+
* @__NO_SIDE_EFFECTS__
|
|
17898
18888
|
*/ function performTasksFromFactoryInParallelFunction(config) {
|
|
17899
18889
|
/**
|
|
17900
18890
|
* @returns null
|
|
@@ -18160,7 +19150,14 @@ function _performAsyncTask(_0, _1) {
|
|
|
18160
19150
|
/**
|
|
18161
19151
|
* Creates a default non-concurrent task key factory that generates unique incrementing number strings.
|
|
18162
19152
|
*
|
|
19153
|
+
* @dbxUtil
|
|
19154
|
+
* @dbxUtilCategory promise
|
|
19155
|
+
* @dbxUtilKind factory
|
|
19156
|
+
* @dbxUtilTags promise, parallel, key, factory, unique, incrementing
|
|
19157
|
+
* @dbxUtilRelated perform-tasks-in-parallel-function, incrementing-number-factory
|
|
19158
|
+
*
|
|
18163
19159
|
* @returns A {@link StringFactory} that produces unique keys for identifying non-concurrent tasks.
|
|
19160
|
+
* @__NO_SIDE_EFFECTS__
|
|
18164
19161
|
*/ function makeDefaultNonConcurrentTaskKeyFactory() {
|
|
18165
19162
|
return stringFactoryFromFactory(incrementingNumberFactory(), function(x) {
|
|
18166
19163
|
return x.toString();
|
|
@@ -18523,8 +19520,15 @@ function _ts_generator$3(thisArg, body) {
|
|
|
18523
19520
|
* Creates a {@link TryWithPromiseFactoriesFunction} that sequentially tries each promise factory
|
|
18524
19521
|
* until one returns a non-null value (or a Maybe value if `successOnMaybe` is true).
|
|
18525
19522
|
*
|
|
19523
|
+
* @dbxUtil
|
|
19524
|
+
* @dbxUtilCategory promise
|
|
19525
|
+
* @dbxUtilKind factory
|
|
19526
|
+
* @dbxUtilTags promise, factory, try, sequential, fallback, async
|
|
19527
|
+
* @dbxUtilRelated run-named-async-tasks-function
|
|
19528
|
+
*
|
|
18526
19529
|
* @param config - Configuration including the array of promise factories and default behavior options.
|
|
18527
19530
|
* @returns A function that tries each factory in order for a given input.
|
|
19531
|
+
* @__NO_SIDE_EFFECTS__
|
|
18528
19532
|
*/ function tryWithPromiseFactoriesFunction(config) {
|
|
18529
19533
|
var promiseFactories = config.promiseFactories, defaultSuccessOnMaybe = config.successOnMaybe, defaultThrowErrors = config.throwErrors;
|
|
18530
19534
|
return function(input, config) {
|
|
@@ -18854,8 +19858,15 @@ function _ts_generator$2(thisArg, body) {
|
|
|
18854
19858
|
/**
|
|
18855
19859
|
* Creates a new RunNamedAsyncTasksFunction.
|
|
18856
19860
|
*
|
|
19861
|
+
* @dbxUtil
|
|
19862
|
+
* @dbxUtilCategory promise
|
|
19863
|
+
* @dbxUtilKind factory
|
|
19864
|
+
* @dbxUtilTags promise, async, task, factory, named, parallel
|
|
19865
|
+
* @dbxUtilRelated try-with-promise-factories-function
|
|
19866
|
+
*
|
|
18857
19867
|
* @param config Optional configuration.
|
|
18858
19868
|
* @returns A new RunNamedAsyncTasksFunction.
|
|
19869
|
+
* @__NO_SIDE_EFFECTS__
|
|
18859
19870
|
*/ function runNamedAsyncTasksFunction(config) {
|
|
18860
19871
|
var _ref = config !== null && config !== void 0 ? config : {}, onTaskSuccess = _ref.onTaskSuccess, onTaskFailure = _ref.onTaskFailure;
|
|
18861
19872
|
return function(inputTasks, options) {
|
|
@@ -19078,9 +20089,16 @@ function _is_native_reflect_construct$2() {
|
|
|
19078
20089
|
/**
|
|
19079
20090
|
* Creates a new Timer from the input duration.
|
|
19080
20091
|
*
|
|
20092
|
+
* @dbxUtil
|
|
20093
|
+
* @dbxUtilCategory date
|
|
20094
|
+
* @dbxUtilKind factory
|
|
20095
|
+
* @dbxUtilTags date, time, timer, factory, duration
|
|
20096
|
+
* @dbxUtilRelated timer
|
|
20097
|
+
*
|
|
19081
20098
|
* @param duration - The duration of the timer.
|
|
19082
20099
|
* @param startImmediately - Whether the timer should start immediately. Defaults to true.
|
|
19083
20100
|
* @returns The new Timer.
|
|
20101
|
+
* @__NO_SIDE_EFFECTS__
|
|
19084
20102
|
*/ function makeTimer(duration) {
|
|
19085
20103
|
var startImmediately = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
|
|
19086
20104
|
var createdAt = new Date();
|
|
@@ -19572,8 +20590,15 @@ function _compareObjects(a, b, pojoFilter) {
|
|
|
19572
20590
|
*
|
|
19573
20591
|
* Fields can be specified as simple field names (using the default `===` comparator) or as config objects with custom comparators.
|
|
19574
20592
|
*
|
|
20593
|
+
* @dbxUtil
|
|
20594
|
+
* @dbxUtilCategory object
|
|
20595
|
+
* @dbxUtilKind factory
|
|
20596
|
+
* @dbxUtilTags object, equality, fields, comparator, factory
|
|
20597
|
+
* @dbxUtilRelated object-keys-equality-comparator-function, object-key-equality-comparator-function
|
|
20598
|
+
*
|
|
19575
20599
|
* @param config - Configuration with the fields to compare and an optional default equality function
|
|
19576
20600
|
* @returns A function that compares two objects and reports which fields are equal/unequal
|
|
20601
|
+
* @__NO_SIDE_EFFECTS__
|
|
19577
20602
|
*/ function objectFieldEqualityChecker(config) {
|
|
19578
20603
|
var fields = config.fields, _config_defaultEqualityFunction = config.defaultEqualityFunction, defaultEqualityFunction = _config_defaultEqualityFunction === void 0 ? function(a, b) {
|
|
19579
20604
|
return a === b;
|
|
@@ -19621,8 +20646,15 @@ function _compareObjects(a, b, pojoFilter) {
|
|
|
19621
20646
|
* Returns `true` if both arrays have the same length and produce identical key sets.
|
|
19622
20647
|
* Handles `null`/`undefined` inputs via {@link safeEqualityComparatorFunction}.
|
|
19623
20648
|
*
|
|
20649
|
+
* @dbxUtil
|
|
20650
|
+
* @dbxUtilCategory object
|
|
20651
|
+
* @dbxUtilKind factory
|
|
20652
|
+
* @dbxUtilTags object, key, equality, comparator, factory, array
|
|
20653
|
+
* @dbxUtilRelated object-key-equality-comparator-function, safe-equality-comparator-function
|
|
20654
|
+
*
|
|
19624
20655
|
* @param readKey - Function to extract one or more keys from each object
|
|
19625
20656
|
* @returns An equality comparator for arrays of keyed objects
|
|
20657
|
+
* @__NO_SIDE_EFFECTS__
|
|
19626
20658
|
*/ function objectKeysEqualityComparatorFunction(readKey) {
|
|
19627
20659
|
var readKeysSet = readKeysSetFunction(readKey);
|
|
19628
20660
|
var readKeysArray = readKeysFunction(readKey);
|
|
@@ -19646,8 +20678,15 @@ function _compareObjects(a, b, pojoFilter) {
|
|
|
19646
20678
|
*
|
|
19647
20679
|
* Handles `null`/`undefined` inputs via {@link safeEqualityComparatorFunction}.
|
|
19648
20680
|
*
|
|
20681
|
+
* @dbxUtil
|
|
20682
|
+
* @dbxUtilCategory object
|
|
20683
|
+
* @dbxUtilKind factory
|
|
20684
|
+
* @dbxUtilTags object, key, equality, comparator, factory
|
|
20685
|
+
* @dbxUtilRelated object-keys-equality-comparator-function, safe-equality-comparator-function
|
|
20686
|
+
*
|
|
19649
20687
|
* @param readKey - Function to extract the key from an object
|
|
19650
20688
|
* @returns An equality comparator for keyed objects
|
|
20689
|
+
* @__NO_SIDE_EFFECTS__
|
|
19651
20690
|
*/ function objectKeyEqualityComparatorFunction(readKey) {
|
|
19652
20691
|
return safeEqualityComparatorFunction(function(a, b) {
|
|
19653
20692
|
return readKey(a) === readKey(b);
|
|
@@ -19711,8 +20750,15 @@ function _unsupported_iterable_to_array$7(o, minLen) {
|
|
|
19711
20750
|
/**
|
|
19712
20751
|
* Creates a reusable {@link MapObjectMapFunction} that applies {@link mapObjectMap} with the given mapping function.
|
|
19713
20752
|
*
|
|
20753
|
+
* @dbxUtil
|
|
20754
|
+
* @dbxUtilCategory object
|
|
20755
|
+
* @dbxUtilKind factory
|
|
20756
|
+
* @dbxUtilTags object, map, transform, factory, values
|
|
20757
|
+
* @dbxUtilRelated map-object-map, map-object-keys-function
|
|
20758
|
+
*
|
|
19714
20759
|
* @param mapFn - Function that transforms each value (receives value and key)
|
|
19715
20760
|
* @returns A function that maps all values in an input object map
|
|
20761
|
+
* @__NO_SIDE_EFFECTS__
|
|
19716
20762
|
*/ function mapObjectMapFunction(mapFn) {
|
|
19717
20763
|
return function(object) {
|
|
19718
20764
|
return mapObjectMap(object, mapFn);
|
|
@@ -19746,8 +20792,15 @@ function _unsupported_iterable_to_array$7(o, minLen) {
|
|
|
19746
20792
|
/**
|
|
19747
20793
|
* Creates a reusable {@link MapObjectKeysFunction} that transforms the keys of an input object using the given mapping function.
|
|
19748
20794
|
*
|
|
20795
|
+
* @dbxUtil
|
|
20796
|
+
* @dbxUtilCategory object
|
|
20797
|
+
* @dbxUtilKind factory
|
|
20798
|
+
* @dbxUtilTags object, map, keys, transform, factory, rename
|
|
20799
|
+
* @dbxUtilRelated map-object-map-function, map-object-keys-to-lowercase
|
|
20800
|
+
*
|
|
19749
20801
|
* @param mapKeyFn - Function that computes the new key from the old key and its value
|
|
19750
20802
|
* @returns A function that remaps keys on any input object
|
|
20803
|
+
* @__NO_SIDE_EFFECTS__
|
|
19751
20804
|
*/ function mapObjectKeysFunction(mapKeyFn) {
|
|
19752
20805
|
return function(object) {
|
|
19753
20806
|
var target = {};
|
|
@@ -19865,9 +20918,16 @@ function _type_of$2(obj) {
|
|
|
19865
20918
|
* If the field does not exist on the source but a default is configured, the default is used.
|
|
19866
20919
|
* Otherwise, the target is left unchanged.
|
|
19867
20920
|
*
|
|
20921
|
+
* @dbxUtil
|
|
20922
|
+
* @dbxUtilCategory model
|
|
20923
|
+
* @dbxUtilKind factory
|
|
20924
|
+
* @dbxUtilTags model, copy, field, factory, default
|
|
20925
|
+
* @dbxUtilRelated make-model-map-functions, modify-model-map-functions
|
|
20926
|
+
*
|
|
19868
20927
|
* @param key - The property key to copy
|
|
19869
20928
|
* @param inputConfig - Optional config with a default value for the field
|
|
19870
20929
|
* @returns A function that copies the field from source to target
|
|
20930
|
+
* @__NO_SIDE_EFFECTS__
|
|
19871
20931
|
*/ function makeCopyModelFieldFunction(key, inputConfig) {
|
|
19872
20932
|
var config = inputConfig !== null && inputConfig !== void 0 ? inputConfig : {};
|
|
19873
20933
|
var hasDefault = objectHasKey(config, 'default');
|
|
@@ -19933,8 +20993,15 @@ function _unsupported_iterable_to_array$6(o, minLen) {
|
|
|
19933
20993
|
*
|
|
19934
20994
|
* The `to` function converts from the model (V) to data (D), while `from` converts back from data (D) to model (V).
|
|
19935
20995
|
*
|
|
20996
|
+
* @dbxUtil
|
|
20997
|
+
* @dbxUtilCategory model
|
|
20998
|
+
* @dbxUtilKind factory
|
|
20999
|
+
* @dbxUtilTags model, conversion, map, factory, bidirectional, fields
|
|
21000
|
+
* @dbxUtilRelated to-model-map-functions, modify-model-map-functions, model-field-conversions
|
|
21001
|
+
*
|
|
19936
21002
|
* @param fields - Field conversion definitions for each key in the model
|
|
19937
21003
|
* @returns Object with `from` and `to` mapping functions
|
|
21004
|
+
* @__NO_SIDE_EFFECTS__
|
|
19938
21005
|
*/ function makeModelMapFunctions(fields) {
|
|
19939
21006
|
var keys = filterKeyValueTuples(fields);
|
|
19940
21007
|
var conversionsByKey = keys.map(function(param) {
|
|
@@ -19970,8 +21037,15 @@ function _unsupported_iterable_to_array$6(o, minLen) {
|
|
|
19970
21037
|
*
|
|
19971
21038
|
* Supports optional filtering by field names and skipping undefined values via {@link ModelConversionOptions}.
|
|
19972
21039
|
*
|
|
21040
|
+
* @dbxUtil
|
|
21041
|
+
* @dbxUtilCategory model
|
|
21042
|
+
* @dbxUtilKind factory
|
|
21043
|
+
* @dbxUtilTags model, conversion, factory, fields, map, transform
|
|
21044
|
+
* @dbxUtilRelated make-model-map-functions, model-field-map-functions
|
|
21045
|
+
*
|
|
19973
21046
|
* @param fields - Array of `[key, convertFn]` tuples defining how each field is converted
|
|
19974
21047
|
* @returns A function that converts an input object to an output object
|
|
21048
|
+
* @__NO_SIDE_EFFECTS__
|
|
19975
21049
|
*/ function makeModelConversionFieldValuesFunction(fields) {
|
|
19976
21050
|
return function(input, inputTarget, options) {
|
|
19977
21051
|
var target = inputTarget !== null && inputTarget !== void 0 ? inputTarget : {};
|
|
@@ -20008,8 +21082,15 @@ function _unsupported_iterable_to_array$6(o, minLen) {
|
|
|
20008
21082
|
/**
|
|
20009
21083
|
* Compiles a {@link ModelFieldMapFunctionsConfig} into resolved {@link ModelFieldMapFunctions} with `from` and `to` mapping functions.
|
|
20010
21084
|
*
|
|
21085
|
+
* @dbxUtil
|
|
21086
|
+
* @dbxUtilCategory model
|
|
21087
|
+
* @dbxUtilKind factory
|
|
21088
|
+
* @dbxUtilTags model, field, map, factory, conversion, bidirectional
|
|
21089
|
+
* @dbxUtilRelated model-field-map-function, make-model-map-functions
|
|
21090
|
+
*
|
|
20011
21091
|
* @param config - Configuration with `from` and `to` field map configs
|
|
20012
21092
|
* @returns Compiled field map functions
|
|
21093
|
+
* @__NO_SIDE_EFFECTS__
|
|
20013
21094
|
*/ function modelFieldMapFunctions(config) {
|
|
20014
21095
|
return {
|
|
20015
21096
|
from: modelFieldMapFunction(config.from),
|
|
@@ -20024,8 +21105,15 @@ function _unsupported_iterable_to_array$6(o, minLen) {
|
|
|
20024
21105
|
* - Null/undefined input with `convertMaybe`: delegates to that function
|
|
20025
21106
|
* - Null/undefined input with `default` or `defaultInput`: uses the appropriate fallback
|
|
20026
21107
|
*
|
|
21108
|
+
* @dbxUtil
|
|
21109
|
+
* @dbxUtilCategory model
|
|
21110
|
+
* @dbxUtilKind factory
|
|
21111
|
+
* @dbxUtilTags model, field, map, factory, maybe, default, convert
|
|
21112
|
+
* @dbxUtilRelated model-field-map-functions, make-model-map-functions
|
|
21113
|
+
*
|
|
20027
21114
|
* @param config - Configuration specifying how to convert values and handle null/undefined
|
|
20028
21115
|
* @returns A function that maps Maybe input values to output values
|
|
21116
|
+
* @__NO_SIDE_EFFECTS__
|
|
20029
21117
|
*/ function modelFieldMapFunction(config) {
|
|
20030
21118
|
var convert = config.convert;
|
|
20031
21119
|
var convertMaybe = 'convertMaybe' in config ? config.convertMaybe : undefined;
|
|
@@ -20066,8 +21154,15 @@ function _unsupported_iterable_to_array$6(o, minLen) {
|
|
|
20066
21154
|
*
|
|
20067
21155
|
* Accepts a pre-built `mapFunctions` reference, a `fieldConversions` ref, or a `fields` config.
|
|
20068
21156
|
*
|
|
21157
|
+
* @dbxUtil
|
|
21158
|
+
* @dbxUtilCategory model
|
|
21159
|
+
* @dbxUtilKind factory
|
|
21160
|
+
* @dbxUtilTags model, conversion, map, factory, normalize, resolve
|
|
21161
|
+
* @dbxUtilRelated make-model-map-functions, to-model-field-conversions
|
|
21162
|
+
*
|
|
20069
21163
|
* @param input - Input that can be resolved to model map functions
|
|
20070
21164
|
* @returns Bidirectional model map functions
|
|
21165
|
+
* @__NO_SIDE_EFFECTS__
|
|
20071
21166
|
*/ function toModelMapFunctions(input) {
|
|
20072
21167
|
var mapFunctions;
|
|
20073
21168
|
if ('mapFunctions' in input) {
|
|
@@ -20166,8 +21261,15 @@ function _object_spread$2(target) {
|
|
|
20166
21261
|
*
|
|
20167
21262
|
* Optionally copies the input object before modification to avoid mutating the original.
|
|
20168
21263
|
*
|
|
21264
|
+
* @dbxUtil
|
|
21265
|
+
* @dbxUtilCategory model
|
|
21266
|
+
* @dbxUtilKind factory
|
|
21267
|
+
* @dbxUtilTags model, map, modify, factory, modifier, copy
|
|
21268
|
+
* @dbxUtilRelated make-model-map-functions, modify-model-map-function
|
|
21269
|
+
*
|
|
20169
21270
|
* @param config - Configuration with the base map functions, modifiers, and copy options
|
|
20170
21271
|
* @returns New model map functions with modifiers applied before each conversion
|
|
21272
|
+
* @__NO_SIDE_EFFECTS__
|
|
20171
21273
|
*/ function modifyModelMapFunctions(config) {
|
|
20172
21274
|
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;
|
|
20173
21275
|
var from = mapFunctions.from, to = mapFunctions.to;
|
|
@@ -20185,10 +21287,17 @@ function _object_spread$2(target) {
|
|
|
20185
21287
|
* When `copy` is true (default), the input is shallow-copied before modification to avoid mutating the original.
|
|
20186
21288
|
* If no modifier is provided, the original map function is returned unchanged.
|
|
20187
21289
|
*
|
|
21290
|
+
* @dbxUtil
|
|
21291
|
+
* @dbxUtilCategory model
|
|
21292
|
+
* @dbxUtilKind factory
|
|
21293
|
+
* @dbxUtilTags model, map, modify, factory, modifier, wrap
|
|
21294
|
+
* @dbxUtilRelated modify-model-map-functions, model-field-map-function
|
|
21295
|
+
*
|
|
20188
21296
|
* @param mapFn - The base map function to wrap
|
|
20189
21297
|
* @param modifyModel - Optional modifier to apply before mapping
|
|
20190
21298
|
* @param copy - Whether to shallow-copy the input before modifying; defaults to true
|
|
20191
21299
|
* @returns The wrapped map function, or the original if no modifier is provided
|
|
21300
|
+
* @__NO_SIDE_EFFECTS__
|
|
20192
21301
|
*/ function modifyModelMapFunction(mapFn, modifyModel) {
|
|
20193
21302
|
var copy = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
|
|
20194
21303
|
return modifyModel ? function(input, target, options) {
|
|
@@ -20203,8 +21312,15 @@ function _object_spread$2(target) {
|
|
|
20203
21312
|
/**
|
|
20204
21313
|
* Creates a function that reads a Node.js ReadableStream and converts its contents to a string using the specified encoding.
|
|
20205
21314
|
*
|
|
21315
|
+
* @dbxUtil
|
|
21316
|
+
* @dbxUtilCategory nodejs
|
|
21317
|
+
* @dbxUtilKind factory
|
|
21318
|
+
* @dbxUtilTags nodejs, stream, readable, string, factory, encoding
|
|
21319
|
+
* @dbxUtilRelated readable-stream-to-buffer, readable-stream-to-base64
|
|
21320
|
+
*
|
|
20206
21321
|
* @param encoding - The buffer encoding to use (e.g., 'utf-8', 'base64')
|
|
20207
21322
|
* @returns A function that consumes a ReadableStream and resolves to its string content
|
|
21323
|
+
* @__NO_SIDE_EFFECTS__
|
|
20208
21324
|
*/ function readableStreamToStringFunction(encoding) {
|
|
20209
21325
|
return function(stream) {
|
|
20210
21326
|
return readableStreamToBuffer(stream).then(function(x) {
|
|
@@ -20685,8 +21801,15 @@ function handlerFactory(readKey, options) {
|
|
|
20685
21801
|
/**
|
|
20686
21802
|
* Convenience function that creates a new {@link Handler} from the given key reader using default options.
|
|
20687
21803
|
*
|
|
21804
|
+
* @dbxUtil
|
|
21805
|
+
* @dbxUtilCategory service
|
|
21806
|
+
* @dbxUtilKind factory
|
|
21807
|
+
* @dbxUtilTags service, handler, factory, dispatch, key, convenience
|
|
21808
|
+
* @dbxUtilRelated handler-factory
|
|
21809
|
+
*
|
|
20688
21810
|
* @param readKey - Function to extract the dispatch key from an input value.
|
|
20689
21811
|
* @returns A new Handler instance.
|
|
21812
|
+
* @__NO_SIDE_EFFECTS__
|
|
20690
21813
|
*/ function makeHandler(readKey) {
|
|
20691
21814
|
return handlerFactory(readKey)();
|
|
20692
21815
|
}
|
|
@@ -20720,9 +21843,16 @@ function handlerFactory(readKey, options) {
|
|
|
20720
21843
|
/**
|
|
20721
21844
|
* Creates a {@link HandlerSetFunction} that registers a handler function on a pre-defined key.
|
|
20722
21845
|
*
|
|
21846
|
+
* @dbxUtil
|
|
21847
|
+
* @dbxUtilCategory service
|
|
21848
|
+
* @dbxUtilKind factory
|
|
21849
|
+
* @dbxUtilTags service, handler, set, factory, register
|
|
21850
|
+
* @dbxUtilRelated handler-mapped-set-function, handler-factory
|
|
21851
|
+
*
|
|
20723
21852
|
* @param accessor - The handler set accessor to register on.
|
|
20724
21853
|
* @param key - The key (or keys) to associate the handler with.
|
|
20725
21854
|
* @returns A function that accepts a handler function and registers it for the given key.
|
|
21855
|
+
* @__NO_SIDE_EFFECTS__
|
|
20726
21856
|
*/ function handlerSetFunction(accessor, key) {
|
|
20727
21857
|
var fn = function fn(handlerFunction) {
|
|
20728
21858
|
accessor.set(key, handlerFunction); // set the handler on the pre-defined key.
|
|
@@ -20734,10 +21864,17 @@ function handlerFactory(readKey, options) {
|
|
|
20734
21864
|
* Creates a {@link HandlerMappedSetFunction} that maps the handler's native input type to a different
|
|
20735
21865
|
* type before invoking the registered handler function.
|
|
20736
21866
|
*
|
|
21867
|
+
* @dbxUtil
|
|
21868
|
+
* @dbxUtilCategory service
|
|
21869
|
+
* @dbxUtilKind factory
|
|
21870
|
+
* @dbxUtilTags service, handler, set, mapped, factory, transform
|
|
21871
|
+
* @dbxUtilRelated handler-set-function, handler-mapped-set-function-factory
|
|
21872
|
+
*
|
|
20737
21873
|
* @param accessor - The handler set accessor to register on.
|
|
20738
21874
|
* @param key - The key (or keys) to associate the handler with.
|
|
20739
21875
|
* @param mapFn - Function to map from the handler's native type to the handler function's expected type.
|
|
20740
21876
|
* @returns A function that accepts a mapped handler function and registers it.
|
|
21877
|
+
* @__NO_SIDE_EFFECTS__
|
|
20741
21878
|
*/ function handlerMappedSetFunction(accessor, key, mapFn) {
|
|
20742
21879
|
var handlerSet = handlerSetFunction(accessor, key);
|
|
20743
21880
|
return function(handlerFunction) {
|
|
@@ -20751,9 +21888,16 @@ function handlerFactory(readKey, options) {
|
|
|
20751
21888
|
/**
|
|
20752
21889
|
* Creates a {@link HandlerMappedSetFunctionFactory} that produces mapped set functions for any given key.
|
|
20753
21890
|
*
|
|
21891
|
+
* @dbxUtil
|
|
21892
|
+
* @dbxUtilCategory service
|
|
21893
|
+
* @dbxUtilKind factory
|
|
21894
|
+
* @dbxUtilTags service, handler, mapped, factory, dispatch
|
|
21895
|
+
* @dbxUtilRelated handler-mapped-set-function, handler-set-function
|
|
21896
|
+
*
|
|
20754
21897
|
* @param accessor - The handler set accessor to register on.
|
|
20755
21898
|
* @param mapFn - Function to map from the handler's native type to the handler function's expected type.
|
|
20756
21899
|
* @returns A factory that creates HandlerMappedSetFunctions for specific keys.
|
|
21900
|
+
* @__NO_SIDE_EFFECTS__
|
|
20757
21901
|
*/ function handlerMappedSetFunctionFactory(accessor, mapFn) {
|
|
20758
21902
|
return function(key) {
|
|
20759
21903
|
return handlerMappedSetFunction(accessor, key, mapFn);
|
|
@@ -20763,8 +21907,15 @@ function handlerFactory(readKey, options) {
|
|
|
20763
21907
|
* Creates a {@link HandlerConfigurerFactory} that produces configurers for binding handler functions
|
|
20764
21908
|
* to a handler instance with automatic `this` binding.
|
|
20765
21909
|
*
|
|
21910
|
+
* @dbxUtil
|
|
21911
|
+
* @dbxUtilCategory service
|
|
21912
|
+
* @dbxUtilKind factory
|
|
21913
|
+
* @dbxUtilTags service, handler, configurer, factory, bind
|
|
21914
|
+
* @dbxUtilRelated handler-bind-accessor, handler-factory
|
|
21915
|
+
*
|
|
20766
21916
|
* @param config - Configuration providing the accessor-to-configurer mapping.
|
|
20767
21917
|
* @returns A factory that creates HandlerConfigurers for specific handlers.
|
|
21918
|
+
* @__NO_SIDE_EFFECTS__
|
|
20768
21919
|
*/ function handlerConfigurerFactory(config) {
|
|
20769
21920
|
return function(handler) {
|
|
20770
21921
|
return function(bindTo, configure) {
|
|
@@ -21828,8 +22979,15 @@ function mimeTypeForFileExtension(extension) {
|
|
|
21828
22979
|
/**
|
|
21829
22980
|
* Creates a {@link SortByStringFunction} that sorts values in ascending alphabetical order using `localeCompare`.
|
|
21830
22981
|
*
|
|
22982
|
+
* @dbxUtil
|
|
22983
|
+
* @dbxUtilCategory string
|
|
22984
|
+
* @dbxUtilKind factory
|
|
22985
|
+
* @dbxUtilTags string, sort, compare, alphabetical, factory, locale
|
|
22986
|
+
* @dbxUtilRelated sort-by-label-function
|
|
22987
|
+
*
|
|
21831
22988
|
* @param readStringFn - Function to extract a string from each value for comparison.
|
|
21832
22989
|
* @returns A comparator function suitable for use with `Array.sort()`.
|
|
22990
|
+
* @__NO_SIDE_EFFECTS__
|
|
21833
22991
|
*/ function sortByStringFunction(readStringFn) {
|
|
21834
22992
|
return function(a, b) {
|
|
21835
22993
|
var as = readStringFn(a);
|
|
@@ -21846,8 +23004,15 @@ function mimeTypeForFileExtension(extension) {
|
|
|
21846
23004
|
/**
|
|
21847
23005
|
* Creates a {@link SearchStringFilterFunction} that filters values based on whether their string representation matches the filter text.
|
|
21848
23006
|
*
|
|
23007
|
+
* @dbxUtil
|
|
23008
|
+
* @dbxUtilCategory string
|
|
23009
|
+
* @dbxUtilKind factory
|
|
23010
|
+
* @dbxUtilTags string, search, filter, factory, match, decision
|
|
23011
|
+
* @dbxUtilRelated case-insensitive-filter-by-index-of-decision-factory
|
|
23012
|
+
*
|
|
21849
23013
|
* @param config - A read function or full configuration specifying how to extract and match search strings.
|
|
21850
23014
|
* @returns A function that filters an array of values by a search/filter text string.
|
|
23015
|
+
* @__NO_SIDE_EFFECTS__
|
|
21851
23016
|
*/ function searchStringFilterFunction(config) {
|
|
21852
23017
|
var _ref = typeof config === 'function' ? {
|
|
21853
23018
|
readStrings: config
|
|
@@ -21942,8 +23107,15 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
21942
23107
|
/**
|
|
21943
23108
|
* Creates a {@link SplitStringTreeFactory} that builds tree structures by splitting strings on the configured separator.
|
|
21944
23109
|
*
|
|
23110
|
+
* @dbxUtil
|
|
23111
|
+
* @dbxUtilCategory string
|
|
23112
|
+
* @dbxUtilKind factory
|
|
23113
|
+
* @dbxUtilTags string, tree, split, separator, factory, hierarchy
|
|
23114
|
+
* @dbxUtilRelated add-to-split-string-tree, find-best-split-string-tree-match
|
|
23115
|
+
*
|
|
21945
23116
|
* @param config - Configuration specifying the separator and optional metadata merge strategy.
|
|
21946
23117
|
* @returns A factory function that creates or extends split string trees.
|
|
23118
|
+
* @__NO_SIDE_EFFECTS__
|
|
21947
23119
|
*/ function splitStringTreeFactory(config) {
|
|
21948
23120
|
var separator = config.separator;
|
|
21949
23121
|
var fn = function fn(input, existing) {
|
|
@@ -22103,6 +23275,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
22103
23275
|
* @template N The type of the TreeNode to be created. Defaults to TreeNode<T, any> if not specified by ExpandTreeWithNodeBuilder.
|
|
22104
23276
|
* @param config An ExpandTree<T> or ExpandTreeWithNodeBuilder<T, N> configuration object.
|
|
22105
23277
|
* @returns An ExpandTreeFunction<T, N> that takes a root value and returns its corresponding tree structure.
|
|
23278
|
+
* @__NO_SIDE_EFFECTS__
|
|
22106
23279
|
*/ function expandTreeFunction(config) {
|
|
22107
23280
|
var _config_makeNode;
|
|
22108
23281
|
var makeNodeFromConfig = (_config_makeNode = config.makeNode) !== null && _config_makeNode !== void 0 ? _config_makeNode : function(basicNode) {
|
|
@@ -22195,6 +23368,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
22195
23368
|
* visited.push(id);
|
|
22196
23369
|
* });
|
|
22197
23370
|
* ```
|
|
23371
|
+
* @__NO_SIDE_EFFECTS__
|
|
22198
23372
|
*/ function exploreTreeFunction(config) {
|
|
22199
23373
|
var _ref, _ref1, _ref2;
|
|
22200
23374
|
var defaultMapNodeFn = (_ref = config === null || config === void 0 ? void 0 : config.mapNodeFunction) !== null && _ref !== void 0 ? _ref : MAP_IDENTITY;
|
|
@@ -22245,6 +23419,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
22245
23419
|
* });
|
|
22246
23420
|
* // Visits: root -> child1 -> leaf1 -> leaf2 -> child2 -> leaf3
|
|
22247
23421
|
* ```
|
|
23422
|
+
* @__NO_SIDE_EFFECTS__
|
|
22248
23423
|
*/ function depthFirstExploreTreeTraversalFactoryFunction() {
|
|
22249
23424
|
return function(visit, continueTraversal) {
|
|
22250
23425
|
return function(node, nodeMappedValue, visitDecision) {
|
|
@@ -22283,6 +23458,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
22283
23458
|
* });
|
|
22284
23459
|
* // Visits: root -> child1, child2, child3 -> leaf1, leaf2, leaf3
|
|
22285
23460
|
* ```
|
|
23461
|
+
* @__NO_SIDE_EFFECTS__
|
|
22286
23462
|
*/ function breadthFirstExploreTreeTraversalFactoryFunction() {
|
|
22287
23463
|
return function(visit, continueTraversal) {
|
|
22288
23464
|
var queue = [];
|
|
@@ -22455,6 +23631,7 @@ function _object_spread_props(target, source) {
|
|
|
22455
23631
|
* const ids = flattenIds(rootNode);
|
|
22456
23632
|
* // ['root', 'child1', 'leaf1', 'leaf2', 'child2', 'leaf3']
|
|
22457
23633
|
* ```
|
|
23634
|
+
* @__NO_SIDE_EFFECTS__
|
|
22458
23635
|
*/ function flattenTreeToArrayFunction(mapNodeFnOrConfig, defaultAddNodeFn) {
|
|
22459
23636
|
var _config_shouldAddNodeFunction;
|
|
22460
23637
|
var config = typeof mapNodeFnOrConfig === 'function' ? {
|
|
@@ -22493,6 +23670,7 @@ function _object_spread_props(target, source) {
|
|
|
22493
23670
|
* @param expand An ExpandTreeFunction (values: T[]) => N[] that converts an array of T into an array of tree nodes N.
|
|
22494
23671
|
* @param flatten A FlattenTreeFunction (tree: N, array?: V[]) => V[] that flattens a tree of N nodes into an array of V values.
|
|
22495
23672
|
* @returns An ExpandFlattenTreeFunction (values: T[]) => V[] that performs the combined expansion and flattening.
|
|
23673
|
+
* @__NO_SIDE_EFFECTS__
|
|
22496
23674
|
*/ function expandFlattenTreeFunction(expand, flatten) {
|
|
22497
23675
|
return function(values) {
|
|
22498
23676
|
return flatten(expandTrees(values, expand));
|
|
@@ -22619,6 +23797,7 @@ function invertMaybeBoolean(x) {
|
|
|
22619
23797
|
* const coinFlip = booleanFactory({ chance: 50 });
|
|
22620
23798
|
* coinFlip(); // true or false with equal probability
|
|
22621
23799
|
* ```
|
|
23800
|
+
* @__NO_SIDE_EFFECTS__
|
|
22622
23801
|
*/ function booleanFactory(config) {
|
|
22623
23802
|
var inputChance = config.chance;
|
|
22624
23803
|
var chance = inputChance / 100;
|
|
@@ -22796,6 +23975,7 @@ function _define_property$1(obj, key, value) {
|
|
|
22796
23975
|
* @param decodeValues - An array of potential original string values.
|
|
22797
23976
|
* @param hashFn - A function that takes a string and returns its hashed representation.
|
|
22798
23977
|
* @returns A {@link HashDecodeMap} for decoding hashed values.
|
|
23978
|
+
* @__NO_SIDE_EFFECTS__
|
|
22799
23979
|
*/ function makeHashDecodeMap(decodeValues, hashFn) {
|
|
22800
23980
|
var keyValuePairs = decodeValues.map(function(x) {
|
|
22801
23981
|
return [
|