@dereekb/util 13.11.2 → 13.11.4
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 +687 -0
- package/eslint/index.cjs.mjs +2 -0
- package/eslint/index.d.ts +1 -0
- package/eslint/index.esm.js +683 -0
- package/eslint/package.json +23 -0
- package/eslint/src/index.d.ts +1 -0
- package/eslint/src/lib/comments.d.ts +101 -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 +50 -0
- package/eslint/src/lib/require-no-side-effects.rule.d.ts +67 -0
- package/fetch/package.json +2 -2
- package/index.cjs.js +1421 -23
- package/index.esm.js +1421 -24
- 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 +229 -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);
|
|
@@ -2013,6 +2081,7 @@ function _type_of$l(obj) {
|
|
|
2013
2081
|
}
|
|
2014
2082
|
return fn;
|
|
2015
2083
|
}
|
|
2084
|
+
// @__NO_SIDE_EFFECTS__
|
|
2016
2085
|
function chainMapFunction(a, b) {
|
|
2017
2086
|
var apply = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
|
|
2018
2087
|
return apply && b != null ? function(x) {
|
|
@@ -2129,6 +2198,7 @@ function _unsupported_iterable_to_array$x(o, minLen) {
|
|
|
2129
2198
|
* @param readKey - Function to extract a unique key from each item.
|
|
2130
2199
|
* @param additionalKeysInput - Optional keys or values to pre-seed as already seen, causing them to be excluded.
|
|
2131
2200
|
* @returns A reusable filter function that removes duplicate items from arrays.
|
|
2201
|
+
* @__NO_SIDE_EFFECTS__
|
|
2132
2202
|
*/ function filterUniqueFunction(readKey, additionalKeysInput) {
|
|
2133
2203
|
var baseKeys = readKeysFromFilterUniqueFunctionAdditionalKeysInput(additionalKeysInput, readKey);
|
|
2134
2204
|
function calculateExclude(excludeInput) {
|
|
@@ -2179,6 +2249,7 @@ function _unsupported_iterable_to_array$x(o, minLen) {
|
|
|
2179
2249
|
*
|
|
2180
2250
|
* @param readKey - Function to extract a unique key from each item.
|
|
2181
2251
|
* @returns A decision function that returns true if all items have distinct keys.
|
|
2252
|
+
* @__NO_SIDE_EFFECTS__
|
|
2182
2253
|
*/ function isUniqueKeyedFunction(readKey) {
|
|
2183
2254
|
return function(input) {
|
|
2184
2255
|
var keys = new Set();
|
|
@@ -2197,6 +2268,7 @@ function _unsupported_iterable_to_array$x(o, minLen) {
|
|
|
2197
2268
|
return findResult === -1;
|
|
2198
2269
|
};
|
|
2199
2270
|
}
|
|
2271
|
+
// @__NO_SIDE_EFFECTS__
|
|
2200
2272
|
function allowValueOnceFilter(inputReadKey) {
|
|
2201
2273
|
var visitedKeys = new Set();
|
|
2202
2274
|
var readKey = inputReadKey !== null && inputReadKey !== void 0 ? inputReadKey : MAP_IDENTITY;
|
|
@@ -2289,6 +2361,7 @@ function removeModelsWithKey(input, key) {
|
|
|
2289
2361
|
return read(x) !== key;
|
|
2290
2362
|
});
|
|
2291
2363
|
}
|
|
2364
|
+
// @__NO_SIDE_EFFECTS__
|
|
2292
2365
|
function makeModelMap(input, read) {
|
|
2293
2366
|
var map = new Map();
|
|
2294
2367
|
input.forEach(function(x) {
|
|
@@ -2304,9 +2377,15 @@ function makeModelMap(input, read) {
|
|
|
2304
2377
|
*
|
|
2305
2378
|
* If multiple models share the same relation key, the last one wins for that key.
|
|
2306
2379
|
*
|
|
2380
|
+
* @dbxUtil
|
|
2381
|
+
* @dbxUtilCategory model
|
|
2382
|
+
* @dbxUtilTags model, map, key, multi, relation, index, lookup
|
|
2383
|
+
* @dbxUtilRelated make-model-map, read-model-key
|
|
2384
|
+
*
|
|
2307
2385
|
* @param input - Array of models to index
|
|
2308
2386
|
* @param read - Function that returns an array of relation keys for each model
|
|
2309
2387
|
* @returns Map from relation key to model
|
|
2388
|
+
* @__NO_SIDE_EFFECTS__
|
|
2310
2389
|
*/ function makeMultiModelKeyMap(input, read) {
|
|
2311
2390
|
var map = new Map();
|
|
2312
2391
|
input.forEach(function(x) {
|
|
@@ -2458,9 +2537,16 @@ function readModelKey(input) {
|
|
|
2458
2537
|
*
|
|
2459
2538
|
* Falls back to the provided default type if the type reader returns a nullish value.
|
|
2460
2539
|
*
|
|
2540
|
+
* @dbxUtil
|
|
2541
|
+
* @dbxUtilCategory model
|
|
2542
|
+
* @dbxUtilKind factory
|
|
2543
|
+
* @dbxUtilTags model, type, pair, factory, wrap
|
|
2544
|
+
* @dbxUtilRelated read-model-key, encode-model-key-type-pair
|
|
2545
|
+
*
|
|
2461
2546
|
* @param typeReader - Function to extract the model type from input data
|
|
2462
2547
|
* @param defaultType - Fallback type string when the reader returns nullish
|
|
2463
2548
|
* @returns Factory function that produces ModelTypeDataPair values
|
|
2549
|
+
* @__NO_SIDE_EFFECTS__
|
|
2464
2550
|
*/ function modelTypeDataPairFactory(typeReader) {
|
|
2465
2551
|
var defaultType = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : DEFAULT_UNKNOWN_MODEL_TYPE_STRING;
|
|
2466
2552
|
return function(data) {
|
|
@@ -2939,6 +3025,7 @@ function reverseCompareFn(compareFn) {
|
|
|
2939
3025
|
* [{ name: 'Bob' }, { name: 'Alice' }].sort(byName);
|
|
2940
3026
|
* // [{ name: 'Alice' }, { name: 'Bob' }]
|
|
2941
3027
|
* ```
|
|
3028
|
+
* @__NO_SIDE_EFFECTS__
|
|
2942
3029
|
*/ function compareWithMappedValuesFunction(mapValue, comparesFunction) {
|
|
2943
3030
|
return function(a, b) {
|
|
2944
3031
|
var vA = mapValue(a);
|
|
@@ -3004,12 +3091,19 @@ function reverseCompareFn(compareFn) {
|
|
|
3004
3091
|
* @param compareFn - Ascending sort comparison function used to determine min/max.
|
|
3005
3092
|
* @returns A function that returns `{ min, max }` or `null` for empty iterables.
|
|
3006
3093
|
*
|
|
3094
|
+
* @dbxUtil
|
|
3095
|
+
* @dbxUtilCategory sort
|
|
3096
|
+
* @dbxUtilKind factory
|
|
3097
|
+
* @dbxUtilTags sort, min, max, factory, iterable, compare
|
|
3098
|
+
* @dbxUtilRelated min-and-max-index-items-function, sort-by-number-function
|
|
3099
|
+
*
|
|
3007
3100
|
* @example
|
|
3008
3101
|
* ```ts
|
|
3009
3102
|
* const fn = minAndMaxFunction<number>((a, b) => a - b);
|
|
3010
3103
|
* fn([3, 1, 4, 1, 5]); // { min: 1, max: 5 }
|
|
3011
3104
|
* fn([]); // null
|
|
3012
3105
|
* ```
|
|
3106
|
+
* @__NO_SIDE_EFFECTS__
|
|
3013
3107
|
*/ function minAndMaxFunction(compareFn) {
|
|
3014
3108
|
return function(values) {
|
|
3015
3109
|
var _firstValueFromIterable;
|
|
@@ -3303,9 +3397,15 @@ function _unsupported_iterable_to_array$t(o, minLen) {
|
|
|
3303
3397
|
/**
|
|
3304
3398
|
* Creates an array of `[key, value]` tuples by extracting a key from each value.
|
|
3305
3399
|
*
|
|
3400
|
+
* @dbxUtil
|
|
3401
|
+
* @dbxUtilCategory grouping
|
|
3402
|
+
* @dbxUtilTags grouping, key, pairs, tuple, array
|
|
3403
|
+
* @dbxUtilRelated group-values, make-values-group-map
|
|
3404
|
+
*
|
|
3306
3405
|
* @param values - Values to create key pairs from.
|
|
3307
3406
|
* @param keyFn - Extracts the key from each value.
|
|
3308
3407
|
* @returns An array of `[key, value]` tuples.
|
|
3408
|
+
* @__NO_SIDE_EFFECTS__
|
|
3309
3409
|
*/ function makeKeyPairs(values, keyFn) {
|
|
3310
3410
|
return values.map(function(x) {
|
|
3311
3411
|
return [
|
|
@@ -3339,6 +3439,7 @@ function groupValues(values, groupKeyFn) {
|
|
|
3339
3439
|
var map = makeValuesGroupMap(values, groupKeyFn);
|
|
3340
3440
|
return mapToObject(map);
|
|
3341
3441
|
}
|
|
3442
|
+
// @__NO_SIDE_EFFECTS__
|
|
3342
3443
|
function makeValuesGroupMap(values, groupKeyFn) {
|
|
3343
3444
|
var map = new Map();
|
|
3344
3445
|
if (values != null) {
|
|
@@ -3471,8 +3572,15 @@ function _unsupported_iterable_to_array$s(o, minLen) {
|
|
|
3471
3572
|
/**
|
|
3472
3573
|
* Creates a KeyValueMapFactory that maps values by their key using a ReadKeyFunction.
|
|
3473
3574
|
*
|
|
3575
|
+
* @dbxUtil
|
|
3576
|
+
* @dbxUtilCategory value
|
|
3577
|
+
* @dbxUtilKind factory
|
|
3578
|
+
* @dbxUtilTags map, key, factory, lookup, index
|
|
3579
|
+
* @dbxUtilRelated multi-key-value-map-factory, read-keys-to-map
|
|
3580
|
+
*
|
|
3474
3581
|
* @param read - Function that extracts a key from each value
|
|
3475
3582
|
* @returns A factory that creates Maps from arrays of values
|
|
3583
|
+
* @__NO_SIDE_EFFECTS__
|
|
3476
3584
|
*/ function keyValueMapFactory(read) {
|
|
3477
3585
|
return function(values) {
|
|
3478
3586
|
var map = new Map();
|
|
@@ -3498,8 +3606,15 @@ function _unsupported_iterable_to_array$s(o, minLen) {
|
|
|
3498
3606
|
* Creates a KeyValueMapFactory that maps values by multiple keys using a ReadMultipleKeysFunction.
|
|
3499
3607
|
* Each value can appear under multiple keys.
|
|
3500
3608
|
*
|
|
3609
|
+
* @dbxUtil
|
|
3610
|
+
* @dbxUtilCategory value
|
|
3611
|
+
* @dbxUtilKind factory
|
|
3612
|
+
* @dbxUtilTags map, key, multi, factory, lookup, index
|
|
3613
|
+
* @dbxUtilRelated key-value-map-factory, read-multiple-keys-to-map
|
|
3614
|
+
*
|
|
3501
3615
|
* @param read - Function that extracts multiple keys from each value
|
|
3502
3616
|
* @returns A factory that creates Maps from arrays of values
|
|
3617
|
+
* @__NO_SIDE_EFFECTS__
|
|
3503
3618
|
*/ function multiKeyValueMapFactory(read) {
|
|
3504
3619
|
return function(values) {
|
|
3505
3620
|
var map = new Map();
|
|
@@ -3615,8 +3730,15 @@ function _unsupported_iterable_to_array$s(o, minLen) {
|
|
|
3615
3730
|
* Creates an {@link IsSelectedDecisionFunctionFactory} that produces decision functions
|
|
3616
3731
|
* checking whether a value's key is included in a set of selected values.
|
|
3617
3732
|
*
|
|
3733
|
+
* @dbxUtil
|
|
3734
|
+
* @dbxUtilCategory set
|
|
3735
|
+
* @dbxUtilKind factory
|
|
3736
|
+
* @dbxUtilTags set, selection, decision, predicate, factory, key
|
|
3737
|
+
* @dbxUtilRelated is-in-set-decision-function
|
|
3738
|
+
*
|
|
3618
3739
|
* @param config - Configuration with the key reader and default behavior.
|
|
3619
3740
|
* @returns A factory that creates decision functions from a set of selected keys.
|
|
3741
|
+
* @__NO_SIDE_EFFECTS__
|
|
3620
3742
|
*/ function isSelectedDecisionFunctionFactory(config) {
|
|
3621
3743
|
var readKey = config.readKey, _config_defaultIfKeyNull = config.defaultIfKeyNull, defaultIfKeyNull = _config_defaultIfKeyNull === void 0 ? false : _config_defaultIfKeyNull;
|
|
3622
3744
|
return function(selectedValues) {
|
|
@@ -3774,6 +3896,7 @@ function _unsupported_iterable_to_array$s(o, minLen) {
|
|
|
3774
3896
|
*
|
|
3775
3897
|
* @param x - The value to check.
|
|
3776
3898
|
* @returns Whether the value is a non-class function.
|
|
3899
|
+
* @__NO_SIDE_EFFECTS__
|
|
3777
3900
|
*/ // eslint-disable-next-line @typescript-eslint/no-unsafe-function-type
|
|
3778
3901
|
function isNonClassFunction(x) {
|
|
3779
3902
|
var type = getFunctionType(x);
|
|
@@ -3827,6 +3950,7 @@ function getValueFromGetter(input, args) {
|
|
|
3827
3950
|
* @param value - The object to copy
|
|
3828
3951
|
* @param copyFunction - Optional custom copy function (defaults to copyObject)
|
|
3829
3952
|
* @returns A factory that produces copies of the value
|
|
3953
|
+
* @__NO_SIDE_EFFECTS__
|
|
3830
3954
|
*/ function objectCopyFactory(value) {
|
|
3831
3955
|
var copyFunction = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : copyObject;
|
|
3832
3956
|
return function() {
|
|
@@ -3837,17 +3961,31 @@ function getValueFromGetter(input, args) {
|
|
|
3837
3961
|
* Converts the input to an ObjectCopyFactory. If the input is an object, wraps it with objectCopyFactory.
|
|
3838
3962
|
* If it's already a function (Getter), it's returned directly.
|
|
3839
3963
|
*
|
|
3964
|
+
* @dbxUtil
|
|
3965
|
+
* @dbxUtilCategory getter
|
|
3966
|
+
* @dbxUtilKind factory
|
|
3967
|
+
* @dbxUtilTags getter, factory, copy, clone, object, normalize
|
|
3968
|
+
* @dbxUtilRelated object-copy-factory, as-getter
|
|
3969
|
+
*
|
|
3840
3970
|
* @param input - An object value or a getter function
|
|
3841
3971
|
* @param copyFunction - Optional custom copy function
|
|
3842
3972
|
* @returns An ObjectCopyFactory for the input
|
|
3973
|
+
* @__NO_SIDE_EFFECTS__
|
|
3843
3974
|
*/ function asObjectCopyFactory(input, copyFunction) {
|
|
3844
3975
|
return (typeof input === "undefined" ? "undefined" : _type_of$j(input)) === 'object' ? objectCopyFactory(input, copyFunction) : asGetter(input);
|
|
3845
3976
|
}
|
|
3846
3977
|
/**
|
|
3847
3978
|
* Wraps the input value in a Getter function that always returns it.
|
|
3848
3979
|
*
|
|
3980
|
+
* @dbxUtil
|
|
3981
|
+
* @dbxUtilCategory getter
|
|
3982
|
+
* @dbxUtilKind factory
|
|
3983
|
+
* @dbxUtilTags getter, factory, wrap, constant
|
|
3984
|
+
* @dbxUtilRelated as-getter, get-value-from-getter
|
|
3985
|
+
*
|
|
3849
3986
|
* @param input - The value to wrap
|
|
3850
3987
|
* @returns A Getter that returns the input value
|
|
3988
|
+
* @__NO_SIDE_EFFECTS__
|
|
3851
3989
|
*/ function makeGetter(input) {
|
|
3852
3990
|
return function() {
|
|
3853
3991
|
return input;
|
|
@@ -3856,9 +3994,15 @@ function getValueFromGetter(input, args) {
|
|
|
3856
3994
|
/**
|
|
3857
3995
|
* Calls a factory function the specified number of times and returns the results as an array.
|
|
3858
3996
|
*
|
|
3997
|
+
* @dbxUtil
|
|
3998
|
+
* @dbxUtilCategory getter
|
|
3999
|
+
* @dbxUtilTags getter, factory, generate, array, count
|
|
4000
|
+
* @dbxUtilRelated make-with-factory-input, array-factory
|
|
4001
|
+
*
|
|
3859
4002
|
* @param factory - The factory function to call (receives the current index as argument)
|
|
3860
4003
|
* @param count - The number of items to create
|
|
3861
4004
|
* @returns An array of produced values
|
|
4005
|
+
* @__NO_SIDE_EFFECTS__
|
|
3862
4006
|
*/ function makeWithFactory(factory, count) {
|
|
3863
4007
|
var results = [];
|
|
3864
4008
|
for(var i = 0; i < count; i += 1){
|
|
@@ -3866,6 +4010,7 @@ function getValueFromGetter(input, args) {
|
|
|
3866
4010
|
}
|
|
3867
4011
|
return results;
|
|
3868
4012
|
}
|
|
4013
|
+
// @__NO_SIDE_EFFECTS__
|
|
3869
4014
|
function makeWithFactoryInput(factory, input) {
|
|
3870
4015
|
return input.map(function(x) {
|
|
3871
4016
|
return factory(x);
|
|
@@ -3875,8 +4020,15 @@ function makeWithFactoryInput(factory, input) {
|
|
|
3875
4020
|
* Wraps a factory so that no arguments are forwarded when it's called.
|
|
3876
4021
|
* Useful for protecting a factory from accidentally receiving arguments.
|
|
3877
4022
|
*
|
|
4023
|
+
* @dbxUtil
|
|
4024
|
+
* @dbxUtilCategory getter
|
|
4025
|
+
* @dbxUtilKind factory
|
|
4026
|
+
* @dbxUtilTags getter, factory, protect, wrap, no-args
|
|
4027
|
+
* @dbxUtilRelated as-getter, make-getter
|
|
4028
|
+
*
|
|
3878
4029
|
* @param factory - The factory to wrap
|
|
3879
4030
|
* @returns A new factory that calls the original with no arguments
|
|
4031
|
+
* @__NO_SIDE_EFFECTS__
|
|
3880
4032
|
*/ function protectedFactory(factory) {
|
|
3881
4033
|
return function() {
|
|
3882
4034
|
return factory();
|
|
@@ -3889,6 +4041,12 @@ function makeWithFactoryInput(factory, input) {
|
|
|
3889
4041
|
* @param config - Configuration with optional `startAt` (default 0) and `increaseBy` (default 1)
|
|
3890
4042
|
* @returns A factory function that returns the next number in the sequence on each call
|
|
3891
4043
|
*
|
|
4044
|
+
* @dbxUtil
|
|
4045
|
+
* @dbxUtilCategory number
|
|
4046
|
+
* @dbxUtilKind factory
|
|
4047
|
+
* @dbxUtilTags number, factory, increment, sequence, counter
|
|
4048
|
+
* @dbxUtilRelated random-number-factory
|
|
4049
|
+
*
|
|
3892
4050
|
* @example
|
|
3893
4051
|
* ```ts
|
|
3894
4052
|
* const factory = incrementingNumberFactory({ startAt: 10, increaseBy: 5 });
|
|
@@ -3896,6 +4054,7 @@ function makeWithFactoryInput(factory, input) {
|
|
|
3896
4054
|
* factory(); // 15
|
|
3897
4055
|
* factory(); // 20
|
|
3898
4056
|
* ```
|
|
4057
|
+
* @__NO_SIDE_EFFECTS__
|
|
3899
4058
|
*/ function incrementingNumberFactory() {
|
|
3900
4059
|
var config = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
3901
4060
|
var initial = config.startAt, inputIncreaseBy = config.increaseBy;
|
|
@@ -3929,6 +4088,7 @@ function makeWithFactoryInput(factory, input) {
|
|
|
3929
4088
|
* @param bounds - The min/max bounds to test against
|
|
3930
4089
|
* @returns A function that returns `true` if the input number is within bounds
|
|
3931
4090
|
* @throws Error if the bounds are invalid (min > max)
|
|
4091
|
+
* @__NO_SIDE_EFFECTS__
|
|
3932
4092
|
*/ function isInNumberBoundFunction(bounds) {
|
|
3933
4093
|
var min = bounds.min, max = bounds.max;
|
|
3934
4094
|
if (!isValidNumberBound(bounds)) {
|
|
@@ -3951,6 +4111,7 @@ function makeWithFactoryInput(factory, input) {
|
|
|
3951
4111
|
*
|
|
3952
4112
|
* @param wrapNumberFunctionConfig - Configuration with min, max, and optional fence post behavior
|
|
3953
4113
|
* @returns A function that wraps input numbers into the bounded range
|
|
4114
|
+
* @__NO_SIDE_EFFECTS__
|
|
3954
4115
|
*/ function wrapNumberFunction(wrapNumberFunctionConfig) {
|
|
3955
4116
|
var min = wrapNumberFunctionConfig.min, max = wrapNumberFunctionConfig.max, _wrapNumberFunctionConfig_fencePosts = wrapNumberFunctionConfig.fencePosts, fencePosts = _wrapNumberFunctionConfig_fencePosts === void 0 ? false : _wrapNumberFunctionConfig_fencePosts;
|
|
3956
4117
|
var distance = max - min;
|
|
@@ -3982,6 +4143,7 @@ function makeWithFactoryInput(factory, input) {
|
|
|
3982
4143
|
*
|
|
3983
4144
|
* @param boundNumberFunctionConfig - Configuration with min, max, and optional wrap behavior
|
|
3984
4145
|
* @returns A function that bounds input numbers into the configured range
|
|
4146
|
+
* @__NO_SIDE_EFFECTS__
|
|
3985
4147
|
*/ function boundNumberFunction(boundNumberFunctionConfig) {
|
|
3986
4148
|
var min = boundNumberFunctionConfig.min, max = boundNumberFunctionConfig.max, wrap = boundNumberFunctionConfig.wrap;
|
|
3987
4149
|
return wrap ? wrapNumberFunction(boundNumberFunctionConfig) : function(input) {
|
|
@@ -4205,6 +4367,7 @@ function _type_of$h(obj) {
|
|
|
4205
4367
|
*
|
|
4206
4368
|
* @param type - The rounding strategy: 'floor', 'ceil', 'round', or 'none'
|
|
4207
4369
|
* @returns The corresponding Math function, or an identity function for 'none'
|
|
4370
|
+
* @__NO_SIDE_EFFECTS__
|
|
4208
4371
|
*/ function roundingFunction(type) {
|
|
4209
4372
|
var fn;
|
|
4210
4373
|
switch(type){
|
|
@@ -4261,9 +4424,16 @@ function _type_of$h(obj) {
|
|
|
4261
4424
|
/**
|
|
4262
4425
|
* Creates a {@link CutValueToPrecisionFunction} that truncates values to the configured precision.
|
|
4263
4426
|
*
|
|
4427
|
+
* @dbxUtil
|
|
4428
|
+
* @dbxUtilCategory number
|
|
4429
|
+
* @dbxUtilKind factory
|
|
4430
|
+
* @dbxUtilTags number, precision, cut, truncate, factory, round
|
|
4431
|
+
* @dbxUtilRelated round-to-precision-function, cut-to-precision
|
|
4432
|
+
*
|
|
4264
4433
|
* @param precision - Number of decimal places to retain
|
|
4265
4434
|
* @param roundingType - Rounding strategy; defaults to 'cut' (truncation)
|
|
4266
4435
|
* @returns A function that accepts a number or string and returns the truncated number
|
|
4436
|
+
* @__NO_SIDE_EFFECTS__
|
|
4267
4437
|
*/ function cutValueToPrecisionFunction(precision) {
|
|
4268
4438
|
var roundingType = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 'cut';
|
|
4269
4439
|
var roundFn = roundToPrecisionFunction(precision, roundingType);
|
|
@@ -4276,9 +4446,16 @@ function _type_of$h(obj) {
|
|
|
4276
4446
|
/**
|
|
4277
4447
|
* Creates a function that rounds numbers to the specified precision using a configurable rounding strategy.
|
|
4278
4448
|
*
|
|
4449
|
+
* @dbxUtil
|
|
4450
|
+
* @dbxUtilCategory number
|
|
4451
|
+
* @dbxUtilKind factory
|
|
4452
|
+
* @dbxUtilTags number, round, precision, factory, decimals
|
|
4453
|
+
* @dbxUtilRelated cut-value-to-precision-function, round-to-precision, cut-to-precision
|
|
4454
|
+
*
|
|
4279
4455
|
* @param precision - Number of decimal places
|
|
4280
4456
|
* @param roundFn - Rounding strategy; defaults to 'round'. Use 'cut' for truncation.
|
|
4281
4457
|
* @returns A function that rounds numbers to the configured precision
|
|
4458
|
+
* @__NO_SIDE_EFFECTS__
|
|
4282
4459
|
*/ function roundToPrecisionFunction(precision) {
|
|
4283
4460
|
var roundFn = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : 'round';
|
|
4284
4461
|
var result;
|
|
@@ -4331,9 +4508,16 @@ function _type_of$h(obj) {
|
|
|
4331
4508
|
*
|
|
4332
4509
|
* Accepts either a step number (uses 'ceil' rounding) or a full config with step, rounding type, and origin.
|
|
4333
4510
|
*
|
|
4511
|
+
* @dbxUtil
|
|
4512
|
+
* @dbxUtilCategory number
|
|
4513
|
+
* @dbxUtilKind factory
|
|
4514
|
+
* @dbxUtilTags number, round, step, factory, multiple, origin
|
|
4515
|
+
* @dbxUtilRelated round-number-up-to-step, round-to-precision-function
|
|
4516
|
+
*
|
|
4334
4517
|
* @param input - Step size or full configuration
|
|
4335
4518
|
* @returns A function that rounds input numbers to the nearest step
|
|
4336
4519
|
* @throws Error if step is 0 or undefined
|
|
4520
|
+
* @__NO_SIDE_EFFECTS__
|
|
4337
4521
|
*/ function roundNumberToStepFunction(input) {
|
|
4338
4522
|
var config = typeof input === 'number' ? {
|
|
4339
4523
|
step: input,
|
|
@@ -4385,8 +4569,15 @@ var DOLLAR_AMOUNT_STRING_REGEX = /^\$?(\d+)\.?(\d\d)$/;
|
|
|
4385
4569
|
/**
|
|
4386
4570
|
* Creates a function that formats dollar amounts as strings with a unit prefix (e.g., "$12.50").
|
|
4387
4571
|
*
|
|
4572
|
+
* @dbxUtil
|
|
4573
|
+
* @dbxUtilCategory number
|
|
4574
|
+
* @dbxUtilKind factory
|
|
4575
|
+
* @dbxUtilTags number, dollar, currency, format, factory, unit
|
|
4576
|
+
* @dbxUtilRelated dollar-amount-string
|
|
4577
|
+
*
|
|
4388
4578
|
* @param unit - The unit prefix to prepend; defaults to "$"
|
|
4389
4579
|
* @returns A function that formats dollar amounts with the configured unit
|
|
4580
|
+
* @__NO_SIDE_EFFECTS__
|
|
4390
4581
|
*/ function dollarAmountStringWithUnitFunction() {
|
|
4391
4582
|
var unit = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : '$';
|
|
4392
4583
|
var fn = function fn(amount) {
|
|
@@ -4410,6 +4601,7 @@ var DOLLAR_AMOUNT_STRING_REGEX = /^\$?(\d+)\.?(\d\d)$/;
|
|
|
4410
4601
|
* @param maxOrArgs - Maximum value (exclusive) or full configuration object
|
|
4411
4602
|
* @param roundingInput - Optional rounding mode override
|
|
4412
4603
|
* @returns A factory function that produces random numbers within the range
|
|
4604
|
+
* @__NO_SIDE_EFFECTS__
|
|
4413
4605
|
*/ function randomNumberFactory(maxOrArgs, roundingInput) {
|
|
4414
4606
|
var config = typeof maxOrArgs === 'number' ? {
|
|
4415
4607
|
min: 0,
|
|
@@ -4455,8 +4647,15 @@ var DOLLAR_AMOUNT_STRING_REGEX = /^\$?(\d+)\.?(\d\d)$/;
|
|
|
4455
4647
|
/**
|
|
4456
4648
|
* Creates a {@link SortCompareFunction} that sorts values in ascending order by a numeric property.
|
|
4457
4649
|
*
|
|
4650
|
+
* @dbxUtil
|
|
4651
|
+
* @dbxUtilCategory number
|
|
4652
|
+
* @dbxUtilKind factory
|
|
4653
|
+
* @dbxUtilTags number, sort, compare, ascending, factory
|
|
4654
|
+
* @dbxUtilRelated sort-numbers-ascending-function, sort-by-string-function
|
|
4655
|
+
*
|
|
4458
4656
|
* @param readNumberFn - Function that extracts the numeric value from each item
|
|
4459
4657
|
* @returns A sort comparator function for ascending numeric order
|
|
4658
|
+
* @__NO_SIDE_EFFECTS__
|
|
4460
4659
|
*/ function sortByNumberFunction(readNumberFn) {
|
|
4461
4660
|
return function(a, b) {
|
|
4462
4661
|
var as = readNumberFn(a);
|
|
@@ -4487,8 +4686,15 @@ var DOLLAR_AMOUNT_STRING_REGEX = /^\$?(\d+)\.?(\d\d)$/;
|
|
|
4487
4686
|
*
|
|
4488
4687
|
* Chains the configured operations in order: custom transform, step rounding, precision cut, then bounds clamping.
|
|
4489
4688
|
*
|
|
4689
|
+
* @dbxUtil
|
|
4690
|
+
* @dbxUtilCategory number
|
|
4691
|
+
* @dbxUtilKind factory
|
|
4692
|
+
* @dbxUtilTags number, transform, factory, round, precision, bounds, chain
|
|
4693
|
+
* @dbxUtilRelated transform-string-function, round-number-to-step-function
|
|
4694
|
+
*
|
|
4490
4695
|
* @param config - Configuration with optional transform, roundToStep, precision, and bounds
|
|
4491
4696
|
* @returns A single function that applies all configured transformations in sequence
|
|
4697
|
+
* @__NO_SIDE_EFFECTS__
|
|
4492
4698
|
*/ function transformNumberFunction(config) {
|
|
4493
4699
|
var transformFunctions = [
|
|
4494
4700
|
config.transform
|
|
@@ -4716,12 +4922,19 @@ function reduceNumbersFn(reduceFn, emptyArrayValue) {
|
|
|
4716
4922
|
*
|
|
4717
4923
|
* @returns a compare function suitable for Array.sort()
|
|
4718
4924
|
*
|
|
4925
|
+
* @dbxUtil
|
|
4926
|
+
* @dbxUtilCategory value
|
|
4927
|
+
* @dbxUtilKind factory
|
|
4928
|
+
* @dbxUtilTags value, index, sort, ascending, factory, ref
|
|
4929
|
+
* @dbxUtilRelated sort-by-index-ascending-compare-function, sort-by-index-range-ascending-compare-function
|
|
4930
|
+
*
|
|
4719
4931
|
* @example
|
|
4720
4932
|
* ```ts
|
|
4721
4933
|
* const items = [{ i: 4 }, { i: 0 }, { i: 2 }];
|
|
4722
4934
|
* items.sort(sortAscendingIndexNumberRefFunction());
|
|
4723
4935
|
* // items[0].i === 0
|
|
4724
4936
|
* ```
|
|
4937
|
+
* @__NO_SIDE_EFFECTS__
|
|
4725
4938
|
*/ function sortAscendingIndexNumberRefFunction() {
|
|
4726
4939
|
return function(a, b) {
|
|
4727
4940
|
return a.i - b.i;
|
|
@@ -4743,6 +4956,12 @@ function reduceNumbersFn(reduceFn, emptyArrayValue) {
|
|
|
4743
4956
|
* @param readIndex - reads an item's index, returning null/undefined for unindexed items
|
|
4744
4957
|
* @returns a function that groups items by their index state
|
|
4745
4958
|
*
|
|
4959
|
+
* @dbxUtil
|
|
4960
|
+
* @dbxUtilCategory value
|
|
4961
|
+
* @dbxUtilKind factory
|
|
4962
|
+
* @dbxUtilTags value, index, delta, group, factory, classify
|
|
4963
|
+
* @dbxUtilRelated separate-values, compute-next-free-index-function
|
|
4964
|
+
*
|
|
4746
4965
|
* @example
|
|
4747
4966
|
* ```ts
|
|
4748
4967
|
* const groupFn = indexDeltaGroupFunction<{ x: string; i?: number }>((x) => x.i);
|
|
@@ -4751,6 +4970,7 @@ function reduceNumbersFn(reduceFn, emptyArrayValue) {
|
|
|
4751
4970
|
* // result.newItems.length === 1 (item without an index)
|
|
4752
4971
|
* // result.currentItems.length === 2 (items with indexes)
|
|
4753
4972
|
* ```
|
|
4973
|
+
* @__NO_SIDE_EFFECTS__
|
|
4754
4974
|
*/ function indexDeltaGroupFunction(readIndex) {
|
|
4755
4975
|
return function(inputItems, previousItems) {
|
|
4756
4976
|
var _separateValues = separateValues(inputItems, function(x) {
|
|
@@ -4788,8 +5008,15 @@ function reduceNumbersFn(reduceFn, emptyArrayValue) {
|
|
|
4788
5008
|
/**
|
|
4789
5009
|
* Creates a SortCompareFunction that sorts items in ascending order using a custom index reader.
|
|
4790
5010
|
*
|
|
5011
|
+
* @dbxUtil
|
|
5012
|
+
* @dbxUtilCategory value
|
|
5013
|
+
* @dbxUtilKind factory
|
|
5014
|
+
* @dbxUtilTags value, index, sort, ascending, factory, compare
|
|
5015
|
+
* @dbxUtilRelated sort-ascending-index-number-ref-function, sort-by-index-range-ascending-compare-function
|
|
5016
|
+
*
|
|
4791
5017
|
* @param readIndex - extracts the index number from each item
|
|
4792
5018
|
* @returns a compare function suitable for Array.sort()
|
|
5019
|
+
* @__NO_SIDE_EFFECTS__
|
|
4793
5020
|
*/ function sortByIndexAscendingCompareFunction(readIndex) {
|
|
4794
5021
|
return function(a, b) {
|
|
4795
5022
|
return readIndex(a) - readIndex(b);
|
|
@@ -4803,12 +5030,19 @@ function reduceNumbersFn(reduceFn, emptyArrayValue) {
|
|
|
4803
5030
|
* @param nextIndex - optional custom function to compute the next index from the max item; defaults to max + 1
|
|
4804
5031
|
* @returns a function that computes the next free index for a given array
|
|
4805
5032
|
*
|
|
5033
|
+
* @dbxUtil
|
|
5034
|
+
* @dbxUtilCategory value
|
|
5035
|
+
* @dbxUtilKind factory
|
|
5036
|
+
* @dbxUtilTags value, index, free, next, factory, max
|
|
5037
|
+
* @dbxUtilRelated compute-next-free-index-on-sorted-values-function, min-and-max-index-function
|
|
5038
|
+
*
|
|
4806
5039
|
* @example
|
|
4807
5040
|
* ```ts
|
|
4808
5041
|
* const fn = computeNextFreeIndexFunction<IndexRef>((x) => x.i);
|
|
4809
5042
|
* const nextIndex = fn([{ i: 0 }, { i: 1 }, { i: 5 }]);
|
|
4810
5043
|
* // nextIndex === 6
|
|
4811
5044
|
* ```
|
|
5045
|
+
* @__NO_SIDE_EFFECTS__
|
|
4812
5046
|
*/ function computeNextFreeIndexFunction(readIndex, nextIndex) {
|
|
4813
5047
|
var findMinMax = minAndMaxIndexItemsFunction(readIndex);
|
|
4814
5048
|
var readNextIndex = nextIndex !== null && nextIndex !== void 0 ? nextIndex : function(x) {
|
|
@@ -4824,9 +5058,16 @@ function reduceNumbersFn(reduceFn, emptyArrayValue) {
|
|
|
4824
5058
|
* Creates a {@link ComputeNextFreeIndexFunction} optimized for pre-sorted input arrays.
|
|
4825
5059
|
* Instead of scanning all items for the maximum, it reads only the last element.
|
|
4826
5060
|
*
|
|
5061
|
+
* @dbxUtil
|
|
5062
|
+
* @dbxUtilCategory value
|
|
5063
|
+
* @dbxUtilKind factory
|
|
5064
|
+
* @dbxUtilTags value, index, free, next, sorted, factory, optimized
|
|
5065
|
+
* @dbxUtilRelated compute-next-free-index-function
|
|
5066
|
+
*
|
|
4827
5067
|
* @param readIndex - extracts the index number from each item
|
|
4828
5068
|
* @param nextIndex - optional custom function to compute the next index from the last item; defaults to last + 1
|
|
4829
5069
|
* @returns a function that computes the next free index from sorted arrays
|
|
5070
|
+
* @__NO_SIDE_EFFECTS__
|
|
4830
5071
|
*/ function computeNextFreeIndexOnSortedValuesFunction(readIndex, nextIndex) {
|
|
4831
5072
|
var readNextIndex = nextIndex !== null && nextIndex !== void 0 ? nextIndex : function(x) {
|
|
4832
5073
|
return readIndex(x) + 1;
|
|
@@ -4842,12 +5083,19 @@ function reduceNumbersFn(reduceFn, emptyArrayValue) {
|
|
|
4842
5083
|
* @param readIndex - extracts the index number from each item
|
|
4843
5084
|
* @returns a function returning the min/max indexes, or null for empty input
|
|
4844
5085
|
*
|
|
5086
|
+
* @dbxUtil
|
|
5087
|
+
* @dbxUtilCategory value
|
|
5088
|
+
* @dbxUtilKind factory
|
|
5089
|
+
* @dbxUtilTags value, index, min, max, factory, range
|
|
5090
|
+
* @dbxUtilRelated min-and-max-index, min-and-max-index-items-function
|
|
5091
|
+
*
|
|
4845
5092
|
* @example
|
|
4846
5093
|
* ```ts
|
|
4847
5094
|
* const fn = minAndMaxIndexFunction<IndexRef>((x) => x.i);
|
|
4848
5095
|
* const result = fn([{ i: 3 }, { i: 0 }, { i: 5 }]);
|
|
4849
5096
|
* // result?.min === 0, result?.max === 5
|
|
4850
5097
|
* ```
|
|
5098
|
+
* @__NO_SIDE_EFFECTS__
|
|
4851
5099
|
*/ function minAndMaxIndexFunction(readIndex) {
|
|
4852
5100
|
var minAndMaxItems = minAndMaxIndexItemsFunction(readIndex);
|
|
4853
5101
|
var fn = function fn(values) {
|
|
@@ -4873,8 +5121,15 @@ function reduceNumbersFn(reduceFn, emptyArrayValue) {
|
|
|
4873
5121
|
* Creates a {@link MinAndMaxIndexItemsFunction} that returns the actual items (not just index numbers)
|
|
4874
5122
|
* with the minimum and maximum index values.
|
|
4875
5123
|
*
|
|
5124
|
+
* @dbxUtil
|
|
5125
|
+
* @dbxUtilCategory value
|
|
5126
|
+
* @dbxUtilKind factory
|
|
5127
|
+
* @dbxUtilTags value, index, min, max, items, factory
|
|
5128
|
+
* @dbxUtilRelated min-and-max-index-function, min-and-max-function
|
|
5129
|
+
*
|
|
4876
5130
|
* @param readIndex - extracts the index number from each item
|
|
4877
5131
|
* @returns a function returning the min/max items, or null for empty input
|
|
5132
|
+
* @__NO_SIDE_EFFECTS__
|
|
4878
5133
|
*/ function minAndMaxIndexItemsFunction(readIndex) {
|
|
4879
5134
|
var fn = minAndMaxFunction(readIndex);
|
|
4880
5135
|
fn._readIndex = readIndex;
|
|
@@ -4929,6 +5184,14 @@ function reduceNumbersFn(reduceFn, emptyArrayValue) {
|
|
|
4929
5184
|
* fn({ i: 6 }); // returns { i: 5 }
|
|
4930
5185
|
* fn({ i: 11 }); // returns { i: 10 }
|
|
4931
5186
|
* ```
|
|
5187
|
+
*
|
|
5188
|
+
* @dbxUtil
|
|
5189
|
+
* @dbxUtilCategory value
|
|
5190
|
+
* @dbxUtilKind factory
|
|
5191
|
+
* @dbxUtilTags value, index, match, find, factory, lookup
|
|
5192
|
+
* @dbxUtilRelated find-best-index-match, safe-find-best-index-match
|
|
5193
|
+
*
|
|
5194
|
+
* @__NO_SIDE_EFFECTS__
|
|
4932
5195
|
*/ function findBestIndexMatchFunction(items) {
|
|
4933
5196
|
// reverse the order so we can return the first item that is less than or equal to the input i
|
|
4934
5197
|
var bestMatchArray = iterableToArray(items, false).sort(reverseCompareFn(sortAscendingIndexNumberRefFunction()));
|
|
@@ -4979,8 +5242,15 @@ function reduceNumbersFn(reduceFn, emptyArrayValue) {
|
|
|
4979
5242
|
* Creates a SortCompareFunction that sorts items by their IndexRange in ascending order.
|
|
4980
5243
|
* Sorts by minIndex first, then by maxIndex for items with equal minIndex values.
|
|
4981
5244
|
*
|
|
5245
|
+
* @dbxUtil
|
|
5246
|
+
* @dbxUtilCategory value
|
|
5247
|
+
* @dbxUtilKind factory
|
|
5248
|
+
* @dbxUtilTags value, index-range, sort, ascending, factory, compare
|
|
5249
|
+
* @dbxUtilRelated sort-by-index-ascending-compare-function, index-range-reader-pair-factory
|
|
5250
|
+
*
|
|
4982
5251
|
* @param readIndexRange - extracts the IndexRange from each item
|
|
4983
5252
|
* @returns a compare function suitable for Array.sort()
|
|
5253
|
+
* @__NO_SIDE_EFFECTS__
|
|
4984
5254
|
*/ function sortByIndexRangeAscendingCompareFunction(readIndexRange) {
|
|
4985
5255
|
return function(a, b) {
|
|
4986
5256
|
var ra = readIndexRange(a);
|
|
@@ -4992,8 +5262,15 @@ function reduceNumbersFn(reduceFn, emptyArrayValue) {
|
|
|
4992
5262
|
/**
|
|
4993
5263
|
* Creates a new {@link IndexRangeReaderPairFactory} that pairs each value with its computed IndexRange.
|
|
4994
5264
|
*
|
|
5265
|
+
* @dbxUtil
|
|
5266
|
+
* @dbxUtilCategory value
|
|
5267
|
+
* @dbxUtilKind factory
|
|
5268
|
+
* @dbxUtilTags value, index-range, pair, factory, reader
|
|
5269
|
+
* @dbxUtilRelated sort-by-index-range-ascending-compare-function
|
|
5270
|
+
*
|
|
4995
5271
|
* @param reader - reads the IndexRange from the input value
|
|
4996
5272
|
* @returns a factory that creates IndexRangeReaderPair instances
|
|
5273
|
+
* @__NO_SIDE_EFFECTS__
|
|
4997
5274
|
*/ function indexRangeReaderPairFactory(reader) {
|
|
4998
5275
|
return function(value) {
|
|
4999
5276
|
var range = reader(value);
|
|
@@ -5018,8 +5295,15 @@ function reduceNumbersFn(reduceFn, emptyArrayValue) {
|
|
|
5018
5295
|
/**
|
|
5019
5296
|
* Creates a {@link FitToIndexRangeFunction} that clamps index numbers to the given range boundaries.
|
|
5020
5297
|
*
|
|
5298
|
+
* @dbxUtil
|
|
5299
|
+
* @dbxUtilCategory value
|
|
5300
|
+
* @dbxUtilKind factory
|
|
5301
|
+
* @dbxUtilTags value, index, clamp, range, factory, fit
|
|
5302
|
+
* @dbxUtilRelated wrap-index-range-function, bound-number-function
|
|
5303
|
+
*
|
|
5021
5304
|
* @param input - the range to clamp to
|
|
5022
5305
|
* @returns a function that clamps any index to the range
|
|
5306
|
+
* @__NO_SIDE_EFFECTS__
|
|
5023
5307
|
*/ function fitToIndexRangeFunction(input) {
|
|
5024
5308
|
var min = input.minIndex, maxIndex = input.maxIndex;
|
|
5025
5309
|
var max = maxIndex - 1;
|
|
@@ -5037,12 +5321,19 @@ function reduceNumbersFn(reduceFn, emptyArrayValue) {
|
|
|
5037
5321
|
* @param fencePosts - whether to use fencepost semantics (maxIndex is exclusive); defaults to true
|
|
5038
5322
|
* @returns a function that wraps any index into the range
|
|
5039
5323
|
*
|
|
5324
|
+
* @dbxUtil
|
|
5325
|
+
* @dbxUtilCategory value
|
|
5326
|
+
* @dbxUtilKind factory
|
|
5327
|
+
* @dbxUtilTags value, index, wrap, range, factory, modular
|
|
5328
|
+
* @dbxUtilRelated fit-to-index-range-function, wrap-number-function
|
|
5329
|
+
*
|
|
5040
5330
|
* @example
|
|
5041
5331
|
* ```ts
|
|
5042
5332
|
* const wrap = wrapIndexRangeFunction({ minIndex: 0, maxIndex: 6 });
|
|
5043
5333
|
* wrap(6); // 0 (wraps from positive side)
|
|
5044
5334
|
* wrap(-1); // 5 (wraps from negative side)
|
|
5045
5335
|
* ```
|
|
5336
|
+
* @__NO_SIDE_EFFECTS__
|
|
5046
5337
|
*/ function wrapIndexRangeFunction(input) {
|
|
5047
5338
|
var fencePosts = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
|
|
5048
5339
|
var min = input.minIndex, maxIndex = input.maxIndex;
|
|
@@ -5053,6 +5344,7 @@ function reduceNumbersFn(reduceFn, emptyArrayValue) {
|
|
|
5053
5344
|
fencePosts: fencePosts
|
|
5054
5345
|
});
|
|
5055
5346
|
}
|
|
5347
|
+
// @__NO_SIDE_EFFECTS__
|
|
5056
5348
|
function indexRangeCheckReaderFunction(input) {
|
|
5057
5349
|
var read = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : function(x) {
|
|
5058
5350
|
return x.i;
|
|
@@ -5090,8 +5382,15 @@ function indexRangeCheckFunctionConfigToIndexRange(param) {
|
|
|
5090
5382
|
* Creates an {@link IndexRangeCheckFunction} that tests whether an index number falls within the configured range.
|
|
5091
5383
|
* The min is inclusive and the max is exclusive by default unless `inclusiveMaxIndex` is set.
|
|
5092
5384
|
*
|
|
5385
|
+
* @dbxUtil
|
|
5386
|
+
* @dbxUtilCategory value
|
|
5387
|
+
* @dbxUtilKind factory
|
|
5388
|
+
* @dbxUtilTags value, index, range, check, factory, predicate
|
|
5389
|
+
* @dbxUtilRelated index-range-check-reader-function, is-index-number-in-index-range-function
|
|
5390
|
+
*
|
|
5093
5391
|
* @param input - the range or range config to check against
|
|
5094
5392
|
* @returns a predicate function for index numbers
|
|
5393
|
+
* @__NO_SIDE_EFFECTS__
|
|
5095
5394
|
*/ function indexRangeCheckFunction(input) {
|
|
5096
5395
|
var _indexRangeCheckFunctionConfigToIndexRange = indexRangeCheckFunctionConfigToIndexRange(asIndexRangeCheckFunctionConfig(input)), minIndex = _indexRangeCheckFunctionConfigToIndexRange.minIndex, maxIndex = _indexRangeCheckFunctionConfigToIndexRange.maxIndex;
|
|
5097
5396
|
return function(i) {
|
|
@@ -5115,8 +5414,15 @@ function indexRangeCheckFunctionConfigToIndexRange(param) {
|
|
|
5115
5414
|
/**
|
|
5116
5415
|
* Creates an {@link IsIndexNumberInIndexRangeFunction} bound to the given range configuration.
|
|
5117
5416
|
*
|
|
5417
|
+
* @dbxUtil
|
|
5418
|
+
* @dbxUtilCategory value
|
|
5419
|
+
* @dbxUtilKind factory
|
|
5420
|
+
* @dbxUtilTags value, index, range, check, factory, predicate
|
|
5421
|
+
* @dbxUtilRelated is-index-number-in-index-range, index-range-check-function
|
|
5422
|
+
*
|
|
5118
5423
|
* @param input - the range or range config to bind
|
|
5119
5424
|
* @returns a predicate that tests index numbers against the bound range
|
|
5425
|
+
* @__NO_SIDE_EFFECTS__
|
|
5120
5426
|
*/ function isIndexNumberInIndexRangeFunction(input) {
|
|
5121
5427
|
var _indexRangeCheckFunctionConfigToIndexRange = indexRangeCheckFunctionConfigToIndexRange(asIndexRangeCheckFunctionConfig(input)), minIndex = _indexRangeCheckFunctionConfigToIndexRange.minIndex, maxIndex = _indexRangeCheckFunctionConfigToIndexRange.maxIndex;
|
|
5122
5428
|
return function(index) {
|
|
@@ -5135,8 +5441,15 @@ function indexRangeCheckFunctionConfigToIndexRange(param) {
|
|
|
5135
5441
|
/**
|
|
5136
5442
|
* Creates an {@link IsIndexRangeInIndexRangeFunction} bound to the given range configuration.
|
|
5137
5443
|
*
|
|
5444
|
+
* @dbxUtil
|
|
5445
|
+
* @dbxUtilCategory value
|
|
5446
|
+
* @dbxUtilKind factory
|
|
5447
|
+
* @dbxUtilTags value, index-range, contains, decision, factory, predicate
|
|
5448
|
+
* @dbxUtilRelated is-index-range-in-index-range, index-range-overlaps-index-range-function
|
|
5449
|
+
*
|
|
5138
5450
|
* @param input - the bounding range or range config to bind
|
|
5139
5451
|
* @returns a predicate that tests whether index ranges are fully contained
|
|
5452
|
+
* @__NO_SIDE_EFFECTS__
|
|
5140
5453
|
*/ function isIndexRangeInIndexRangeFunction(input) {
|
|
5141
5454
|
var _indexRangeCheckFunctionConfigToIndexRange = indexRangeCheckFunctionConfigToIndexRange(asIndexRangeCheckFunctionConfig(input)), minIndex = _indexRangeCheckFunctionConfigToIndexRange.minIndex, maxIndex = _indexRangeCheckFunctionConfigToIndexRange.maxIndex;
|
|
5142
5455
|
return function(input) {
|
|
@@ -5155,8 +5468,15 @@ function indexRangeCheckFunctionConfigToIndexRange(param) {
|
|
|
5155
5468
|
/**
|
|
5156
5469
|
* Creates an {@link IndexRangeOverlapsIndexRangeFunction} bound to the given range configuration.
|
|
5157
5470
|
*
|
|
5471
|
+
* @dbxUtil
|
|
5472
|
+
* @dbxUtilCategory value
|
|
5473
|
+
* @dbxUtilKind factory
|
|
5474
|
+
* @dbxUtilTags value, index-range, overlap, decision, factory, predicate
|
|
5475
|
+
* @dbxUtilRelated is-index-range-in-index-range-function, index-range-check-function
|
|
5476
|
+
*
|
|
5158
5477
|
* @param input - the reference range or range config to bind
|
|
5159
5478
|
* @returns a predicate that tests for overlap with the bound range
|
|
5479
|
+
* @__NO_SIDE_EFFECTS__
|
|
5160
5480
|
*/ function indexRangeOverlapsIndexRangeFunction(input) {
|
|
5161
5481
|
var _indexRangeCheckFunctionConfigToIndexRange = indexRangeCheckFunctionConfigToIndexRange(asIndexRangeCheckFunctionConfig(input)), minIndex = _indexRangeCheckFunctionConfigToIndexRange.minIndex, maxIndex = _indexRangeCheckFunctionConfigToIndexRange.maxIndex;
|
|
5162
5482
|
return function(input) {
|
|
@@ -5175,8 +5495,15 @@ function indexRangeCheckFunctionConfigToIndexRange(param) {
|
|
|
5175
5495
|
* Creates a {@link StepsFromIndexFunction} that computes the next index after stepping from a start position.
|
|
5176
5496
|
* Returns undefined when the result falls outside the range (unless wrapping or fitting is enabled).
|
|
5177
5497
|
*
|
|
5498
|
+
* @dbxUtil
|
|
5499
|
+
* @dbxUtilCategory value
|
|
5500
|
+
* @dbxUtilKind factory
|
|
5501
|
+
* @dbxUtilTags value, index, step, range, factory, wrap, navigation
|
|
5502
|
+
* @dbxUtilRelated wrap-index-range-function, fit-to-index-range-function
|
|
5503
|
+
*
|
|
5178
5504
|
* @param config - stepping behavior configuration
|
|
5179
5505
|
* @returns a function that computes the stepped index
|
|
5506
|
+
* @__NO_SIDE_EFFECTS__
|
|
5180
5507
|
*/ function stepsFromIndexFunction(config) {
|
|
5181
5508
|
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
5509
|
var wrapNumber = wrapIndexRangeFunction(range, fencePosts);
|
|
@@ -5316,8 +5643,15 @@ function stepsFromIndex(range, startIndex) {
|
|
|
5316
5643
|
/**
|
|
5317
5644
|
* Creates a {@link SliceIndexRangeFunction} that slices the specified index range from any input array.
|
|
5318
5645
|
*
|
|
5646
|
+
* @dbxUtil
|
|
5647
|
+
* @dbxUtilCategory array
|
|
5648
|
+
* @dbxUtilKind factory
|
|
5649
|
+
* @dbxUtilTags array, slice, index, range, factory
|
|
5650
|
+
* @dbxUtilRelated index-range, find-to-index-set
|
|
5651
|
+
*
|
|
5319
5652
|
* @param inputRange - the index range configuration to use for slicing
|
|
5320
5653
|
* @returns a function that slices the configured range from an input array
|
|
5654
|
+
* @__NO_SIDE_EFFECTS__
|
|
5321
5655
|
*/ function sliceIndexRangeFunction(inputRange) {
|
|
5322
5656
|
var range = indexRange(inputRange);
|
|
5323
5657
|
return function(input) {
|
|
@@ -5329,15 +5663,39 @@ function stepsFromIndex(range, startIndex) {
|
|
|
5329
5663
|
* Filters the input values by distance while maintaining the original order of elements.
|
|
5330
5664
|
* Values that are too close to each other (based on the minDistance parameter) will be filtered out.
|
|
5331
5665
|
*
|
|
5666
|
+
* Items whose extracted value is null are excluded from the result.
|
|
5667
|
+
*
|
|
5332
5668
|
* If order is irrelevant, use filterValuesByDistanceNoOrder() instead.
|
|
5333
5669
|
*
|
|
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
|
-
|
|
5670
|
+
* @param input - The array of values to filter
|
|
5671
|
+
* @param minDistance - The minimum distance required between values (inclusive)
|
|
5672
|
+
* @param getValue - Function that extracts a numeric value from each item for distance comparison
|
|
5673
|
+
* @returns A filtered array with only values that are at least minDistance apart, in their original input order
|
|
5674
|
+
*/ function filterValuesByDistance(input, minDistance, getValue) {
|
|
5675
|
+
// Tag each non-null value with its original index so we can restore order after the distance filter.
|
|
5676
|
+
var tagged = [];
|
|
5677
|
+
for(var i = 0, n = input.length; i < n; i += 1){
|
|
5678
|
+
var item = input[i];
|
|
5679
|
+
var value = getValue(item);
|
|
5680
|
+
if (value != null) {
|
|
5681
|
+
tagged.push([
|
|
5682
|
+
{
|
|
5683
|
+
item: item,
|
|
5684
|
+
index: i
|
|
5685
|
+
},
|
|
5686
|
+
value
|
|
5687
|
+
]);
|
|
5688
|
+
}
|
|
5689
|
+
}
|
|
5690
|
+
var kept = _filterValuesByDistance(tagged, minDistance, function(x) {
|
|
5691
|
+
return x[0];
|
|
5692
|
+
});
|
|
5693
|
+
kept.sort(function(a, b) {
|
|
5694
|
+
return a.index - b.index;
|
|
5695
|
+
});
|
|
5696
|
+
return kept.map(function(x) {
|
|
5697
|
+
return x.item;
|
|
5698
|
+
});
|
|
5341
5699
|
}
|
|
5342
5700
|
/**
|
|
5343
5701
|
* Filters the input values by an arbitrary "distance"/difference from each other and returns the values sorted by their determined distance.
|
|
@@ -5401,14 +5759,17 @@ function stepsFromIndex(range, startIndex) {
|
|
|
5401
5759
|
/**
|
|
5402
5760
|
* Same as applyBestFit, but returns a new array, rather than modifying the existing array.
|
|
5403
5761
|
*
|
|
5404
|
-
* @
|
|
5405
|
-
* @
|
|
5406
|
-
* @
|
|
5407
|
-
* @
|
|
5408
|
-
*
|
|
5409
|
-
|
|
5410
|
-
|
|
5411
|
-
|
|
5762
|
+
* @dbxUtil
|
|
5763
|
+
* @dbxUtilCategory array
|
|
5764
|
+
* @dbxUtilTags array, best-fit, filter, sort, immutable
|
|
5765
|
+
* @dbxUtilRelated apply-best-fit, find-best-index-set-pair
|
|
5766
|
+
*
|
|
5767
|
+
* @param input - The array to filter for the best fit.
|
|
5768
|
+
* @param config - The best-fit strategy ({@link BestFitConfig}).
|
|
5769
|
+
* @returns A new array with only the best fit item and transformed non-best-fit items.
|
|
5770
|
+
* @__NO_SIDE_EFFECTS__
|
|
5771
|
+
*/ function makeBestFit(input, config) {
|
|
5772
|
+
return applyBestFit(copyArray(input), config);
|
|
5412
5773
|
}
|
|
5413
5774
|
/**
|
|
5414
5775
|
* Used for updating an array so that a single element becomes the "best fit" in whatever context is provided.
|
|
@@ -5416,13 +5777,16 @@ function makeBestFit(input, filter, compare, updateNonBestFit) {
|
|
|
5416
5777
|
* For instance, if two items are selected but only one can be selected by design, this function can be used to
|
|
5417
5778
|
* pick the best fit, and update the input array.
|
|
5418
5779
|
*
|
|
5419
|
-
* @
|
|
5420
|
-
* @
|
|
5421
|
-
* @
|
|
5422
|
-
* @
|
|
5423
|
-
*
|
|
5424
|
-
|
|
5425
|
-
|
|
5780
|
+
* @dbxUtil
|
|
5781
|
+
* @dbxUtilCategory array
|
|
5782
|
+
* @dbxUtilTags array, best-fit, filter, sort, mutable, in-place
|
|
5783
|
+
* @dbxUtilRelated make-best-fit, find-best-index-set-pair
|
|
5784
|
+
*
|
|
5785
|
+
* @param input - The array to modify in-place.
|
|
5786
|
+
* @param config - The best-fit strategy ({@link BestFitConfig}).
|
|
5787
|
+
* @returns The modified input array with only the best fit item and transformed non-best-fit items.
|
|
5788
|
+
*/ function applyBestFit(input, config) {
|
|
5789
|
+
var filter = config.filter, compare = config.compare, updateNonBestFit = config.updateNonBestFit;
|
|
5426
5790
|
var matchIndexSet = findToIndexSet(input, filter);
|
|
5427
5791
|
if (matchIndexSet.length > 1) {
|
|
5428
5792
|
var expansion = expandIndexSet(input, matchIndexSet);
|
|
@@ -5440,9 +5804,16 @@ function applyBestFit(input, filter, compare, updateNonBestFit) {
|
|
|
5440
5804
|
* Creates a function that filters the input values and maps all matching values to a new value.
|
|
5441
5805
|
* This is a higher-order function that combines filtering and mapping operations.
|
|
5442
5806
|
*
|
|
5807
|
+
* @dbxUtil
|
|
5808
|
+
* @dbxUtilCategory array
|
|
5809
|
+
* @dbxUtilKind factory
|
|
5810
|
+
* @dbxUtilTags array, filter, map, transform, factory, iterable
|
|
5811
|
+
* @dbxUtilRelated array-decision-function
|
|
5812
|
+
*
|
|
5443
5813
|
* @param decisionFunction - Function that determines which items to include in the result
|
|
5444
5814
|
* @param mapFunction - Function that transforms each included item
|
|
5445
5815
|
* @returns A function that takes an iterable of input values and returns an array of transformed values
|
|
5816
|
+
* @__NO_SIDE_EFFECTS__
|
|
5446
5817
|
*/ function filterAndMapFunction(decisionFunction, mapFunction) {
|
|
5447
5818
|
return function(values) {
|
|
5448
5819
|
var result = [];
|
|
@@ -5466,6 +5837,7 @@ function applyBestFit(input, filter, compare, updateNonBestFit) {
|
|
|
5466
5837
|
*
|
|
5467
5838
|
* @param factory - The factory function used to generate each item
|
|
5468
5839
|
* @returns A function that takes a count parameter and returns an array of generated items
|
|
5840
|
+
* @__NO_SIDE_EFFECTS__
|
|
5469
5841
|
*/ function arrayFactory(factory) {
|
|
5470
5842
|
return function(count) {
|
|
5471
5843
|
return makeWithFactory(factory, count);
|
|
@@ -5482,6 +5854,7 @@ function applyBestFit(input, filter, compare, updateNonBestFit) {
|
|
|
5482
5854
|
*
|
|
5483
5855
|
* @param factory - The factory function used to transform each input value
|
|
5484
5856
|
* @returns A function that takes an array of input values and returns an array of output values
|
|
5857
|
+
* @__NO_SIDE_EFFECTS__
|
|
5485
5858
|
*/ function arrayInputFactory(factory) {
|
|
5486
5859
|
return function(input) {
|
|
5487
5860
|
return makeWithFactoryInput(factory, input);
|
|
@@ -5566,8 +5939,15 @@ function getArrayNextIndex(array, index) {
|
|
|
5566
5939
|
*
|
|
5567
5940
|
* Each accessor maps an index to the value whose range contains that index, or undefined if no range matches.
|
|
5568
5941
|
*
|
|
5942
|
+
* @dbxUtil
|
|
5943
|
+
* @dbxUtilCategory array
|
|
5944
|
+
* @dbxUtilKind factory
|
|
5945
|
+
* @dbxUtilTags array, indexed, range, accessor, factory, lookup
|
|
5946
|
+
* @dbxUtilRelated indexed-values-array-accessor-factory, ranged-indexed-values-array-accessor-info-factory
|
|
5947
|
+
*
|
|
5569
5948
|
* @param readIndexRange - Function that reads the index range from each value.
|
|
5570
5949
|
* @returns A factory that creates ranged accessors from arrays of values.
|
|
5950
|
+
* @__NO_SIDE_EFFECTS__
|
|
5571
5951
|
*/ function rangedIndexedValuesArrayAccessorFactory(readIndexRange) {
|
|
5572
5952
|
var readInfoFactory = rangedIndexedValuesArrayAccessorInfoFactory({
|
|
5573
5953
|
readIndexRange: readIndexRange
|
|
@@ -5586,9 +5966,16 @@ function getArrayNextIndex(array, index) {
|
|
|
5586
5966
|
* Each accessor maps an index to the matching value, falling back to the previous value, then the next value.
|
|
5587
5967
|
* This guarantees a value is always returned.
|
|
5588
5968
|
*
|
|
5969
|
+
* @dbxUtil
|
|
5970
|
+
* @dbxUtilCategory array
|
|
5971
|
+
* @dbxUtilKind factory
|
|
5972
|
+
* @dbxUtilTags array, indexed, range, accessor, factory, fallback
|
|
5973
|
+
* @dbxUtilRelated ranged-indexed-values-array-accessor-factory, ranged-indexed-values-array-accessor-info-factory
|
|
5974
|
+
*
|
|
5589
5975
|
* @param readIndexRange - Function that reads the index range from each value.
|
|
5590
5976
|
* @returns A factory that creates indexed accessors from arrays of values.
|
|
5591
5977
|
* @throws Error if the provided values array is empty.
|
|
5978
|
+
* @__NO_SIDE_EFFECTS__
|
|
5592
5979
|
*/ function indexedValuesArrayAccessorFactory(readIndexRange) {
|
|
5593
5980
|
var readInfoFactory = rangedIndexedValuesArrayAccessorInfoFactory({
|
|
5594
5981
|
readIndexRange: readIndexRange
|
|
@@ -5612,8 +5999,15 @@ function getArrayNextIndex(array, index) {
|
|
|
5612
5999
|
* Each accessor sorts the values by their index ranges in ascending order, then for a given index
|
|
5613
6000
|
* returns the matching value along with its previous and next neighbors.
|
|
5614
6001
|
*
|
|
6002
|
+
* @dbxUtil
|
|
6003
|
+
* @dbxUtilCategory array
|
|
6004
|
+
* @dbxUtilKind factory
|
|
6005
|
+
* @dbxUtilTags array, indexed, range, accessor, info, factory, neighbors
|
|
6006
|
+
* @dbxUtilRelated ranged-indexed-values-array-accessor-factory, indexed-values-array-accessor-factory
|
|
6007
|
+
*
|
|
5615
6008
|
* @param config - Configuration containing the index range reader function.
|
|
5616
6009
|
* @returns A factory that creates ranged info accessors from arrays of values.
|
|
6010
|
+
* @__NO_SIDE_EFFECTS__
|
|
5617
6011
|
*/ function rangedIndexedValuesArrayAccessorInfoFactory(config) {
|
|
5618
6012
|
var pairFactory = indexRangeReaderPairFactory(config.readIndexRange);
|
|
5619
6013
|
return function(values) {
|
|
@@ -5679,8 +6073,15 @@ function limitArray(array, inputConfig) {
|
|
|
5679
6073
|
/**
|
|
5680
6074
|
* Creates a factory function that generates arrays of a random length populated with items from a make function.
|
|
5681
6075
|
*
|
|
6076
|
+
* @dbxUtil
|
|
6077
|
+
* @dbxUtilCategory array
|
|
6078
|
+
* @dbxUtilKind factory
|
|
6079
|
+
* @dbxUtilTags array, random, factory, generate, make
|
|
6080
|
+
* @dbxUtilRelated array-factory, random-number-factory
|
|
6081
|
+
*
|
|
5682
6082
|
* @param config - configuration containing the make function and random number source
|
|
5683
6083
|
* @returns a factory that produces arrays of random length, optionally accepting a specific count override
|
|
6084
|
+
* @__NO_SIDE_EFFECTS__
|
|
5684
6085
|
*/ function randomArrayFactory(config) {
|
|
5685
6086
|
var randomFn = typeof config.random === 'function' ? config.random : randomNumberFactory(config.random);
|
|
5686
6087
|
var nextRandomCount = function nextRandomCount() {
|
|
@@ -5747,6 +6148,7 @@ function generateIfDoesNotExist(keys, existing, readKey, generateFn) {
|
|
|
5747
6148
|
* @param values - array of values to randomly pick from
|
|
5748
6149
|
* @returns a callable factory that returns a random value from the array on each invocation
|
|
5749
6150
|
* @throws Error if the input array is empty
|
|
6151
|
+
* @__NO_SIDE_EFFECTS__
|
|
5750
6152
|
*/ function randomPickFactory(values) {
|
|
5751
6153
|
if (values.length === 0) {
|
|
5752
6154
|
throw new Error('randomPickFactory() cannot use an empty array.');
|
|
@@ -6056,6 +6458,7 @@ function caseInsensitiveString(input) {
|
|
|
6056
6458
|
*
|
|
6057
6459
|
* @param config - configuration controlling max length and end text behavior
|
|
6058
6460
|
* @returns a reusable function that truncates input strings
|
|
6461
|
+
* @__NO_SIDE_EFFECTS__
|
|
6059
6462
|
*/ function cutStringFunction(config) {
|
|
6060
6463
|
var inputMaxLength = config.maxLength, maxLengthIncludesEndText = config.maxLengthIncludesEndText, inputEndText = config.endText;
|
|
6061
6464
|
var endText = inputEndText === undefined ? DEFAULT_CUT_STRING_END_TEXT : '';
|
|
@@ -6172,24 +6575,42 @@ function caseInsensitiveString(input) {
|
|
|
6172
6575
|
/**
|
|
6173
6576
|
* Trims leading and trailing whitespace from a string.
|
|
6174
6577
|
*
|
|
6578
|
+
* @dbxUtil
|
|
6579
|
+
* @dbxUtilCategory string
|
|
6580
|
+
* @dbxUtilTags string, trim, whitespace, transform
|
|
6581
|
+
* @dbxUtilRelated transform-string-function
|
|
6582
|
+
*
|
|
6175
6583
|
* @param input The string to trim.
|
|
6176
6584
|
* @returns The trimmed string.
|
|
6585
|
+
* @__NO_SIDE_EFFECTS__
|
|
6177
6586
|
*/ function stringTrimFunction(input) {
|
|
6178
6587
|
return input.trim();
|
|
6179
6588
|
}
|
|
6180
6589
|
/**
|
|
6181
6590
|
* Converts a string to uppercase.
|
|
6182
6591
|
*
|
|
6592
|
+
* @dbxUtil
|
|
6593
|
+
* @dbxUtilCategory string
|
|
6594
|
+
* @dbxUtilTags string, uppercase, case, transform
|
|
6595
|
+
* @dbxUtilRelated string-to-lowercase-function, transform-string-function
|
|
6596
|
+
*
|
|
6183
6597
|
* @param input The string to convert.
|
|
6184
6598
|
* @returns The uppercase string.
|
|
6599
|
+
* @__NO_SIDE_EFFECTS__
|
|
6185
6600
|
*/ function stringToUppercaseFunction(input) {
|
|
6186
6601
|
return input.toUpperCase();
|
|
6187
6602
|
}
|
|
6188
6603
|
/**
|
|
6189
6604
|
* Converts a string to lowercase.
|
|
6190
6605
|
*
|
|
6606
|
+
* @dbxUtil
|
|
6607
|
+
* @dbxUtilCategory string
|
|
6608
|
+
* @dbxUtilTags string, lowercase, case, transform
|
|
6609
|
+
* @dbxUtilRelated string-to-uppercase-function, transform-string-function
|
|
6610
|
+
*
|
|
6191
6611
|
* @param input The string to convert.
|
|
6192
6612
|
* @returns The lowercase string.
|
|
6613
|
+
* @__NO_SIDE_EFFECTS__
|
|
6193
6614
|
*/ function stringToLowercaseFunction(input) {
|
|
6194
6615
|
return input.toLowerCase();
|
|
6195
6616
|
}
|
|
@@ -6216,9 +6637,16 @@ function caseInsensitiveString(input) {
|
|
|
6216
6637
|
* 4. Lowercase conversion (if `config.toLowercase` is true and no `config.transform` or `config.toUppercase`).
|
|
6217
6638
|
* If no transformations are specified, the identity function is returned.
|
|
6218
6639
|
*
|
|
6640
|
+
* @dbxUtil
|
|
6641
|
+
* @dbxUtilCategory string
|
|
6642
|
+
* @dbxUtilKind factory
|
|
6643
|
+
* @dbxUtilTags string, transform, trim, case, slice, factory
|
|
6644
|
+
* @dbxUtilRelated string-trim-function, string-to-uppercase-function, string-to-lowercase-function, slice-string-function
|
|
6645
|
+
*
|
|
6219
6646
|
* @template S The specific string type, defaults to `string`.
|
|
6220
6647
|
* @param config The `TransformStringFunctionConfig` detailing the transformations.
|
|
6221
6648
|
* @returns A `TransformStringFunction` that applies the configured transformations.
|
|
6649
|
+
* @__NO_SIDE_EFFECTS__
|
|
6222
6650
|
*/ function transformStringFunction(config) {
|
|
6223
6651
|
var baseTransform;
|
|
6224
6652
|
if (config.transform) {
|
|
@@ -6264,8 +6692,15 @@ function caseInsensitiveString(input) {
|
|
|
6264
6692
|
/**
|
|
6265
6693
|
* Creates a function that adds a configured prefix to the input string if it does not exist on that string.
|
|
6266
6694
|
*
|
|
6695
|
+
* @dbxUtil
|
|
6696
|
+
* @dbxUtilCategory string
|
|
6697
|
+
* @dbxUtilKind factory
|
|
6698
|
+
* @dbxUtilTags string, prefix, add, factory
|
|
6699
|
+
* @dbxUtilRelated add-prefix, add-suffix-function
|
|
6700
|
+
*
|
|
6267
6701
|
* @param prefix The prefix to add.
|
|
6268
6702
|
* @returns A function that adds the prefix to a string.
|
|
6703
|
+
* @__NO_SIDE_EFFECTS__
|
|
6269
6704
|
*/ function addPrefixFunction(prefix) {
|
|
6270
6705
|
return function(input) {
|
|
6271
6706
|
return input.startsWith(prefix) ? input : prefix + input;
|
|
@@ -6283,8 +6718,15 @@ function caseInsensitiveString(input) {
|
|
|
6283
6718
|
/**
|
|
6284
6719
|
* Creates a function that adds a configured suffix to the input string if it does not exist on that string.
|
|
6285
6720
|
*
|
|
6721
|
+
* @dbxUtil
|
|
6722
|
+
* @dbxUtilCategory string
|
|
6723
|
+
* @dbxUtilKind factory
|
|
6724
|
+
* @dbxUtilTags string, suffix, add, factory
|
|
6725
|
+
* @dbxUtilRelated add-suffix, add-prefix-function
|
|
6726
|
+
*
|
|
6286
6727
|
* @param suffix The suffix to add.
|
|
6287
6728
|
* @returns A function that adds the suffix to a string.
|
|
6729
|
+
* @__NO_SIDE_EFFECTS__
|
|
6288
6730
|
*/ function addSuffixFunction(suffix) {
|
|
6289
6731
|
return function(input) {
|
|
6290
6732
|
return input.endsWith(suffix) ? input : input + suffix;
|
|
@@ -6293,9 +6735,16 @@ function caseInsensitiveString(input) {
|
|
|
6293
6735
|
/**
|
|
6294
6736
|
* Pads the start of a string to a minimum length.
|
|
6295
6737
|
*
|
|
6738
|
+
* @dbxUtil
|
|
6739
|
+
* @dbxUtilCategory string
|
|
6740
|
+
* @dbxUtilKind factory
|
|
6741
|
+
* @dbxUtilTags string, pad, start, factory, minimum-length
|
|
6742
|
+
* @dbxUtilRelated transform-string-function
|
|
6743
|
+
*
|
|
6296
6744
|
* @param minLength The minimum length of the string.
|
|
6297
6745
|
* @param padCharacter The character to use for padding.
|
|
6298
6746
|
* @returns A function that pads the start of a string.
|
|
6747
|
+
* @__NO_SIDE_EFFECTS__
|
|
6299
6748
|
*/ function padStartFunction(minLength, padCharacter) {
|
|
6300
6749
|
return function(input) {
|
|
6301
6750
|
return input.padStart(minLength, padCharacter);
|
|
@@ -6304,8 +6753,15 @@ function caseInsensitiveString(input) {
|
|
|
6304
6753
|
/**
|
|
6305
6754
|
* Creates a function that slices and concats parts of a string based on the configuration.
|
|
6306
6755
|
*
|
|
6756
|
+
* @dbxUtil
|
|
6757
|
+
* @dbxUtilCategory string
|
|
6758
|
+
* @dbxUtilKind factory
|
|
6759
|
+
* @dbxUtilTags string, slice, take, factory, from-start, from-end
|
|
6760
|
+
* @dbxUtilRelated transform-string-function
|
|
6761
|
+
*
|
|
6307
6762
|
* @param config The configuration for the slice function.
|
|
6308
6763
|
* @returns A SliceStringFunction.
|
|
6764
|
+
* @__NO_SIDE_EFFECTS__
|
|
6309
6765
|
*/ function sliceStringFunction(config) {
|
|
6310
6766
|
var fromStart = config.fromStart, fromEnd = config.fromEnd;
|
|
6311
6767
|
var takeFromStart = Math.abs(fromStart !== null && fromStart !== void 0 ? fromStart : 0);
|
|
@@ -6853,8 +7309,15 @@ function _object_spread$f(target) {
|
|
|
6853
7309
|
* The merged function returns true only if all individual filters pass (AND logic).
|
|
6854
7310
|
* Null/undefined filters are ignored.
|
|
6855
7311
|
*
|
|
7312
|
+
* @dbxUtil
|
|
7313
|
+
* @dbxUtilCategory value
|
|
7314
|
+
* @dbxUtilKind factory
|
|
7315
|
+
* @dbxUtilTags filter, merge, compose, factory, and
|
|
7316
|
+
* @dbxUtilRelated invert-filter, invert-boolean-return-function
|
|
7317
|
+
*
|
|
6856
7318
|
* @param inputFilters - The filter functions to merge
|
|
6857
7319
|
* @returns A single FilterFunction that applies all filters
|
|
7320
|
+
* @__NO_SIDE_EFFECTS__
|
|
6858
7321
|
*/ function mergeFilterFunctions() {
|
|
6859
7322
|
for(var _len = arguments.length, inputFilters = new Array(_len), _key = 0; _key < _len; _key++){
|
|
6860
7323
|
inputFilters[_key] = arguments[_key];
|
|
@@ -6991,6 +7454,14 @@ function _unsupported_iterable_to_array$r(o, minLen) {
|
|
|
6991
7454
|
* const tuples = getDefinedTuples({ a: 1, b: undefined, c: 'hello' });
|
|
6992
7455
|
* // tuples: [['a', 1], ['c', 'hello']]
|
|
6993
7456
|
* ```
|
|
7457
|
+
*
|
|
7458
|
+
* @dbxUtil
|
|
7459
|
+
* @dbxUtilCategory object
|
|
7460
|
+
* @dbxUtilKind factory
|
|
7461
|
+
* @dbxUtilTags object, tuples, filter, factory, key-value
|
|
7462
|
+
* @dbxUtilRelated filter-key-value-tuple-function, for-each-key-value
|
|
7463
|
+
*
|
|
7464
|
+
* @__NO_SIDE_EFFECTS__
|
|
6994
7465
|
*/ function filterKeyValueTuplesFunction(filter) {
|
|
6995
7466
|
var result;
|
|
6996
7467
|
if (filter != null) {
|
|
@@ -7075,6 +7546,14 @@ function _unsupported_iterable_to_array$r(o, minLen) {
|
|
|
7075
7546
|
* isNotNull(['a', 1], 0); // true
|
|
7076
7547
|
* isNotNull(['b', null], 0); // false
|
|
7077
7548
|
* ```
|
|
7549
|
+
*
|
|
7550
|
+
* @dbxUtil
|
|
7551
|
+
* @dbxUtilCategory object
|
|
7552
|
+
* @dbxUtilKind factory
|
|
7553
|
+
* @dbxUtilTags object, tuple, filter, predicate, factory, key-value
|
|
7554
|
+
* @dbxUtilRelated filter-key-value-tuples-function
|
|
7555
|
+
*
|
|
7556
|
+
* @__NO_SIDE_EFFECTS__
|
|
7078
7557
|
*/ function filterKeyValueTupleFunction(inputFilter) {
|
|
7079
7558
|
var filter = filterKeyValueTuplesInputToFilter(inputFilter);
|
|
7080
7559
|
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 +7624,15 @@ function _unsupported_iterable_to_array$r(o, minLen) {
|
|
|
7145
7624
|
/**
|
|
7146
7625
|
* Creates a factory that returns a random element from the given array on each call.
|
|
7147
7626
|
*
|
|
7627
|
+
* @dbxUtil
|
|
7628
|
+
* @dbxUtilCategory getter
|
|
7629
|
+
* @dbxUtilKind factory
|
|
7630
|
+
* @dbxUtilTags getter, factory, random, array, sample
|
|
7631
|
+
* @dbxUtilRelated random-number-factory, random-array-factory
|
|
7632
|
+
*
|
|
7148
7633
|
* @param values - The array of values to randomly select from
|
|
7149
7634
|
* @returns A factory that returns a random element from the array
|
|
7635
|
+
* @__NO_SIDE_EFFECTS__
|
|
7150
7636
|
*/ function randomFromArrayFactory(values) {
|
|
7151
7637
|
var randomIndex = randomNumberFactory({
|
|
7152
7638
|
min: 0,
|
|
@@ -7158,6 +7644,7 @@ function _unsupported_iterable_to_array$r(o, minLen) {
|
|
|
7158
7644
|
};
|
|
7159
7645
|
}
|
|
7160
7646
|
|
|
7647
|
+
// @__NO_SIDE_EFFECTS__
|
|
7161
7648
|
function cachedGetter(factory) {
|
|
7162
7649
|
var loaded;
|
|
7163
7650
|
var init = function init(input) {
|
|
@@ -7198,8 +7685,15 @@ function cachedGetter(factory) {
|
|
|
7198
7685
|
/**
|
|
7199
7686
|
* Creates a factory that wraps Getters with a mapping function.
|
|
7200
7687
|
*
|
|
7688
|
+
* @dbxUtil
|
|
7689
|
+
* @dbxUtilCategory getter
|
|
7690
|
+
* @dbxUtilKind factory
|
|
7691
|
+
* @dbxUtilTags getter, map, transform, factory
|
|
7692
|
+
* @dbxUtilRelated map-getter
|
|
7693
|
+
*
|
|
7201
7694
|
* @param mapFn - The mapping function to apply
|
|
7202
7695
|
* @returns A factory that transforms Getters of type I to Getters of type O
|
|
7696
|
+
* @__NO_SIDE_EFFECTS__
|
|
7203
7697
|
*/ function mapGetterFactory(mapFn) {
|
|
7204
7698
|
return function(getter) {
|
|
7205
7699
|
return function() {
|
|
@@ -7297,12 +7791,19 @@ function _unsupported_iterable_to_array$q(o, minLen) {
|
|
|
7297
7791
|
* @param copy - When true (default), the returned function shallow-copies the input before filtering instead of mutating it.
|
|
7298
7792
|
* @returns A function that returns the stripped object, or `undefined` when filtering removed every key.
|
|
7299
7793
|
*
|
|
7794
|
+
* @dbxUtil
|
|
7795
|
+
* @dbxUtilCategory object
|
|
7796
|
+
* @dbxUtilKind factory
|
|
7797
|
+
* @dbxUtilTags object, strip, filter, factory, undefined, empty
|
|
7798
|
+
* @dbxUtilRelated strip-object, filter-from-pojo-function
|
|
7799
|
+
*
|
|
7300
7800
|
* @example
|
|
7301
7801
|
* ```ts
|
|
7302
7802
|
* const stripUndef = stripObjectFunction(KeyValueTypleValueFilter.UNDEFINED);
|
|
7303
7803
|
* stripUndef({ a: 1, b: undefined }); // { a: 1 }
|
|
7304
7804
|
* stripUndef({ a: undefined }); // undefined
|
|
7305
7805
|
* ```
|
|
7806
|
+
* @__NO_SIDE_EFFECTS__
|
|
7306
7807
|
*/ function stripObjectFunction(filter) {
|
|
7307
7808
|
var copy = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
|
|
7308
7809
|
var filterFn = filterFromPOJOFunction({
|
|
@@ -7391,6 +7892,14 @@ function _unsupported_iterable_to_array$q(o, minLen) {
|
|
|
7391
7892
|
* const result = overrideFn({ color: 'blue', size: 5 });
|
|
7392
7893
|
* // result is { color: 'red', size: 10 } (a new copy)
|
|
7393
7894
|
* ```
|
|
7895
|
+
*
|
|
7896
|
+
* @dbxUtil
|
|
7897
|
+
* @dbxUtilCategory object
|
|
7898
|
+
* @dbxUtilKind factory
|
|
7899
|
+
* @dbxUtilTags object, override, factory, merge, template, cached
|
|
7900
|
+
* @dbxUtilRelated override-in-object, merge-objects-function, filter-from-pojo-function
|
|
7901
|
+
*
|
|
7902
|
+
* @__NO_SIDE_EFFECTS__
|
|
7394
7903
|
*/ function overrideInObjectFunctionFactory(param) {
|
|
7395
7904
|
var filter = param.filter, copy = param.copy, _param_dynamic = param.dynamic, dynamic = _param_dynamic === void 0 ? false : _param_dynamic;
|
|
7396
7905
|
var filterToRelevantValuesObject = filter != null ? filterFromPOJOFunction({
|
|
@@ -7460,6 +7969,14 @@ function _unsupported_iterable_to_array$q(o, minLen) {
|
|
|
7460
7969
|
* // With null filter to also exclude null values:
|
|
7461
7970
|
* const mergeNoNulls = mergeObjectsFunction(KeyValueTypleValueFilter.NULL);
|
|
7462
7971
|
* ```
|
|
7972
|
+
*
|
|
7973
|
+
* @dbxUtil
|
|
7974
|
+
* @dbxUtilCategory object
|
|
7975
|
+
* @dbxUtilKind factory
|
|
7976
|
+
* @dbxUtilTags object, merge, factory, filter
|
|
7977
|
+
* @dbxUtilRelated merge-objects, override-in-object-function-factory
|
|
7978
|
+
*
|
|
7979
|
+
* @__NO_SIDE_EFFECTS__
|
|
7463
7980
|
*/ function mergeObjectsFunction(filter) {
|
|
7464
7981
|
var overrideFn = overrideInObjectFunctionFactory({
|
|
7465
7982
|
filter: filter,
|
|
@@ -7624,6 +8141,14 @@ function _unsupported_iterable_to_array$q(o, minLen) {
|
|
|
7624
8141
|
* findDefinedKeys({ a: 1, b: undefined, c: 'hello' });
|
|
7625
8142
|
* // ['a', 'c']
|
|
7626
8143
|
* ```
|
|
8144
|
+
*
|
|
8145
|
+
* @dbxUtil
|
|
8146
|
+
* @dbxUtilCategory object
|
|
8147
|
+
* @dbxUtilKind factory
|
|
8148
|
+
* @dbxUtilTags object, pojo, keys, find, factory, filter
|
|
8149
|
+
* @dbxUtilRelated find-pojo-keys, count-pojo-keys-function, for-each-key-value-on-pojo-function
|
|
8150
|
+
*
|
|
8151
|
+
* @__NO_SIDE_EFFECTS__
|
|
7627
8152
|
*/ function findPOJOKeysFunction(filter) {
|
|
7628
8153
|
var findEachMatchingKeyOnTarget = forEachKeyValueOnPOJOFunction({
|
|
7629
8154
|
filter: filter,
|
|
@@ -7677,6 +8202,14 @@ function _unsupported_iterable_to_array$q(o, minLen) {
|
|
|
7677
8202
|
* countDefined({ a: 1, b: undefined, c: 'test' });
|
|
7678
8203
|
* // 2
|
|
7679
8204
|
* ```
|
|
8205
|
+
*
|
|
8206
|
+
* @dbxUtil
|
|
8207
|
+
* @dbxUtilCategory object
|
|
8208
|
+
* @dbxUtilKind factory
|
|
8209
|
+
* @dbxUtilTags object, pojo, keys, count, factory, filter
|
|
8210
|
+
* @dbxUtilRelated count-pojo-keys, find-pojo-keys-function
|
|
8211
|
+
*
|
|
8212
|
+
* @__NO_SIDE_EFFECTS__
|
|
7680
8213
|
*/ function countPOJOKeysFunction() {
|
|
7681
8214
|
var filter = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : exports.KeyValueTypleValueFilter.UNDEFINED;
|
|
7682
8215
|
var countEachMatchingKeyOnTarget = forEachKeyValueOnPOJOFunction({
|
|
@@ -7743,6 +8276,14 @@ function _unsupported_iterable_to_array$q(o, minLen) {
|
|
|
7743
8276
|
* const result = filterNulls({ a: 1, b: null, c: undefined });
|
|
7744
8277
|
* // result is { a: 1 }, original is unchanged
|
|
7745
8278
|
* ```
|
|
8279
|
+
*
|
|
8280
|
+
* @dbxUtil
|
|
8281
|
+
* @dbxUtilCategory object
|
|
8282
|
+
* @dbxUtilKind factory
|
|
8283
|
+
* @dbxUtilTags object, pojo, filter, factory, remove, copy
|
|
8284
|
+
* @dbxUtilRelated filter-from-pojo, strip-object-function, assign-values-to-pojo-function
|
|
8285
|
+
*
|
|
8286
|
+
* @__NO_SIDE_EFFECTS__
|
|
7746
8287
|
*/ function filterFromPOJOFunction() {
|
|
7747
8288
|
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
8289
|
valueFilter: exports.KeyValueTypleValueFilter.UNDEFINED
|
|
@@ -7820,6 +8361,14 @@ function _unsupported_iterable_to_array$q(o, minLen) {
|
|
|
7820
8361
|
* // With NULL filter and no copy:
|
|
7821
8362
|
* const assignNoNulls = assignValuesToPOJOFunction({ valueFilter: KeyValueTypleValueFilter.NULL, copy: false });
|
|
7822
8363
|
* ```
|
|
8364
|
+
*
|
|
8365
|
+
* @dbxUtil
|
|
8366
|
+
* @dbxUtilCategory object
|
|
8367
|
+
* @dbxUtilKind factory
|
|
8368
|
+
* @dbxUtilTags object, pojo, assign, factory, filter, copy
|
|
8369
|
+
* @dbxUtilRelated assign-values-to-pojo, filter-from-pojo-function
|
|
8370
|
+
*
|
|
8371
|
+
* @__NO_SIDE_EFFECTS__
|
|
7823
8372
|
*/ function assignValuesToPOJOFunction() {
|
|
7824
8373
|
var input = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : exports.KeyValueTypleValueFilter.UNDEFINED;
|
|
7825
8374
|
var _ref;
|
|
@@ -7885,6 +8434,14 @@ function _unsupported_iterable_to_array$q(o, minLen) {
|
|
|
7885
8434
|
* getNonNullValues({ a: 1, b: null, c: undefined });
|
|
7886
8435
|
* // [1]
|
|
7887
8436
|
* ```
|
|
8437
|
+
*
|
|
8438
|
+
* @dbxUtil
|
|
8439
|
+
* @dbxUtilCategory object
|
|
8440
|
+
* @dbxUtilKind factory
|
|
8441
|
+
* @dbxUtilTags object, pojo, values, factory, filter, extract
|
|
8442
|
+
* @dbxUtilRelated values-from-pojo, find-pojo-keys-function
|
|
8443
|
+
*
|
|
8444
|
+
* @__NO_SIDE_EFFECTS__
|
|
7888
8445
|
*/ function valuesFromPOJOFunction() {
|
|
7889
8446
|
var filter = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : exports.KeyValueTypleValueFilter.UNDEFINED;
|
|
7890
8447
|
var addValuesFromObjectToContext = forEachKeyValueOnPOJOFunction({
|
|
@@ -7924,6 +8481,14 @@ function _unsupported_iterable_to_array$q(o, minLen) {
|
|
|
7924
8481
|
* omitAB({ a: 1, b: 2, c: 3 });
|
|
7925
8482
|
* // { c: 3 }
|
|
7926
8483
|
* ```
|
|
8484
|
+
*
|
|
8485
|
+
* @dbxUtil
|
|
8486
|
+
* @dbxUtilCategory object
|
|
8487
|
+
* @dbxUtilKind factory
|
|
8488
|
+
* @dbxUtilTags object, pojo, keys, filter, pick, omit, factory
|
|
8489
|
+
* @dbxUtilRelated filter-tuples-on-pojo-function, filter-from-pojo-function
|
|
8490
|
+
*
|
|
8491
|
+
* @__NO_SIDE_EFFECTS__
|
|
7927
8492
|
*/ function filterKeysOnPOJOFunction(keysToFilter) {
|
|
7928
8493
|
var invertFilter = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : false;
|
|
7929
8494
|
var keysSet = new Set(keysToFilter);
|
|
@@ -7948,6 +8513,14 @@ function _unsupported_iterable_to_array$q(o, minLen) {
|
|
|
7948
8513
|
* keepStrings({ a: 'hello', b: 42, c: 'world' });
|
|
7949
8514
|
* // { a: 'hello', c: 'world' }
|
|
7950
8515
|
* ```
|
|
8516
|
+
*
|
|
8517
|
+
* @dbxUtil
|
|
8518
|
+
* @dbxUtilCategory object
|
|
8519
|
+
* @dbxUtilKind factory
|
|
8520
|
+
* @dbxUtilTags object, pojo, tuples, filter, predicate, factory
|
|
8521
|
+
* @dbxUtilRelated filter-keys-on-pojo-function, filter-from-pojo-function
|
|
8522
|
+
*
|
|
8523
|
+
* @__NO_SIDE_EFFECTS__
|
|
7951
8524
|
*/ function filterTuplesOnPOJOFunction(filterTupleOnObject) {
|
|
7952
8525
|
return function(input) {
|
|
7953
8526
|
var result = {};
|
|
@@ -7982,6 +8555,14 @@ function _unsupported_iterable_to_array$q(o, minLen) {
|
|
|
7982
8555
|
* logDefined({ a: 1, b: undefined, c: 'test' });
|
|
7983
8556
|
* // logs: 'a' 1, 'c' 'test'
|
|
7984
8557
|
* ```
|
|
8558
|
+
*
|
|
8559
|
+
* @dbxUtil
|
|
8560
|
+
* @dbxUtilCategory object
|
|
8561
|
+
* @dbxUtilKind factory
|
|
8562
|
+
* @dbxUtilTags object, pojo, for-each, iterate, factory, callback
|
|
8563
|
+
* @dbxUtilRelated find-pojo-keys-function, count-pojo-keys-function, filter-key-value-tuples-function
|
|
8564
|
+
*
|
|
8565
|
+
* @__NO_SIDE_EFFECTS__
|
|
7985
8566
|
*/ function forEachKeyValueOnPOJOFunction(param) {
|
|
7986
8567
|
var forEach = param.forEach, filter = param.filter;
|
|
7987
8568
|
var filterKeyValues = filterKeyValueTuplesFunction(filter);
|
|
@@ -8016,6 +8597,7 @@ function _unsupported_iterable_to_array$q(o, minLen) {
|
|
|
8016
8597
|
return isAllowed;
|
|
8017
8598
|
}
|
|
8018
8599
|
|
|
8600
|
+
// @__NO_SIDE_EFFECTS__
|
|
8019
8601
|
function isInSetDecisionFunction(set, inputReadValue) {
|
|
8020
8602
|
var readValue = inputReadValue !== null && inputReadValue !== void 0 ? inputReadValue : function(x) {
|
|
8021
8603
|
return x;
|
|
@@ -8041,8 +8623,15 @@ function isInSetDecisionFunction(set, inputReadValue) {
|
|
|
8041
8623
|
* Creates a {@link SetDeltaFunction} that computes the differences between two iterables,
|
|
8042
8624
|
* identifying which items were added, removed, or unchanged.
|
|
8043
8625
|
*
|
|
8626
|
+
* @dbxUtil
|
|
8627
|
+
* @dbxUtilCategory set
|
|
8628
|
+
* @dbxUtilKind factory
|
|
8629
|
+
* @dbxUtilTags set, delta, diff, factory, change, added, removed
|
|
8630
|
+
* @dbxUtilRelated index-delta-group-function, set-has-value-function
|
|
8631
|
+
*
|
|
8044
8632
|
* @param config - Configuration with the key reader and optional modification detector.
|
|
8045
8633
|
* @returns A function that compares two iterables and returns an array of change pairs.
|
|
8634
|
+
* @__NO_SIDE_EFFECTS__
|
|
8046
8635
|
*/ function setDeltaFunction(config) {
|
|
8047
8636
|
var readKey = config.readKey, _config_isModifiedFunction = config.isModifiedFunction, isModifiedFunction = _config_isModifiedFunction === void 0 ? function() {
|
|
8048
8637
|
return undefined;
|
|
@@ -8189,9 +8778,16 @@ var AUTH_ROLE_CLAIMS_DEFAULT_EMPTY_VALUE = null;
|
|
|
8189
8778
|
* Each key in the config maps a claim key to role(s). Simple entries map a claim value to one or more roles,
|
|
8190
8779
|
* while encode/decode entries allow custom bidirectional conversion logic.
|
|
8191
8780
|
*
|
|
8781
|
+
* @dbxUtil
|
|
8782
|
+
* @dbxUtilCategory auth
|
|
8783
|
+
* @dbxUtilKind factory
|
|
8784
|
+
* @dbxUtilTags auth, role, claims, jwt, factory, bidirectional
|
|
8785
|
+
* @dbxUtilRelated auth-role
|
|
8786
|
+
*
|
|
8192
8787
|
* @param config - Mapping of claim keys to their role configuration entries (or null to ignore)
|
|
8193
8788
|
* @param defaults - Optional default values for claim presence and absence
|
|
8194
8789
|
* @returns A service with `toClaims` and `toRoles` conversion functions
|
|
8790
|
+
* @__NO_SIDE_EFFECTS__
|
|
8195
8791
|
*/ function authRoleClaimsService(config) {
|
|
8196
8792
|
var defaults = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
8197
8793
|
var _ref, _ref1;
|
|
@@ -9899,9 +10495,16 @@ function _unsupported_iterable_to_array$o(o, minLen) {
|
|
|
9899
10495
|
* Creates a function that replaces the last character of a string with the replacement string
|
|
9900
10496
|
* if that character matches any of the specified values.
|
|
9901
10497
|
*
|
|
10498
|
+
* @dbxUtil
|
|
10499
|
+
* @dbxUtilCategory string
|
|
10500
|
+
* @dbxUtilKind factory
|
|
10501
|
+
* @dbxUtilTags string, replace, last, character, conditional, factory
|
|
10502
|
+
* @dbxUtilRelated replace-last-character-if, replace-character-at-index-if
|
|
10503
|
+
*
|
|
9902
10504
|
* @param replacement - string to substitute for the last character
|
|
9903
10505
|
* @param is - character(s) that trigger the replacement
|
|
9904
10506
|
* @returns a function that conditionally replaces the last character
|
|
10507
|
+
* @__NO_SIDE_EFFECTS__
|
|
9905
10508
|
*/ function replaceLastCharacterIfIsFunction(replacement, is) {
|
|
9906
10509
|
var matches = new Set(is);
|
|
9907
10510
|
return function(input) {
|
|
@@ -10071,8 +10674,15 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10071
10674
|
/**
|
|
10072
10675
|
* Creates a function that replaces all occurrences of the configured target strings with a replacement value.
|
|
10073
10676
|
*
|
|
10677
|
+
* @dbxUtil
|
|
10678
|
+
* @dbxUtilCategory string
|
|
10679
|
+
* @dbxUtilKind factory
|
|
10680
|
+
* @dbxUtilTags string, replace, regex, substitute, factory
|
|
10681
|
+
* @dbxUtilRelated find-strings-regex-string, escape-string-for-regex
|
|
10682
|
+
*
|
|
10074
10683
|
* @param config - Configuration specifying strings to find and the replacement value.
|
|
10075
10684
|
* @returns A function that performs the configured replacements on an input string.
|
|
10685
|
+
* @__NO_SIDE_EFFECTS__
|
|
10076
10686
|
*/ function replaceStringsFunction(config) {
|
|
10077
10687
|
var replaceInput = config.replace, replaceWith = config.replaceWith;
|
|
10078
10688
|
var replaceRegexString = findStringsRegexString(replaceInput);
|
|
@@ -10105,6 +10715,11 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10105
10715
|
/**
|
|
10106
10716
|
* Creates an escaped regex string that matches any of the input values, joined with the OR (`|`) operator.
|
|
10107
10717
|
*
|
|
10718
|
+
* @dbxUtil
|
|
10719
|
+
* @dbxUtilCategory string
|
|
10720
|
+
* @dbxUtilTags string, regex, escape, alternation, pattern
|
|
10721
|
+
* @dbxUtilRelated escape-string-for-regex, replace-strings-function
|
|
10722
|
+
*
|
|
10108
10723
|
* @param find - One or more strings to create a matching regex pattern for.
|
|
10109
10724
|
* @returns A regex-compatible string with special characters escaped and values joined by `|`.
|
|
10110
10725
|
*/ function findStringsRegexString(find) {
|
|
@@ -10115,8 +10730,15 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10115
10730
|
/**
|
|
10116
10731
|
* Creates an {@link EscapeStringCharactersFunction} that escapes specific characters in a string using the configured escape strategy.
|
|
10117
10732
|
*
|
|
10733
|
+
* @dbxUtil
|
|
10734
|
+
* @dbxUtilCategory string
|
|
10735
|
+
* @dbxUtilKind factory
|
|
10736
|
+
* @dbxUtilTags string, escape, characters, factory, transform
|
|
10737
|
+
* @dbxUtilRelated escape-string-for-regex, find-all-character-occurences-function
|
|
10738
|
+
*
|
|
10118
10739
|
* @param config - Configuration specifying which characters to escape and how to escape them.
|
|
10119
10740
|
* @returns A function that escapes the configured characters in any input string.
|
|
10741
|
+
* @__NO_SIDE_EFFECTS__
|
|
10120
10742
|
*/ function escapeStringCharactersFunction(config) {
|
|
10121
10743
|
var inputEscapeTargets = config.escapeTargets, escapeCharacter = config.escapeCharacter;
|
|
10122
10744
|
var escapeTargets = _instanceof$3(inputEscapeTargets, Set) ? inputEscapeTargets : new Set(inputEscapeTargets);
|
|
@@ -10164,6 +10786,12 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10164
10786
|
*
|
|
10165
10787
|
* For instance, `'hello.world'` will be escaped to `'hello\\.world'`.
|
|
10166
10788
|
*
|
|
10789
|
+
* @dbxUtil
|
|
10790
|
+
* @dbxUtilCategory string
|
|
10791
|
+
* @dbxUtilKind const
|
|
10792
|
+
* @dbxUtilTags string, regex, escape, sanitize, pattern
|
|
10793
|
+
* @dbxUtilRelated escape-string-characters-function, find-strings-regex-string
|
|
10794
|
+
*
|
|
10167
10795
|
* @param input - The string to escape for regex use.
|
|
10168
10796
|
* @returns The escaped string with all regex special characters prefixed with a backslash.
|
|
10169
10797
|
*/ var escapeStringForRegex = escapeStringCharactersFunction({
|
|
@@ -10175,8 +10803,15 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10175
10803
|
/**
|
|
10176
10804
|
* Creates a {@link FindAllCharacterOccurencesFunction} that searches for characters from the given set.
|
|
10177
10805
|
*
|
|
10806
|
+
* @dbxUtil
|
|
10807
|
+
* @dbxUtilCategory string
|
|
10808
|
+
* @dbxUtilKind factory
|
|
10809
|
+
* @dbxUtilTags string, search, characters, indices, factory, occurrences
|
|
10810
|
+
* @dbxUtilRelated find-all-character-occurences, find-first-character-occurence
|
|
10811
|
+
*
|
|
10178
10812
|
* @param characterSet - The set of characters to search for.
|
|
10179
10813
|
* @returns A function that finds all occurrences of the configured characters in an input string.
|
|
10814
|
+
* @__NO_SIDE_EFFECTS__
|
|
10180
10815
|
*/ function findAllCharacterOccurencesFunction(characterSet) {
|
|
10181
10816
|
return function(input, maxToReturn) {
|
|
10182
10817
|
var max = maxToReturn !== null && maxToReturn !== void 0 ? maxToReturn : Number.MAX_SAFE_INTEGER;
|
|
@@ -10213,6 +10848,11 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10213
10848
|
/**
|
|
10214
10849
|
* Finds all indices of characters from the set that appear in the input string.
|
|
10215
10850
|
*
|
|
10851
|
+
* @dbxUtil
|
|
10852
|
+
* @dbxUtilCategory string
|
|
10853
|
+
* @dbxUtilTags string, search, characters, indices, occurrences
|
|
10854
|
+
* @dbxUtilRelated find-all-character-occurences-function, find-first-character-occurence
|
|
10855
|
+
*
|
|
10216
10856
|
* @param set - The set of characters to search for.
|
|
10217
10857
|
* @param input - The string to search through.
|
|
10218
10858
|
* @param max - Optional maximum number of occurrences to return.
|
|
@@ -10223,6 +10863,11 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10223
10863
|
/**
|
|
10224
10864
|
* Finds the index of the first occurrence of any character from the set in the input string.
|
|
10225
10865
|
*
|
|
10866
|
+
* @dbxUtil
|
|
10867
|
+
* @dbxUtilCategory string
|
|
10868
|
+
* @dbxUtilTags string, search, characters, first, index, occurrence
|
|
10869
|
+
* @dbxUtilRelated find-all-character-occurences, find-all-character-occurences-function
|
|
10870
|
+
*
|
|
10226
10871
|
* @param set - The set of characters to search for.
|
|
10227
10872
|
* @param input - The string to search through.
|
|
10228
10873
|
* @returns The zero-based index of the first matching character, or `undefined` if none found.
|
|
@@ -10232,8 +10877,15 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10232
10877
|
/**
|
|
10233
10878
|
* Creates a function that splits a string into two parts at the first occurrence of any character in the configured set.
|
|
10234
10879
|
*
|
|
10880
|
+
* @dbxUtil
|
|
10881
|
+
* @dbxUtilCategory string
|
|
10882
|
+
* @dbxUtilKind factory
|
|
10883
|
+
* @dbxUtilTags string, split, characters, occurrence, factory
|
|
10884
|
+
* @dbxUtilRelated split-string-at-first-character-occurence, keep-characters-after-first-character-occurence-function
|
|
10885
|
+
*
|
|
10235
10886
|
* @param splitAt - A single character or set of characters to split on.
|
|
10236
10887
|
* @returns A function that splits input strings at the first matching character.
|
|
10888
|
+
* @__NO_SIDE_EFFECTS__
|
|
10237
10889
|
*/ function splitStringAtFirstCharacterOccurenceFunction(splitAt) {
|
|
10238
10890
|
return function(input) {
|
|
10239
10891
|
var splitSet = typeof splitAt === 'string' ? new Set([
|
|
@@ -10255,6 +10907,11 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10255
10907
|
/**
|
|
10256
10908
|
* Splits the input string into two parts at the first occurrence of any character in the split set.
|
|
10257
10909
|
*
|
|
10910
|
+
* @dbxUtil
|
|
10911
|
+
* @dbxUtilCategory string
|
|
10912
|
+
* @dbxUtilTags string, split, characters, occurrence, tuple
|
|
10913
|
+
* @dbxUtilRelated split-string-at-first-character-occurence-function, find-first-character-occurence
|
|
10914
|
+
*
|
|
10258
10915
|
* @param input - The string to split.
|
|
10259
10916
|
* @param splitAt - A single character or set of characters to split on.
|
|
10260
10917
|
* @returns A tuple of [before, after], where `after` is `undefined` if no split character was found.
|
|
@@ -10264,8 +10921,15 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10264
10921
|
/**
|
|
10265
10922
|
* Creates a function that returns only the characters after the first occurrence of any character in the configured set.
|
|
10266
10923
|
*
|
|
10924
|
+
* @dbxUtil
|
|
10925
|
+
* @dbxUtilCategory string
|
|
10926
|
+
* @dbxUtilKind factory
|
|
10927
|
+
* @dbxUtilTags string, keep, after, occurrence, factory, suffix
|
|
10928
|
+
* @dbxUtilRelated keep-characters-after-first-character-occurence, remove-characters-after-first-character-occurence-function
|
|
10929
|
+
*
|
|
10267
10930
|
* @param findCharacters - A single character or set of characters to search for.
|
|
10268
10931
|
* @returns A function that extracts the substring after the first matching character, or an empty string if none found.
|
|
10932
|
+
* @__NO_SIDE_EFFECTS__
|
|
10269
10933
|
*/ function keepCharactersAfterFirstCharacterOccurenceFunction(findCharacters) {
|
|
10270
10934
|
var splitStringAtFirstCharacterOccurence = splitStringAtFirstCharacterOccurenceFunction(findCharacters);
|
|
10271
10935
|
return function(input) {
|
|
@@ -10276,6 +10940,11 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10276
10940
|
/**
|
|
10277
10941
|
* Returns only the characters after the first occurrence of any character from the find set.
|
|
10278
10942
|
*
|
|
10943
|
+
* @dbxUtil
|
|
10944
|
+
* @dbxUtilCategory string
|
|
10945
|
+
* @dbxUtilTags string, keep, after, occurrence, suffix
|
|
10946
|
+
* @dbxUtilRelated keep-characters-after-first-character-occurence-function, remove-characters-after-first-character-occurence
|
|
10947
|
+
*
|
|
10279
10948
|
* @param input - The string to search through.
|
|
10280
10949
|
* @param findCharacters - A single character or set of characters to search for.
|
|
10281
10950
|
* @returns The substring after the first matching character, or an empty string if none found.
|
|
@@ -10285,8 +10954,15 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10285
10954
|
/**
|
|
10286
10955
|
* Creates a function that removes all characters after (and including) the first occurrence of any character in the configured set.
|
|
10287
10956
|
*
|
|
10957
|
+
* @dbxUtil
|
|
10958
|
+
* @dbxUtilCategory string
|
|
10959
|
+
* @dbxUtilKind factory
|
|
10960
|
+
* @dbxUtilTags string, remove, truncate, occurrence, factory, prefix
|
|
10961
|
+
* @dbxUtilRelated remove-characters-after-first-character-occurence, keep-characters-after-first-character-occurence-function
|
|
10962
|
+
*
|
|
10288
10963
|
* @param findCharacters - A single character or set of characters to search for.
|
|
10289
10964
|
* @returns A function that truncates input strings at the first matching character.
|
|
10965
|
+
* @__NO_SIDE_EFFECTS__
|
|
10290
10966
|
*/ function removeCharactersAfterFirstCharacterOccurenceFunction(findCharacters) {
|
|
10291
10967
|
var splitStringAtFirstCharacterOccurence = splitStringAtFirstCharacterOccurenceFunction(findCharacters);
|
|
10292
10968
|
return function(input) {
|
|
@@ -10296,6 +10972,11 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10296
10972
|
/**
|
|
10297
10973
|
* Removes all characters after (and including) the first occurrence of any character from the find set.
|
|
10298
10974
|
*
|
|
10975
|
+
* @dbxUtil
|
|
10976
|
+
* @dbxUtilCategory string
|
|
10977
|
+
* @dbxUtilTags string, remove, truncate, occurrence, prefix
|
|
10978
|
+
* @dbxUtilRelated remove-characters-after-first-character-occurence-function, keep-characters-after-first-character-occurence
|
|
10979
|
+
*
|
|
10299
10980
|
* @param input - The string to truncate.
|
|
10300
10981
|
* @param findCharacters - A single character or set of characters to search for.
|
|
10301
10982
|
* @returns The substring before the first matching character, or the full string if none found.
|
|
@@ -10445,6 +11126,7 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10445
11126
|
* const alwaysTrue = decisionFunction(true);
|
|
10446
11127
|
* alwaysTrue('anything'); // true
|
|
10447
11128
|
* ```
|
|
11129
|
+
* @__NO_SIDE_EFFECTS__
|
|
10448
11130
|
*/ function decisionFunction(decision) {
|
|
10449
11131
|
return function() {
|
|
10450
11132
|
return decision;
|
|
@@ -10487,11 +11169,14 @@ function _unsupported_iterable_to_array$n(o, minLen) {
|
|
|
10487
11169
|
* const fn2 = asDecisionFunction(undefined, false);
|
|
10488
11170
|
* fn2('anything'); // false
|
|
10489
11171
|
* ```
|
|
11172
|
+
*
|
|
11173
|
+
* @__NO_SIDE_EFFECTS__
|
|
10490
11174
|
*/ function asDecisionFunction(valueOrFunction) {
|
|
10491
11175
|
var defaultIfUndefined = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
|
|
10492
11176
|
var input = valueOrFunction !== null && valueOrFunction !== void 0 ? valueOrFunction : defaultIfUndefined;
|
|
10493
11177
|
return typeof input === 'boolean' ? decisionFunction(input) : input;
|
|
10494
11178
|
}
|
|
11179
|
+
// @__NO_SIDE_EFFECTS__
|
|
10495
11180
|
function isEqualToValueDecisionFunction(equalityValue) {
|
|
10496
11181
|
var equalityValueCheckFunction;
|
|
10497
11182
|
if (typeof equalityValue === 'function') {
|
|
@@ -10751,6 +11436,7 @@ function _unsupported_iterable_to_array$m(o, minLen) {
|
|
|
10751
11436
|
*
|
|
10752
11437
|
* @param type - The start type to enforce.
|
|
10753
11438
|
* @returns A function that transforms paths to the specified start type.
|
|
11439
|
+
* @__NO_SIDE_EFFECTS__
|
|
10754
11440
|
*/ function slashPathStartTypeFactory(type) {
|
|
10755
11441
|
var fn;
|
|
10756
11442
|
switch(type){
|
|
@@ -10797,6 +11483,7 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
10797
11483
|
*
|
|
10798
11484
|
* @param config Configuration options for the factory.
|
|
10799
11485
|
* @returns A SlashPathFolderFactory.
|
|
11486
|
+
* @__NO_SIDE_EFFECTS__
|
|
10800
11487
|
*/ function slashPathFolderFactory() {
|
|
10801
11488
|
var config = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
10802
11489
|
var startType = config.startType, validationConfig = config.validationConfig, inputInvalidPathValue = config.invalidPathValue, treatUntypedFilesAsFolders = config.treatUntypedFilesAsFolders;
|
|
@@ -10966,6 +11653,7 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
10966
11653
|
* @param input
|
|
10967
11654
|
* @param replaceWith
|
|
10968
11655
|
* @returns
|
|
11656
|
+
* @__NO_SIDE_EFFECTS__
|
|
10969
11657
|
*/ function replaceInvalidFilePathTypeSeparatorsInSlashPathFunction() {
|
|
10970
11658
|
var replaceWith = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : DEFAULT_SLASH_PATH_ILLEGAL_CHARACTER_REPLACEMENT;
|
|
10971
11659
|
return function(input) {
|
|
@@ -11011,6 +11699,7 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
11011
11699
|
*
|
|
11012
11700
|
* @param config - Configuration for validation behavior.
|
|
11013
11701
|
* @returns A function that validates and fixes a slash path.
|
|
11702
|
+
* @__NO_SIDE_EFFECTS__
|
|
11014
11703
|
*/ function slashPathValidationFactory(config) {
|
|
11015
11704
|
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
11705
|
var fns = [];
|
|
@@ -11042,6 +11731,7 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
11042
11731
|
*
|
|
11043
11732
|
* @param config - Configuration for path generation.
|
|
11044
11733
|
* @returns A factory function that merges input paths into a single validated slash path.
|
|
11734
|
+
* @__NO_SIDE_EFFECTS__
|
|
11045
11735
|
*/ function slashPathFactory(config) {
|
|
11046
11736
|
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
11737
|
var basePath = inputBasePaths ? mergeSlashPaths(asArray(inputBasePaths)) : undefined;
|
|
@@ -11108,6 +11798,7 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
11108
11798
|
*
|
|
11109
11799
|
* @param config - Configuration with range, optional start type, and file mode.
|
|
11110
11800
|
* @returns A function that isolates path segments within the configured range.
|
|
11801
|
+
* @__NO_SIDE_EFFECTS__
|
|
11111
11802
|
*/ function isolateSlashPathFunction(config) {
|
|
11112
11803
|
var startType = config.startType, asFile = config.asFile;
|
|
11113
11804
|
var range = indexRange(config.range);
|
|
@@ -11210,6 +11901,7 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
11210
11901
|
*
|
|
11211
11902
|
* @param path - Matcher path parts to expand into decision functions.
|
|
11212
11903
|
* @returns Array of decision functions for each path part.
|
|
11904
|
+
* @__NO_SIDE_EFFECTS__
|
|
11213
11905
|
*/ function expandSlashPathPathMatcherPartToDecisionFunctions(path) {
|
|
11214
11906
|
var targetPathPartsInput = asArray(path);
|
|
11215
11907
|
var indexMatchingDecisionFunctions = [];
|
|
@@ -11292,6 +11984,7 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
11292
11984
|
*
|
|
11293
11985
|
* @param input - the matcher configuration, which may be a target path string, an array of path parts, or a full config object
|
|
11294
11986
|
* @returns The matcher.
|
|
11987
|
+
* @__NO_SIDE_EFFECTS__
|
|
11295
11988
|
*/ function slashPathPathMatcher(input) {
|
|
11296
11989
|
var _config_matchRemaining, _config_nonMatchingFillValue;
|
|
11297
11990
|
var config = slashPathPathMatcherConfig(input);
|
|
@@ -11353,6 +12046,7 @@ var ALL_SLASH_PATH_FILE_TYPE_SEPARATORS_REGEX = /\.+/g;
|
|
|
11353
12046
|
*
|
|
11354
12047
|
* @param config The configuration for the matcher.
|
|
11355
12048
|
* @returns The matcher.
|
|
12049
|
+
* @__NO_SIDE_EFFECTS__
|
|
11356
12050
|
*/ function slashPathSubPathMatcher(config) {
|
|
11357
12051
|
var targetPathIndexMatchingDecisionFunctions = expandSlashPathPathMatcherPartToDecisionFunctions(config.basePath);
|
|
11358
12052
|
var basePathPartsCount = targetPathIndexMatchingDecisionFunctions.length;
|
|
@@ -11606,8 +12300,15 @@ function _unsupported_iterable_to_array$l(o, minLen) {
|
|
|
11606
12300
|
/**
|
|
11607
12301
|
* Creates an {@link IsolateWebsitePathFunction} that extracts and transforms a path from a website URL based on the configuration.
|
|
11608
12302
|
*
|
|
12303
|
+
* @dbxUtil
|
|
12304
|
+
* @dbxUtilCategory string
|
|
12305
|
+
* @dbxUtilKind factory
|
|
12306
|
+
* @dbxUtilTags string, url, path, isolate, transform, factory, query
|
|
12307
|
+
* @dbxUtilRelated website-path-from-website-url, website-path-and-query-pair, fix-extra-query-parameters
|
|
12308
|
+
*
|
|
11609
12309
|
* @param config - Configuration for path isolation, including base path removal, component range, query handling, and trailing slash behavior.
|
|
11610
12310
|
* @returns A function that isolates the configured portion of a website path.
|
|
12311
|
+
* @__NO_SIDE_EFFECTS__
|
|
11611
12312
|
*/ function isolateWebsitePathFunction() {
|
|
11612
12313
|
var config = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
11613
12314
|
var removeQueryParameters = config.removeQueryParameters, ignoredBasePath = config.ignoredBasePath, isolatePathComponents = config.isolatePathComponents, removeTrailingSlash = config.removeTrailingSlash;
|
|
@@ -11987,8 +12688,15 @@ function _unsupported_iterable_to_array$k(o, minLen) {
|
|
|
11987
12688
|
/**
|
|
11988
12689
|
* Creates a factory that generates random email addresses using configurable prefixes, domains, and number generators.
|
|
11989
12690
|
*
|
|
12691
|
+
* @dbxUtil
|
|
12692
|
+
* @dbxUtilCategory contact
|
|
12693
|
+
* @dbxUtilKind factory
|
|
12694
|
+
* @dbxUtilTags contact, email, random, factory, generate
|
|
12695
|
+
* @dbxUtilRelated random-phone-number-factory, incrementing-number-factory
|
|
12696
|
+
*
|
|
11990
12697
|
* @param inputConfig - Optional configuration overrides
|
|
11991
12698
|
* @returns A factory function that produces random email address strings
|
|
12699
|
+
* @__NO_SIDE_EFFECTS__
|
|
11992
12700
|
*/ function randomEmailFactory(inputConfig) {
|
|
11993
12701
|
var _config_prefixes, _config_domains;
|
|
11994
12702
|
var config = mergeObjects([
|
|
@@ -12024,8 +12732,15 @@ function _unsupported_iterable_to_array$k(o, minLen) {
|
|
|
12024
12732
|
/**
|
|
12025
12733
|
* Creates a factory that generates random E.164 phone numbers using configurable area codes and number generators.
|
|
12026
12734
|
*
|
|
12735
|
+
* @dbxUtil
|
|
12736
|
+
* @dbxUtilCategory contact
|
|
12737
|
+
* @dbxUtilKind factory
|
|
12738
|
+
* @dbxUtilTags contact, phone, e164, random, factory, generate
|
|
12739
|
+
* @dbxUtilRelated random-email-factory, random-number-factory
|
|
12740
|
+
*
|
|
12027
12741
|
* @param inputConfig - Optional configuration overrides
|
|
12028
12742
|
* @returns A factory function that produces random E.164 phone number strings
|
|
12743
|
+
* @__NO_SIDE_EFFECTS__
|
|
12029
12744
|
*/ function randomPhoneNumberFactory(inputConfig) {
|
|
12030
12745
|
var _config_internationalAreaCodes;
|
|
12031
12746
|
var config = mergeObjects([
|
|
@@ -12312,8 +13027,15 @@ function toReadableError(inputError) {
|
|
|
12312
13027
|
/**
|
|
12313
13028
|
* Creates a function that checks if an error's message contains the target string.
|
|
12314
13029
|
*
|
|
13030
|
+
* @dbxUtil
|
|
13031
|
+
* @dbxUtilCategory error
|
|
13032
|
+
* @dbxUtilKind factory
|
|
13033
|
+
* @dbxUtilTags error, message, contains, factory, predicate, regex
|
|
13034
|
+
* @dbxUtilRelated escape-string-for-regex
|
|
13035
|
+
*
|
|
12315
13036
|
* @param target - The string to search for
|
|
12316
13037
|
* @returns A function that checks error messages for the target string
|
|
13038
|
+
* @__NO_SIDE_EFFECTS__
|
|
12317
13039
|
*/ function errorMessageContainsStringFunction(target) {
|
|
12318
13040
|
var regex = new RegExp(escapeStringForRegex(target));
|
|
12319
13041
|
return function(input) {
|
|
@@ -12427,8 +13149,15 @@ function _unsupported_iterable_to_array$j(o, minLen) {
|
|
|
12427
13149
|
*
|
|
12428
13150
|
* Useful for late-binding or circular dependency resolution.
|
|
12429
13151
|
*
|
|
13152
|
+
* @dbxUtil
|
|
13153
|
+
* @dbxUtilCategory function
|
|
13154
|
+
* @dbxUtilKind factory
|
|
13155
|
+
* @dbxUtilTags function, forward, late-binding, factory, lazy
|
|
13156
|
+
* @dbxUtilRelated default-forward-function-factory
|
|
13157
|
+
*
|
|
12430
13158
|
* @param getter - A Getter that provides the target function
|
|
12431
13159
|
* @returns A forwarding function with the same signature as the target
|
|
13160
|
+
* @__NO_SIDE_EFFECTS__
|
|
12432
13161
|
*/ function forwardFunction(getter) {
|
|
12433
13162
|
return function() {
|
|
12434
13163
|
for(var _len = arguments.length, args = new Array(_len), _key = 0; _key < _len; _key++){
|
|
@@ -12442,8 +13171,15 @@ function _unsupported_iterable_to_array$j(o, minLen) {
|
|
|
12442
13171
|
* Creates a factory that produces forwarding functions which use the provided function
|
|
12443
13172
|
* or fall back to the default function when not provided.
|
|
12444
13173
|
*
|
|
13174
|
+
* @dbxUtil
|
|
13175
|
+
* @dbxUtilCategory function
|
|
13176
|
+
* @dbxUtilKind factory
|
|
13177
|
+
* @dbxUtilTags function, forward, factory, default, fallback
|
|
13178
|
+
* @dbxUtilRelated forward-function
|
|
13179
|
+
*
|
|
12445
13180
|
* @param defaultFn - The default function to use as fallback
|
|
12446
13181
|
* @returns A factory that wraps optional functions with a default fallback
|
|
13182
|
+
* @__NO_SIDE_EFFECTS__
|
|
12447
13183
|
*/ function defaultForwardFunctionFactory(defaultFn) {
|
|
12448
13184
|
return function(fn) {
|
|
12449
13185
|
return forwardFunction(function() {
|
|
@@ -12979,9 +13715,16 @@ function _ts_generator$8(thisArg, body) {
|
|
|
12979
13715
|
* The factory generates identifiers in batches, filters them for uniqueness, and verifies each batch
|
|
12980
13716
|
* using the configured verifier. Throws if uniqueness generation fails repeatedly (after 20 attempts).
|
|
12981
13717
|
*
|
|
13718
|
+
* @dbxUtil
|
|
13719
|
+
* @dbxUtilCategory model
|
|
13720
|
+
* @dbxUtilKind factory
|
|
13721
|
+
* @dbxUtilTags model, id, batch, factory, async, unique, identifier
|
|
13722
|
+
* @dbxUtilRelated sequential-incrementing-number-string-model-id-factory
|
|
13723
|
+
*
|
|
12982
13724
|
* @param config - Configuration with the base factory for generating candidates and the verifier for validating them
|
|
12983
13725
|
* @returns An async factory function that produces the requested number of valid identifiers
|
|
12984
13726
|
* @throws Error if the factory cannot produce enough unique values after repeated attempts
|
|
13727
|
+
* @__NO_SIDE_EFFECTS__
|
|
12985
13728
|
*/ function idBatchFactory(config) {
|
|
12986
13729
|
var factory = config.factory, verifier = config.verifier;
|
|
12987
13730
|
var tagsToGeneratePerBatch = verifier.maxBatchSize, _verifier_filterUnique = verifier.filterUnique, filterUnique = _verifier_filterUnique === void 0 ? function(x) {
|
|
@@ -13188,9 +13931,16 @@ function _unsupported_iterable_to_array$g(o, minLen) {
|
|
|
13188
13931
|
* Creates a new {@link PrimativeKeyDencoderFunction} that can bidirectionally encode/decode
|
|
13189
13932
|
* primitive key values based on the configured value pairs.
|
|
13190
13933
|
*
|
|
13934
|
+
* @dbxUtil
|
|
13935
|
+
* @dbxUtilCategory string
|
|
13936
|
+
* @dbxUtilKind factory
|
|
13937
|
+
* @dbxUtilTags string, encode, decode, dencoder, bidirectional, factory, primitive
|
|
13938
|
+
* @dbxUtilRelated primative-key-dencoder-map, primative-key-string-dencoder
|
|
13939
|
+
*
|
|
13191
13940
|
* @param config - configuration with value pairs and optional default fallback
|
|
13192
13941
|
* @returns a function that encodes or decodes single values or arrays
|
|
13193
13942
|
* @throws Error if a single value lookup produces a null result and no default handles it
|
|
13943
|
+
* @__NO_SIDE_EFFECTS__
|
|
13194
13944
|
*/ function primativeKeyDencoder(config) {
|
|
13195
13945
|
var _config_defaultValue = config.defaultValue, defaultValue = _config_defaultValue === void 0 ? PRIMATIVE_KEY_DENCODER_VALUE : _config_defaultValue;
|
|
13196
13946
|
var map = primativeKeyDencoderMap(config.values);
|
|
@@ -13219,9 +13969,16 @@ function _unsupported_iterable_to_array$g(o, minLen) {
|
|
|
13219
13969
|
* When no splitter is defined, all encoded values must be exactly one character long so the string
|
|
13220
13970
|
* can be split character-by-character.
|
|
13221
13971
|
*
|
|
13972
|
+
* @dbxUtil
|
|
13973
|
+
* @dbxUtilCategory string
|
|
13974
|
+
* @dbxUtilKind factory
|
|
13975
|
+
* @dbxUtilTags string, encode, decode, dencoder, splitter, factory, primitive
|
|
13976
|
+
* @dbxUtilRelated primative-key-dencoder, primative-key-dencoder-map
|
|
13977
|
+
*
|
|
13222
13978
|
* @param config - configuration with dencoder and optional splitter
|
|
13223
13979
|
* @returns a bidirectional function for string-to-array and array-to-string conversion
|
|
13224
13980
|
* @throws Error if encoded values contain the splitter character, or if values exceed one character when no splitter is defined
|
|
13981
|
+
* @__NO_SIDE_EFFECTS__
|
|
13225
13982
|
*/ function primativeKeyStringDencoder(config) {
|
|
13226
13983
|
var dencoder = typeof config.dencoder === 'function' ? config.dencoder : primativeKeyDencoder(config.dencoder);
|
|
13227
13984
|
var splitter = config.splitter;
|
|
@@ -13326,8 +14083,15 @@ function _unsupported_iterable_to_array$g(o, minLen) {
|
|
|
13326
14083
|
* Creates a {@link NumberStringDencoderFunction} from the given dencoder.
|
|
13327
14084
|
* The returned function auto-detects the input type: numbers are encoded, strings are decoded.
|
|
13328
14085
|
*
|
|
14086
|
+
* @dbxUtil
|
|
14087
|
+
* @dbxUtilCategory string
|
|
14088
|
+
* @dbxUtilKind factory
|
|
14089
|
+
* @dbxUtilTags string, number, encode, decode, dencoder, bidirectional, factory
|
|
14090
|
+
* @dbxUtilRelated number-string-dencoder, number-string-dencoder-encoded-string-value-function, number-string-dencoder-decoded-number-value-function
|
|
14091
|
+
*
|
|
13329
14092
|
* @param dencoder - the NumberStringDencoder to wrap
|
|
13330
14093
|
* @returns a bidirectional encode/decode function
|
|
14094
|
+
* @__NO_SIDE_EFFECTS__
|
|
13331
14095
|
*/ function numberStringDencoderFunction(dencoder) {
|
|
13332
14096
|
var fn = function fn(input) {
|
|
13333
14097
|
var result = typeof input === 'number' ? dencoder.encodeNumber(input) : dencoder.decodeNumber(input);
|
|
@@ -13339,8 +14103,15 @@ function _unsupported_iterable_to_array$g(o, minLen) {
|
|
|
13339
14103
|
* Creates a function that always returns the encoded string form of the input.
|
|
13340
14104
|
* Numbers are encoded; strings are passed through as-is.
|
|
13341
14105
|
*
|
|
14106
|
+
* @dbxUtil
|
|
14107
|
+
* @dbxUtilCategory string
|
|
14108
|
+
* @dbxUtilKind factory
|
|
14109
|
+
* @dbxUtilTags string, number, encode, normalize, factory
|
|
14110
|
+
* @dbxUtilRelated number-string-dencoder-function, number-string-dencoder-decoded-number-value-function
|
|
14111
|
+
*
|
|
13342
14112
|
* @param dencoder - the NumberStringDencoder to use for encoding
|
|
13343
14113
|
* @returns a function that normalizes input to an encoded string
|
|
14114
|
+
* @__NO_SIDE_EFFECTS__
|
|
13344
14115
|
*/ function numberStringDencoderEncodedStringValueFunction(dencoder) {
|
|
13345
14116
|
return function(input) {
|
|
13346
14117
|
return typeof input === 'number' ? dencoder.encodeNumber(input) : input;
|
|
@@ -13350,8 +14121,15 @@ function _unsupported_iterable_to_array$g(o, minLen) {
|
|
|
13350
14121
|
* Creates a function that always returns the decoded number form of the input.
|
|
13351
14122
|
* Strings are decoded; numbers are passed through as-is.
|
|
13352
14123
|
*
|
|
14124
|
+
* @dbxUtil
|
|
14125
|
+
* @dbxUtilCategory string
|
|
14126
|
+
* @dbxUtilKind factory
|
|
14127
|
+
* @dbxUtilTags string, number, decode, normalize, factory
|
|
14128
|
+
* @dbxUtilRelated number-string-dencoder-function, number-string-dencoder-encoded-string-value-function
|
|
14129
|
+
*
|
|
13353
14130
|
* @param dencoder - the NumberStringDencoder to use for decoding
|
|
13354
14131
|
* @returns a function that normalizes input to a decoded number
|
|
14132
|
+
* @__NO_SIDE_EFFECTS__
|
|
13355
14133
|
*/ function numberStringDencoderDecodedNumberValueFunction(dencoder) {
|
|
13356
14134
|
return function(input) {
|
|
13357
14135
|
return typeof input === 'number' ? input : dencoder.decodeNumber(input);
|
|
@@ -13476,12 +14254,19 @@ function _unsupported_iterable_to_array$g(o, minLen) {
|
|
|
13476
14254
|
* @param minSize - the minimum dimensions to enforce
|
|
13477
14255
|
* @returns a resize function that clamps each axis to the specified minimum
|
|
13478
14256
|
*
|
|
14257
|
+
* @dbxUtil
|
|
14258
|
+
* @dbxUtilCategory value
|
|
14259
|
+
* @dbxUtilKind factory
|
|
14260
|
+
* @dbxUtilTags value, vector, resize, minimum, factory, clamp
|
|
14261
|
+
* @dbxUtilRelated vector
|
|
14262
|
+
*
|
|
13479
14263
|
* @example
|
|
13480
14264
|
* ```ts
|
|
13481
14265
|
* const resize = vectorMinimumSizeResizeFunction({ x: 5 });
|
|
13482
14266
|
* resize({ x: 3, y: 10 });
|
|
13483
14267
|
* // { x: 5, y: 10 }
|
|
13484
14268
|
* ```
|
|
14269
|
+
* @__NO_SIDE_EFFECTS__
|
|
13485
14270
|
*/ function vectorMinimumSizeResizeFunction(minSize) {
|
|
13486
14271
|
return function(input) {
|
|
13487
14272
|
return {
|
|
@@ -13953,8 +14738,15 @@ function _wrap_reg_exp(re, groups, source) {
|
|
|
13953
14738
|
* Creates a {@link LatLngTupleFunction} that converts various input formats into `[lat, lng]` tuples,
|
|
13954
14739
|
* applying optional precision configuration.
|
|
13955
14740
|
*
|
|
14741
|
+
* @dbxUtil
|
|
14742
|
+
* @dbxUtilCategory value
|
|
14743
|
+
* @dbxUtilKind factory
|
|
14744
|
+
* @dbxUtilTags value, lat-lng, tuple, factory, geographic, normalize
|
|
14745
|
+
* @dbxUtilRelated lat-lng-point-function, lat-lng-string-function
|
|
14746
|
+
*
|
|
13956
14747
|
* @param config - optional configuration for precision and wrapping behavior
|
|
13957
14748
|
* @returns a function that produces lat/lng tuples from flexible inputs
|
|
14749
|
+
* @__NO_SIDE_EFFECTS__
|
|
13958
14750
|
*/ function latLngTupleFunction(config) {
|
|
13959
14751
|
var fn = latLngPointFunction(config);
|
|
13960
14752
|
return function(lat, lng) {
|
|
@@ -14037,9 +14829,16 @@ function latLngString(lat, lng) {
|
|
|
14037
14829
|
* Creates a {@link LatLngPointPrecisionFunction} that rounds both lat and lng values
|
|
14038
14830
|
* to the specified number of decimal places.
|
|
14039
14831
|
*
|
|
14832
|
+
* @dbxUtil
|
|
14833
|
+
* @dbxUtilCategory value
|
|
14834
|
+
* @dbxUtilKind factory
|
|
14835
|
+
* @dbxUtilTags value, lat-lng, precision, round, factory, geographic
|
|
14836
|
+
* @dbxUtilRelated lat-lng-point-function, cut-value-to-precision-function
|
|
14837
|
+
*
|
|
14040
14838
|
* @param precision - number of decimal places to retain
|
|
14041
14839
|
* @param precisionRounding - optional rounding strategy (e.g., floor, ceil, round)
|
|
14042
14840
|
* @returns a function that rounds points to the given precision
|
|
14841
|
+
* @__NO_SIDE_EFFECTS__
|
|
14043
14842
|
*/ function latLngPointPrecisionFunction(precision, precisionRounding) {
|
|
14044
14843
|
var precisionFunction = cutValueToPrecisionFunction(precision, precisionRounding);
|
|
14045
14844
|
return function(latLng) {
|
|
@@ -14056,8 +14855,15 @@ function latLngString(lat, lng) {
|
|
|
14056
14855
|
* Creates a {@link LatLngStringFunction} that converts various input formats into comma-separated lat/lng strings,
|
|
14057
14856
|
* applying optional precision configuration.
|
|
14058
14857
|
*
|
|
14858
|
+
* @dbxUtil
|
|
14859
|
+
* @dbxUtilCategory value
|
|
14860
|
+
* @dbxUtilKind factory
|
|
14861
|
+
* @dbxUtilTags value, lat-lng, string, factory, geographic, normalize
|
|
14862
|
+
* @dbxUtilRelated lat-lng-point-function, lat-lng-tuple-function
|
|
14863
|
+
*
|
|
14059
14864
|
* @param config - optional configuration for precision and wrapping behavior
|
|
14060
14865
|
* @returns a function that produces lat/lng strings from flexible inputs
|
|
14866
|
+
* @__NO_SIDE_EFFECTS__
|
|
14061
14867
|
*/ function latLngStringFunction(config) {
|
|
14062
14868
|
var fn = latLngPointFunction(config);
|
|
14063
14869
|
return function(lat, lng) {
|
|
@@ -14088,12 +14894,19 @@ function latLngString(lat, lng) {
|
|
|
14088
14894
|
* @returns a function that produces points from flexible inputs
|
|
14089
14895
|
* @throws {Error} when the input cannot be parsed into a valid point
|
|
14090
14896
|
*
|
|
14897
|
+
* @dbxUtil
|
|
14898
|
+
* @dbxUtilCategory value
|
|
14899
|
+
* @dbxUtilKind factory
|
|
14900
|
+
* @dbxUtilTags value, lat-lng, point, factory, geographic, normalize
|
|
14901
|
+
* @dbxUtilRelated lat-lng-point, lat-lng-tuple-function, lat-lng-string-function, lat-lng-point-precision-function
|
|
14902
|
+
*
|
|
14091
14903
|
* @example
|
|
14092
14904
|
* ```ts
|
|
14093
14905
|
* const fn = latLngPointFunction({ precision: 3 });
|
|
14094
14906
|
* const result = fn(30.59929, -96.38315);
|
|
14095
14907
|
* // result.lat === 30.599, result.lng === -96.383
|
|
14096
14908
|
* ```
|
|
14909
|
+
* @__NO_SIDE_EFFECTS__
|
|
14097
14910
|
*/ function latLngPointFunction(config) {
|
|
14098
14911
|
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
14912
|
var precisionFunction = precision != null ? latLngPointPrecisionFunction(precision, precisionRounding) : mapIdentityFunction();
|
|
@@ -14164,8 +14977,15 @@ function latLngString(lat, lng) {
|
|
|
14164
14977
|
/**
|
|
14165
14978
|
* Creates a {@link ValidLatLngPointFunction} that returns the input point when valid, or a default point otherwise.
|
|
14166
14979
|
*
|
|
14980
|
+
* @dbxUtil
|
|
14981
|
+
* @dbxUtilCategory value
|
|
14982
|
+
* @dbxUtilKind factory
|
|
14983
|
+
* @dbxUtilTags value, lat-lng, validate, fallback, factory, geographic
|
|
14984
|
+
* @dbxUtilRelated valid-lat-lng-point, is-valid-lat-lng-point
|
|
14985
|
+
*
|
|
14167
14986
|
* @param defaultValue - factory for the fallback point; defaults to `defaultLatLngPoint`
|
|
14168
14987
|
* @returns a validation function
|
|
14988
|
+
* @__NO_SIDE_EFFECTS__
|
|
14169
14989
|
*/ function validLatLngPointFunction() {
|
|
14170
14990
|
var defaultValue = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : defaultLatLngPoint;
|
|
14171
14991
|
return function(latLngPoint) {
|
|
@@ -14175,8 +14995,15 @@ function latLngString(lat, lng) {
|
|
|
14175
14995
|
/**
|
|
14176
14996
|
* Creates a {@link LatLngDataPointFunction} that wraps a {@link LatLngRef} object with its resolved point coordinates.
|
|
14177
14997
|
*
|
|
14998
|
+
* @dbxUtil
|
|
14999
|
+
* @dbxUtilCategory value
|
|
15000
|
+
* @dbxUtilKind factory
|
|
15001
|
+
* @dbxUtilTags value, lat-lng, data-point, factory, geographic, ref
|
|
15002
|
+
* @dbxUtilRelated lat-lng-point-function
|
|
15003
|
+
*
|
|
14178
15004
|
* @param config - optional configuration for precision and wrapping behavior
|
|
14179
15005
|
* @returns a function that produces data points from lat/lng references
|
|
15006
|
+
* @__NO_SIDE_EFFECTS__
|
|
14180
15007
|
*/ function latLngDataPointFunction(config) {
|
|
14181
15008
|
var fn = latLngPointFunction(config);
|
|
14182
15009
|
return function(data) {
|
|
@@ -14191,8 +15018,15 @@ function latLngString(lat, lng) {
|
|
|
14191
15018
|
* Creates a {@link RandomLatLngFactory} that generates random points within the specified bounding box.
|
|
14192
15019
|
* The bounding box corners are capped/wrapped to valid coordinate ranges.
|
|
14193
15020
|
*
|
|
15021
|
+
* @dbxUtil
|
|
15022
|
+
* @dbxUtilCategory value
|
|
15023
|
+
* @dbxUtilKind factory
|
|
15024
|
+
* @dbxUtilTags value, lat-lng, random, factory, geographic, bounding-box
|
|
15025
|
+
* @dbxUtilRelated random-lat-lng-from-center-factory, random-number-factory
|
|
15026
|
+
*
|
|
14194
15027
|
* @param config - optional bounding box and precision configuration
|
|
14195
15028
|
* @returns a factory that produces random points within the bounds
|
|
15029
|
+
* @__NO_SIDE_EFFECTS__
|
|
14196
15030
|
*/ function randomLatLngFactory(config) {
|
|
14197
15031
|
var _$_object_spread_props = _object_spread_props$4(_object_spread$8({}, config), {
|
|
14198
15032
|
sw: _object_spread$8({
|
|
@@ -14224,8 +15058,15 @@ function latLngString(lat, lng) {
|
|
|
14224
15058
|
* Creates a {@link RandomLatLngFactory} that generates random points within a rectangle
|
|
14225
15059
|
* centered on the given point, extending by `latDistance` and `lngDistance` in each direction.
|
|
14226
15060
|
*
|
|
15061
|
+
* @dbxUtil
|
|
15062
|
+
* @dbxUtilCategory value
|
|
15063
|
+
* @dbxUtilKind factory
|
|
15064
|
+
* @dbxUtilTags value, lat-lng, random, factory, geographic, center
|
|
15065
|
+
* @dbxUtilRelated random-lat-lng-factory, random-number-factory
|
|
15066
|
+
*
|
|
14227
15067
|
* @param config - center point, distances, and optional precision
|
|
14228
15068
|
* @returns a factory that produces random points near the center
|
|
15069
|
+
* @__NO_SIDE_EFFECTS__
|
|
14229
15070
|
*/ function randomLatLngFromCenterFactory(config) {
|
|
14230
15071
|
var center = config.center, latDistance = config.latDistance, lngDistance = config.lngDistance, precision = config.precision;
|
|
14231
15072
|
var sw = {
|
|
@@ -14477,8 +15318,15 @@ function _unsupported_iterable_to_array$e(o, minLen) {
|
|
|
14477
15318
|
* Creates a {@link LatLngBoundTupleFunction} that converts various bound inputs into a `[sw, ne]` tuple,
|
|
14478
15319
|
* applying optional precision to the resulting points.
|
|
14479
15320
|
*
|
|
15321
|
+
* @dbxUtil
|
|
15322
|
+
* @dbxUtilCategory value
|
|
15323
|
+
* @dbxUtilKind factory
|
|
15324
|
+
* @dbxUtilTags value, lat-lng, bound, tuple, factory, geographic
|
|
15325
|
+
* @dbxUtilRelated lat-lng-bound-function, lat-lng-bound
|
|
15326
|
+
*
|
|
14480
15327
|
* @param config - optional configuration for point precision
|
|
14481
15328
|
* @returns a function that produces bound tuples from flexible inputs
|
|
15329
|
+
* @__NO_SIDE_EFFECTS__
|
|
14482
15330
|
*/ function latLngBoundTupleFunction(config) {
|
|
14483
15331
|
var fn = latLngBoundFunction(config);
|
|
14484
15332
|
return function(input, inputNe) {
|
|
@@ -14515,12 +15363,19 @@ function _unsupported_iterable_to_array$e(o, minLen) {
|
|
|
14515
15363
|
* @returns a function that produces bounds from flexible inputs
|
|
14516
15364
|
* @throws {Error} when the input cannot be parsed into a valid bound
|
|
14517
15365
|
*
|
|
15366
|
+
* @dbxUtil
|
|
15367
|
+
* @dbxUtilCategory value
|
|
15368
|
+
* @dbxUtilKind factory
|
|
15369
|
+
* @dbxUtilTags value, lat-lng, bound, factory, geographic, normalize
|
|
15370
|
+
* @dbxUtilRelated lat-lng-bound, lat-lng-bound-tuple-function, lat-lng-point-function
|
|
15371
|
+
*
|
|
14518
15372
|
* @example
|
|
14519
15373
|
* ```ts
|
|
14520
15374
|
* const fn = latLngBoundFunction({ precision: 3 });
|
|
14521
15375
|
* const result = fn([{ lat: 20, lng: 20 }, { lat: 30, lng: 30 }]);
|
|
14522
15376
|
* // result.sw.lat === 20, result.ne.lat === 30
|
|
14523
15377
|
* ```
|
|
15378
|
+
* @__NO_SIDE_EFFECTS__
|
|
14524
15379
|
*/ function latLngBoundFunction(config) {
|
|
14525
15380
|
var _ref = config !== null && config !== void 0 ? config : {}, pointFunction = _ref.pointFunction, precision = _ref.precision;
|
|
14526
15381
|
var latLngPoint = pointFunction !== null && pointFunction !== void 0 ? pointFunction : latLngPointFunction({
|
|
@@ -14642,8 +15497,15 @@ function _unsupported_iterable_to_array$e(o, minLen) {
|
|
|
14642
15497
|
* falls entirely within the specified bound. Points are checked directly; bounds require
|
|
14643
15498
|
* both corners to be within.
|
|
14644
15499
|
*
|
|
15500
|
+
* @dbxUtil
|
|
15501
|
+
* @dbxUtilCategory value
|
|
15502
|
+
* @dbxUtilKind factory
|
|
15503
|
+
* @dbxUtilTags value, lat-lng, bound, contains, decision, factory, geographic
|
|
15504
|
+
* @dbxUtilRelated overlaps-lat-lng-bound-function, is-lat-lng-point-within-lat-lng-bound
|
|
15505
|
+
*
|
|
14645
15506
|
* @param bound - the reference bound to check containment against
|
|
14646
15507
|
* @returns a function that returns `true` if the input is within the reference bound
|
|
15508
|
+
* @__NO_SIDE_EFFECTS__
|
|
14647
15509
|
*/ function isWithinLatLngBoundFunction(bound) {
|
|
14648
15510
|
var fn = function fn(boundOrPoint) {
|
|
14649
15511
|
return isLatLngPoint(boundOrPoint) ? isLatLngPointWithinLatLngBound(boundOrPoint, bound) : isLatLngBoundWithinLatLngBound(boundOrPoint, bound);
|
|
@@ -14701,8 +15563,15 @@ function _unsupported_iterable_to_array$e(o, minLen) {
|
|
|
14701
15563
|
* overlaps the reference bound. Internally converts bounds to rectangles for overlap detection,
|
|
14702
15564
|
* handling antimeridian wrapping.
|
|
14703
15565
|
*
|
|
15566
|
+
* @dbxUtil
|
|
15567
|
+
* @dbxUtilCategory value
|
|
15568
|
+
* @dbxUtilKind factory
|
|
15569
|
+
* @dbxUtilTags value, lat-lng, bound, overlap, decision, factory, geographic
|
|
15570
|
+
* @dbxUtilRelated is-within-lat-lng-bound-function, lat-lng-bound-overlaps-lat-lng-bound
|
|
15571
|
+
*
|
|
14704
15572
|
* @param bound - the reference bound to check overlap against
|
|
14705
15573
|
* @returns a function that returns `true` if the input overlaps the reference bound
|
|
15574
|
+
* @__NO_SIDE_EFFECTS__
|
|
14706
15575
|
*/ function overlapsLatLngBoundFunction(bound) {
|
|
14707
15576
|
var a = boundToRectangle(bound);
|
|
14708
15577
|
var fn = function fn(boundOrPoint) {
|
|
@@ -14774,6 +15643,7 @@ function _unsupported_iterable_to_array$e(o, minLen) {
|
|
|
14774
15643
|
* safeCompare(null, null); // true
|
|
14775
15644
|
* safeCompare(null, undefined); // false
|
|
14776
15645
|
* ```
|
|
15646
|
+
* @__NO_SIDE_EFFECTS__
|
|
14777
15647
|
*/ function safeEqualityComparatorFunction(compare) {
|
|
14778
15648
|
return function(a, b) {
|
|
14779
15649
|
return a != null && b != null ? compare(a, b) : a === b;
|
|
@@ -14812,9 +15682,16 @@ function _unsupported_iterable_to_array$e(o, minLen) {
|
|
|
14812
15682
|
* This is a convenience wrapper around {@link compareEqualityWithValueFromItemsFunctionFactory} that
|
|
14813
15683
|
* accepts both the value reader and comparator in a single call.
|
|
14814
15684
|
*
|
|
15685
|
+
* @dbxUtil
|
|
15686
|
+
* @dbxUtilCategory value
|
|
15687
|
+
* @dbxUtilKind factory
|
|
15688
|
+
* @dbxUtilTags value, comparator, equality, factory, read
|
|
15689
|
+
* @dbxUtilRelated compare-equality-with-value-from-items-function-factory, safe-equality-comparator-function
|
|
15690
|
+
*
|
|
14815
15691
|
* @param readValues - extracts the comparable value from each item
|
|
14816
15692
|
* @param equalityComparator - compares the extracted values for equality
|
|
14817
15693
|
* @returns a function that compares two items by their extracted values
|
|
15694
|
+
* @__NO_SIDE_EFFECTS__
|
|
14818
15695
|
*/ function compareEqualityWithValueFromItemsFunction(readValues, equalityComparator) {
|
|
14819
15696
|
return compareEqualityWithValueFromItemsFunctionFactory(readValues)(equalityComparator);
|
|
14820
15697
|
}
|
|
@@ -14837,6 +15714,14 @@ function _unsupported_iterable_to_array$e(o, minLen) {
|
|
|
14837
15714
|
* fn(undefined, undefined); // true
|
|
14838
15715
|
* fn(0, 1); // false
|
|
14839
15716
|
* ```
|
|
15717
|
+
*
|
|
15718
|
+
* @dbxUtil
|
|
15719
|
+
* @dbxUtilCategory value
|
|
15720
|
+
* @dbxUtilKind factory
|
|
15721
|
+
* @dbxUtilTags value, comparator, equality, factory, read, reuse
|
|
15722
|
+
* @dbxUtilRelated compare-equality-with-value-from-items-function, safe-equality-comparator-function
|
|
15723
|
+
*
|
|
15724
|
+
* @__NO_SIDE_EFFECTS__
|
|
14840
15725
|
*/ function compareEqualityWithValueFromItemsFunctionFactory(readValues) {
|
|
14841
15726
|
var fn = function fn(equalityComparator) {
|
|
14842
15727
|
var fn = safeEqualityComparatorFunction(function(a, b) {
|
|
@@ -14914,10 +15799,21 @@ function _unsupported_iterable_to_array$d(o, minLen) {
|
|
|
14914
15799
|
* Regular expression for validating ISO8601 date strings.
|
|
14915
15800
|
*
|
|
14916
15801
|
* TODO(FUTURE): Need to improve to support negative years.
|
|
15802
|
+
*
|
|
15803
|
+
* @dbxUtil
|
|
15804
|
+
* @dbxUtilCategory date
|
|
15805
|
+
* @dbxUtilKind const
|
|
15806
|
+
* @dbxUtilTags date, iso8601, regex, string, validate
|
|
15807
|
+
* @dbxUtilRelated is-iso8601-date-string, iso8601-day-string-regex
|
|
14917
15808
|
*/ var ISO_8601_DATE_STRING_REGEX = /(\d{4,})-(\d{2})-(\d{2})T(\d{2}):(\d{2}):(\d{2})(Z|[+-](\d{2}):(\d{2}))?/;
|
|
14918
15809
|
/**
|
|
14919
15810
|
* Determines if a string is a valid ISO8601 date string.
|
|
14920
15811
|
*
|
|
15812
|
+
* @dbxUtil
|
|
15813
|
+
* @dbxUtilCategory date
|
|
15814
|
+
* @dbxUtilTags date, iso8601, string, predicate, validate
|
|
15815
|
+
* @dbxUtilRelated is-iso8601-day-string, is-utc-date-string, iso-8601-date-string-regex
|
|
15816
|
+
*
|
|
14921
15817
|
* @param input - The string to test
|
|
14922
15818
|
* @returns True if the input is a valid ISO8601 date string
|
|
14923
15819
|
*/ function isISO8601DateString(input) {
|
|
@@ -14929,10 +15825,21 @@ function _unsupported_iterable_to_array$d(o, minLen) {
|
|
|
14929
15825
|
* Sat, 03 Feb 2001 04:05:06 GMT
|
|
14930
15826
|
* Tue, 14 Mar 2023 12:34:56 UTC
|
|
14931
15827
|
* Wed, 25 May 2024 20:45:07 EST
|
|
15828
|
+
*
|
|
15829
|
+
* @dbxUtil
|
|
15830
|
+
* @dbxUtilCategory date
|
|
15831
|
+
* @dbxUtilKind const
|
|
15832
|
+
* @dbxUtilTags date, utc, regex, string, validate
|
|
15833
|
+
* @dbxUtilRelated is-utc-date-string
|
|
14932
15834
|
*/ var UTC_DATE_STRING_REGEX = /^([a-zA-Z]{3}, \d{2} [a-zA-Z]{3} \d{4} \d{2}:\d{2}:\d{2} [A-Z]{3})$/;
|
|
14933
15835
|
/**
|
|
14934
15836
|
* Determines if a string is a valid UTC date string.
|
|
14935
15837
|
*
|
|
15838
|
+
* @dbxUtil
|
|
15839
|
+
* @dbxUtilCategory date
|
|
15840
|
+
* @dbxUtilTags date, utc, string, predicate, validate
|
|
15841
|
+
* @dbxUtilRelated is-iso8601-date-string, utc-date-string-regex
|
|
15842
|
+
*
|
|
14936
15843
|
* @param input - The string to test
|
|
14937
15844
|
* @returns True if the input is a valid UTC date string
|
|
14938
15845
|
*/ function isUTCDateString(input) {
|
|
@@ -14941,6 +15848,11 @@ function _unsupported_iterable_to_array$d(o, minLen) {
|
|
|
14941
15848
|
/**
|
|
14942
15849
|
* Returns true only if the inputs have the same timezone, or both do not have a timezone set.
|
|
14943
15850
|
*
|
|
15851
|
+
* @dbxUtil
|
|
15852
|
+
* @dbxUtilCategory date
|
|
15853
|
+
* @dbxUtilTags date, timezone, compare, equal, predicate
|
|
15854
|
+
* @dbxUtilRelated is-considered-utc-timezone-string
|
|
15855
|
+
*
|
|
14944
15856
|
* @param a - First object that may contain a timezone reference
|
|
14945
15857
|
* @param b - Second object that may contain a timezone reference
|
|
14946
15858
|
* @returns True if both objects have the same timezone or neither has a timezone set
|
|
@@ -14951,21 +15863,44 @@ function _unsupported_iterable_to_array$d(o, minLen) {
|
|
|
14951
15863
|
}
|
|
14952
15864
|
/**
|
|
14953
15865
|
* Constant for the UTC timezone string, "UTC".
|
|
15866
|
+
*
|
|
15867
|
+
* @dbxUtil
|
|
15868
|
+
* @dbxUtilCategory date
|
|
15869
|
+
* @dbxUtilKind const
|
|
15870
|
+
* @dbxUtilTags date, timezone, utc, string, constant
|
|
15871
|
+
* @dbxUtilRelated is-considered-utc-timezone-string
|
|
14954
15872
|
*/ var UTC_TIMEZONE_STRING = 'UTC';
|
|
14955
15873
|
function isConsideredUtcTimezoneString(timezone) {
|
|
14956
15874
|
return timezone == null || timezone === UTC_TIMEZONE_STRING;
|
|
14957
15875
|
}
|
|
14958
15876
|
/**
|
|
14959
15877
|
* Regex for an ISO8601DayString.
|
|
15878
|
+
*
|
|
15879
|
+
* @dbxUtil
|
|
15880
|
+
* @dbxUtilCategory date
|
|
15881
|
+
* @dbxUtilKind const
|
|
15882
|
+
* @dbxUtilTags date, iso8601, day, regex, string, validate
|
|
15883
|
+
* @dbxUtilRelated is-iso8601-day-string, iso8601-day-string-start-regex
|
|
14960
15884
|
*/ var ISO8601_DAY_STRING_REGEX = /^\d{4,}-\d{2}-\d{2}$/;
|
|
14961
15885
|
/**
|
|
14962
15886
|
* Regex for a string that starts as an ISO8601DayString.
|
|
15887
|
+
*
|
|
15888
|
+
* @dbxUtil
|
|
15889
|
+
* @dbxUtilCategory date
|
|
15890
|
+
* @dbxUtilKind const
|
|
15891
|
+
* @dbxUtilTags date, iso8601, day, regex, prefix
|
|
15892
|
+
* @dbxUtilRelated is-iso8601-day-string-start, iso8601-day-string-regex
|
|
14963
15893
|
*/ var ISO8601_DAY_STRING_START_REGEX = /^\d{4,}-\d{2}-\d{2}/;
|
|
14964
15894
|
/**
|
|
14965
15895
|
* Returns the start of the input date's UTC time in UTC.
|
|
14966
15896
|
*
|
|
14967
15897
|
* I.E. 2022-01-02T04:00:00.000Z in GMT-6 returns 2022-01-02
|
|
14968
15898
|
*
|
|
15899
|
+
* @dbxUtil
|
|
15900
|
+
* @dbxUtilCategory date
|
|
15901
|
+
* @dbxUtilTags date, utc, start-of-day, day, normalize
|
|
15902
|
+
* @dbxUtilRelated start-of-day-for-system-date-in-utc, parse-iso8601-day-string-to-utc-date
|
|
15903
|
+
*
|
|
14969
15904
|
* @param date - The date to get the start of day for
|
|
14970
15905
|
* @returns A new Date set to midnight UTC of the input date's UTC day
|
|
14971
15906
|
*/ function startOfDayForUTCDateInUTC(date) {
|
|
@@ -14976,6 +15911,11 @@ function isConsideredUtcTimezoneString(timezone) {
|
|
|
14976
15911
|
*
|
|
14977
15912
|
* I.E. 2022-01-02T04:00:00.000Z in GMT-6 (10PM Jan 1st CST) returns 2022-01-01
|
|
14978
15913
|
*
|
|
15914
|
+
* @dbxUtil
|
|
15915
|
+
* @dbxUtilCategory date
|
|
15916
|
+
* @dbxUtilTags date, utc, start-of-day, system, local
|
|
15917
|
+
* @dbxUtilRelated start-of-day-for-utc-date-in-utc
|
|
15918
|
+
*
|
|
14979
15919
|
* @param date - The date to get the start of local day for
|
|
14980
15920
|
* @returns A new Date set to midnight UTC of the input date's local day
|
|
14981
15921
|
*/ function startOfDayForSystemDateInUTC(date) {
|
|
@@ -14984,6 +15924,11 @@ function isConsideredUtcTimezoneString(timezone) {
|
|
|
14984
15924
|
/**
|
|
14985
15925
|
* Parses an ISO8601DayString (YYYY-MM-DD) to a UTC Date at midnight.
|
|
14986
15926
|
*
|
|
15927
|
+
* @dbxUtil
|
|
15928
|
+
* @dbxUtilCategory date
|
|
15929
|
+
* @dbxUtilTags date, iso8601, day, parse, utc, convert
|
|
15930
|
+
* @dbxUtilRelated is-iso8601-day-string, start-of-day-for-utc-date-in-utc
|
|
15931
|
+
*
|
|
14987
15932
|
* @param inputDateString - The ISO8601 day string to parse (e.g., '2022-01-15')
|
|
14988
15933
|
* @returns A Date object set to midnight UTC on the specified day
|
|
14989
15934
|
*/ function parseISO8601DayStringToUTCDate(inputDateString) {
|
|
@@ -14993,6 +15938,11 @@ function isConsideredUtcTimezoneString(timezone) {
|
|
|
14993
15938
|
/**
|
|
14994
15939
|
* Determines if a string is a valid ISO8601 day string (YYYY-MM-DD format).
|
|
14995
15940
|
*
|
|
15941
|
+
* @dbxUtil
|
|
15942
|
+
* @dbxUtilCategory date
|
|
15943
|
+
* @dbxUtilTags date, iso8601, day, string, predicate, validate
|
|
15944
|
+
* @dbxUtilRelated is-iso8601-day-string-start, parse-iso8601-day-string-to-utc-date, iso8601-day-string-regex
|
|
15945
|
+
*
|
|
14996
15946
|
* @param input - The string to test
|
|
14997
15947
|
* @returns True if the input is a valid ISO8601 day string
|
|
14998
15948
|
*/ function isISO8601DayString(input) {
|
|
@@ -15001,6 +15951,11 @@ function isConsideredUtcTimezoneString(timezone) {
|
|
|
15001
15951
|
/**
|
|
15002
15952
|
* Determines if a string starts with a valid ISO8601 day string pattern (YYYY-MM-DD).
|
|
15003
15953
|
*
|
|
15954
|
+
* @dbxUtil
|
|
15955
|
+
* @dbxUtilCategory date
|
|
15956
|
+
* @dbxUtilTags date, iso8601, day, string, predicate, prefix
|
|
15957
|
+
* @dbxUtilRelated is-iso8601-day-string, iso8601-day-string-start-regex
|
|
15958
|
+
*
|
|
15004
15959
|
* @param input - The string to test
|
|
15005
15960
|
* @returns True if the input starts with a valid ISO8601 day string pattern
|
|
15006
15961
|
*/ function isISO8601DayStringStart(input) {
|
|
@@ -15008,10 +15963,21 @@ function isConsideredUtcTimezoneString(timezone) {
|
|
|
15008
15963
|
}
|
|
15009
15964
|
/**
|
|
15010
15965
|
* Regex for a MonthDaySlashDate.
|
|
15966
|
+
*
|
|
15967
|
+
* @dbxUtil
|
|
15968
|
+
* @dbxUtilCategory date
|
|
15969
|
+
* @dbxUtilKind const
|
|
15970
|
+
* @dbxUtilTags date, slash, month, day, regex, string, validate
|
|
15971
|
+
* @dbxUtilRelated is-month-day-slash-date
|
|
15011
15972
|
*/ var MONTH_DAY_SLASH_DATE_STRING_REGEX = /^\d{1,2}\/\d{1,2}\/\d+$/;
|
|
15012
15973
|
/**
|
|
15013
15974
|
* Determines if a string is a valid Month/Day/Year slash date format.
|
|
15014
15975
|
*
|
|
15976
|
+
* @dbxUtil
|
|
15977
|
+
* @dbxUtilCategory date
|
|
15978
|
+
* @dbxUtilTags date, slash, month, day, string, predicate, validate
|
|
15979
|
+
* @dbxUtilRelated month-day-slash-date-to-date-string, month-day-slash-date-string-regex
|
|
15980
|
+
*
|
|
15015
15981
|
* @param input - The string to test
|
|
15016
15982
|
* @returns True if the input is a valid Month/Day/Year slash date
|
|
15017
15983
|
*/ function isMonthDaySlashDate(input) {
|
|
@@ -15022,6 +15988,11 @@ function isConsideredUtcTimezoneString(timezone) {
|
|
|
15022
15988
|
* Handles single digit months and days by adding leading zeros.
|
|
15023
15989
|
* If year is only 2 digits, prepends '20' to make a 4-digit year.
|
|
15024
15990
|
*
|
|
15991
|
+
* @dbxUtil
|
|
15992
|
+
* @dbxUtilCategory date
|
|
15993
|
+
* @dbxUtilTags date, slash, day, string, convert, parse
|
|
15994
|
+
* @dbxUtilRelated is-month-day-slash-date
|
|
15995
|
+
*
|
|
15025
15996
|
* @param slashDate - The slash date string to convert (e.g., '1/1/20' or '11/15/2022')
|
|
15026
15997
|
* @returns An ISO8601 formatted day string (YYYY-MM-DD)
|
|
15027
15998
|
*/ function monthDaySlashDateToDateString(slashDate) {
|
|
@@ -15051,6 +16022,11 @@ function dateFromDateOrTimeMillisecondsNumber(input) {
|
|
|
15051
16022
|
/**
|
|
15052
16023
|
* Converts a unix timestamp number to a Date object.
|
|
15053
16024
|
*
|
|
16025
|
+
* @dbxUtil
|
|
16026
|
+
* @dbxUtilCategory date
|
|
16027
|
+
* @dbxUtilTags date, milliseconds, unix, convert, parse
|
|
16028
|
+
* @dbxUtilRelated date-from-date-or-time-milliseconds-number, unix-date-time-seconds-number-to-date
|
|
16029
|
+
*
|
|
15054
16030
|
* @param dateTimeNumber - Unix timestamp number to convert
|
|
15055
16031
|
* @returns Date object if timestamp is valid, null/undefined if timestamp is null/undefined
|
|
15056
16032
|
*/ function unixMillisecondsNumberToDate(dateTimeNumber) {
|
|
@@ -15063,6 +16039,11 @@ function dateFromDateOrTimeMillisecondsNumber(input) {
|
|
|
15063
16039
|
*
|
|
15064
16040
|
* If the input is a number of milliseconds, it is added to the current date.
|
|
15065
16041
|
*
|
|
16042
|
+
* @dbxUtil
|
|
16043
|
+
* @dbxUtilCategory date
|
|
16044
|
+
* @dbxUtilTags date, milliseconds, convert, normalize, offset
|
|
16045
|
+
* @dbxUtilRelated add-milliseconds, date-from-date-or-time-milliseconds-number
|
|
16046
|
+
*
|
|
15066
16047
|
* @param dateOrMilliseconds - The date or milliseconds to convert to a Date.
|
|
15067
16048
|
* @param now - The current date to use when adding milliseconds. Defaults to the current time.
|
|
15068
16049
|
* @returns The Date representation of the input.
|
|
@@ -15071,45 +16052,131 @@ function dateFromDateOrTimeMillisecondsNumber(input) {
|
|
|
15071
16052
|
}
|
|
15072
16053
|
/**
|
|
15073
16054
|
* Number of days in a year (ignoring leap years, which are 366 days).
|
|
16055
|
+
*
|
|
16056
|
+
* @dbxUtil
|
|
16057
|
+
* @dbxUtilCategory date
|
|
16058
|
+
* @dbxUtilKind const
|
|
16059
|
+
* @dbxUtilTags date, day, year, duration, constant
|
|
16060
|
+
* @dbxUtilRelated days-in-week
|
|
15074
16061
|
*/ var DAYS_IN_YEAR = 365;
|
|
15075
16062
|
/**
|
|
15076
16063
|
* Number of hours in a day.
|
|
16064
|
+
*
|
|
16065
|
+
* @dbxUtil
|
|
16066
|
+
* @dbxUtilCategory date
|
|
16067
|
+
* @dbxUtilKind const
|
|
16068
|
+
* @dbxUtilTags date, hour, day, duration, constant
|
|
16069
|
+
* @dbxUtilRelated minutes-in-day, ms-in-day
|
|
15077
16070
|
*/ var HOURS_IN_DAY = 24;
|
|
15078
16071
|
/**
|
|
15079
16072
|
* Number of seconds in a minute.
|
|
16073
|
+
*
|
|
16074
|
+
* @dbxUtil
|
|
16075
|
+
* @dbxUtilCategory date
|
|
16076
|
+
* @dbxUtilKind const
|
|
16077
|
+
* @dbxUtilTags date, second, minute, duration, constant
|
|
16078
|
+
* @dbxUtilRelated seconds-in-hour, ms-in-second
|
|
15080
16079
|
*/ var SECONDS_IN_MINUTE = 60;
|
|
15081
16080
|
/**
|
|
15082
16081
|
* Number of minutes in a day.
|
|
16082
|
+
*
|
|
16083
|
+
* @dbxUtil
|
|
16084
|
+
* @dbxUtilCategory date
|
|
16085
|
+
* @dbxUtilKind const
|
|
16086
|
+
* @dbxUtilTags date, minute, day, duration, constant
|
|
16087
|
+
* @dbxUtilRelated hours-in-day, minutes-in-hour
|
|
15083
16088
|
*/ var MINUTES_IN_DAY = 1440;
|
|
15084
16089
|
/**
|
|
15085
16090
|
* Number of minutes in an hour.
|
|
16091
|
+
*
|
|
16092
|
+
* @dbxUtil
|
|
16093
|
+
* @dbxUtilCategory date
|
|
16094
|
+
* @dbxUtilKind const
|
|
16095
|
+
* @dbxUtilTags date, minute, hour, duration, constant
|
|
16096
|
+
* @dbxUtilRelated minutes-in-day, seconds-in-minute
|
|
15086
16097
|
*/ var MINUTES_IN_HOUR = 60;
|
|
15087
16098
|
/**
|
|
15088
16099
|
* Number of seconds in an hour.
|
|
16100
|
+
*
|
|
16101
|
+
* @dbxUtil
|
|
16102
|
+
* @dbxUtilCategory date
|
|
16103
|
+
* @dbxUtilKind const
|
|
16104
|
+
* @dbxUtilTags date, second, hour, duration, constant
|
|
16105
|
+
* @dbxUtilRelated seconds-in-minute, minutes-in-hour
|
|
15089
16106
|
*/ var SECONDS_IN_HOUR = MINUTES_IN_HOUR * SECONDS_IN_MINUTE;
|
|
15090
16107
|
/**
|
|
15091
16108
|
* Number of milliseconds in a second.
|
|
16109
|
+
*
|
|
16110
|
+
* @dbxUtil
|
|
16111
|
+
* @dbxUtilCategory date
|
|
16112
|
+
* @dbxUtilKind const
|
|
16113
|
+
* @dbxUtilTags date, milliseconds, second, duration, constant
|
|
16114
|
+
* @dbxUtilRelated ms-in-minute, seconds-in-minute
|
|
15092
16115
|
*/ var MS_IN_SECOND = 1000;
|
|
15093
16116
|
/**
|
|
15094
16117
|
* Number of milliseconds in a minute.
|
|
16118
|
+
*
|
|
16119
|
+
* @dbxUtil
|
|
16120
|
+
* @dbxUtilCategory date
|
|
16121
|
+
* @dbxUtilKind const
|
|
16122
|
+
* @dbxUtilTags date, milliseconds, minute, duration, constant
|
|
16123
|
+
* @dbxUtilRelated ms-in-second, ms-in-hour
|
|
15095
16124
|
*/ var MS_IN_MINUTE = MS_IN_SECOND * 60;
|
|
15096
16125
|
/**
|
|
15097
16126
|
* Number of milliseconds in an hour.
|
|
16127
|
+
*
|
|
16128
|
+
* @dbxUtil
|
|
16129
|
+
* @dbxUtilCategory date
|
|
16130
|
+
* @dbxUtilKind const
|
|
16131
|
+
* @dbxUtilTags date, milliseconds, hour, duration, constant
|
|
16132
|
+
* @dbxUtilRelated ms-in-minute, ms-in-day
|
|
15098
16133
|
*/ var MS_IN_HOUR = MS_IN_MINUTE * 60;
|
|
15099
16134
|
/**
|
|
15100
16135
|
* Number of milliseconds in a day.
|
|
16136
|
+
*
|
|
16137
|
+
* @dbxUtil
|
|
16138
|
+
* @dbxUtilCategory date
|
|
16139
|
+
* @dbxUtilKind const
|
|
16140
|
+
* @dbxUtilTags date, milliseconds, day, duration, constant
|
|
16141
|
+
* @dbxUtilRelated ms-in-hour, ms-in-week, hours-in-day
|
|
15101
16142
|
*/ var MS_IN_DAY = MS_IN_HOUR * HOURS_IN_DAY;
|
|
16143
|
+
/**
|
|
16144
|
+
* Number of seconds in a day.
|
|
16145
|
+
*
|
|
16146
|
+
* @dbxUtil
|
|
16147
|
+
* @dbxUtilCategory date
|
|
16148
|
+
* @dbxUtilKind const
|
|
16149
|
+
* @dbxUtilTags date, seconds, day, duration, constant
|
|
16150
|
+
* @dbxUtilRelated seconds-in-hour, seconds-in-week
|
|
16151
|
+
*/ var SECONDS_IN_DAY = SECONDS_IN_HOUR * HOURS_IN_DAY;
|
|
15102
16152
|
/**
|
|
15103
16153
|
* Number of days in a week.
|
|
16154
|
+
*
|
|
16155
|
+
* @dbxUtil
|
|
16156
|
+
* @dbxUtilCategory date
|
|
16157
|
+
* @dbxUtilKind const
|
|
16158
|
+
* @dbxUtilTags date, day, week, duration, constant
|
|
16159
|
+
* @dbxUtilRelated ms-in-week, days-in-year
|
|
15104
16160
|
*/ var DAYS_IN_WEEK = 7;
|
|
15105
16161
|
/**
|
|
15106
16162
|
* Number of milliseconds in a week.
|
|
16163
|
+
*
|
|
16164
|
+
* @dbxUtil
|
|
16165
|
+
* @dbxUtilCategory date
|
|
16166
|
+
* @dbxUtilKind const
|
|
16167
|
+
* @dbxUtilTags date, milliseconds, week, duration, constant
|
|
16168
|
+
* @dbxUtilRelated ms-in-day, days-in-week
|
|
15107
16169
|
*/ var MS_IN_WEEK = MS_IN_DAY * DAYS_IN_WEEK;
|
|
15108
16170
|
/**
|
|
15109
16171
|
* Retrieves the MonthOfYear value (1-12) from the input Date in the current system timezone.
|
|
15110
16172
|
*
|
|
15111
16173
|
* Converts JavaScript's 0-based month (0-11) to a 1-based month (1-12).
|
|
15112
16174
|
*
|
|
16175
|
+
* @dbxUtil
|
|
16176
|
+
* @dbxUtilCategory date
|
|
16177
|
+
* @dbxUtilTags date, month, year, accessor, system, local
|
|
16178
|
+
* @dbxUtilRelated month-of-year-from-date-month, month-of-year-from-utc-date
|
|
16179
|
+
*
|
|
15113
16180
|
* @param date - The date to extract the month from
|
|
15114
16181
|
* @returns The month of year as a number from 1-12
|
|
15115
16182
|
*/ function monthOfYearFromDate(date) {
|
|
@@ -15120,6 +16187,11 @@ function dateFromDateOrTimeMillisecondsNumber(input) {
|
|
|
15120
16187
|
*
|
|
15121
16188
|
* Converts JavaScript's 0-based month (0-11) to a 1-based month (1-12).
|
|
15122
16189
|
*
|
|
16190
|
+
* @dbxUtil
|
|
16191
|
+
* @dbxUtilCategory date
|
|
16192
|
+
* @dbxUtilTags date, month, year, accessor, utc
|
|
16193
|
+
* @dbxUtilRelated month-of-year-from-date, month-of-year-from-date-month
|
|
16194
|
+
*
|
|
15123
16195
|
* @param date - The date to extract the month from
|
|
15124
16196
|
* @returns The month of year as a number from 1-12
|
|
15125
16197
|
*/ function monthOfYearFromUTCDate(date) {
|
|
@@ -15128,6 +16200,11 @@ function dateFromDateOrTimeMillisecondsNumber(input) {
|
|
|
15128
16200
|
/**
|
|
15129
16201
|
* Converts a JavaScript Date month (0-11) to a MonthOfYear (1-12).
|
|
15130
16202
|
*
|
|
16203
|
+
* @dbxUtil
|
|
16204
|
+
* @dbxUtilCategory date
|
|
16205
|
+
* @dbxUtilTags date, month, year, convert, javascript
|
|
16206
|
+
* @dbxUtilRelated make-date-month-for-month-of-year, month-of-year-from-date
|
|
16207
|
+
*
|
|
15131
16208
|
* @param dateMonth - JavaScript Date month (0-11)
|
|
15132
16209
|
* @returns The month of year as a number from 1-12
|
|
15133
16210
|
*/ function monthOfYearFromDateMonth(dateMonth) {
|
|
@@ -15136,8 +16213,14 @@ function dateFromDateOrTimeMillisecondsNumber(input) {
|
|
|
15136
16213
|
/**
|
|
15137
16214
|
* Converts a MonthOfYear (1-12) to a JavaScript Date month (0-11).
|
|
15138
16215
|
*
|
|
16216
|
+
* @dbxUtil
|
|
16217
|
+
* @dbxUtilCategory date
|
|
16218
|
+
* @dbxUtilTags date, month, convert, javascript
|
|
16219
|
+
* @dbxUtilRelated month-of-year-from-date-month, month-of-year-from-date
|
|
16220
|
+
*
|
|
15139
16221
|
* @param monthOfYear - Month of year (1-12)
|
|
15140
16222
|
* @returns JavaScript Date month (0-11)
|
|
16223
|
+
* @__NO_SIDE_EFFECTS__
|
|
15141
16224
|
*/ function makeDateMonthForMonthOfYear(monthOfYear) {
|
|
15142
16225
|
return monthOfYear - 1;
|
|
15143
16226
|
}
|
|
@@ -15145,6 +16228,11 @@ function dateFromDateOrTimeMillisecondsNumber(input) {
|
|
|
15145
16228
|
* Returns true if the value is a Date object.
|
|
15146
16229
|
* Uses both instanceof and Object.prototype.toString for reliable type checking.
|
|
15147
16230
|
*
|
|
16231
|
+
* @dbxUtil
|
|
16232
|
+
* @dbxUtilCategory date
|
|
16233
|
+
* @dbxUtilTags date, predicate, type-guard, validate
|
|
16234
|
+
* @dbxUtilRelated is-equal-date, is-past
|
|
16235
|
+
*
|
|
15148
16236
|
* @param value - The value to check
|
|
15149
16237
|
* @returns True if the value is a Date object
|
|
15150
16238
|
*/ function isDate(value) {
|
|
@@ -15154,6 +16242,11 @@ function dateFromDateOrTimeMillisecondsNumber(input) {
|
|
|
15154
16242
|
* Returns true if the two input dates represent the same point in time.
|
|
15155
16243
|
* Compares the timestamp values rather than the object references.
|
|
15156
16244
|
*
|
|
16245
|
+
* @dbxUtil
|
|
16246
|
+
* @dbxUtilCategory date
|
|
16247
|
+
* @dbxUtilTags date, equal, compare, predicate
|
|
16248
|
+
* @dbxUtilRelated is-date, is-past
|
|
16249
|
+
*
|
|
15157
16250
|
* @param a - First date to compare
|
|
15158
16251
|
* @param b - Second date to compare
|
|
15159
16252
|
* @returns True if the dates represent the same point in time
|
|
@@ -15163,6 +16256,11 @@ function dateFromDateOrTimeMillisecondsNumber(input) {
|
|
|
15163
16256
|
/**
|
|
15164
16257
|
* Returns true if the input date is in the past relative to the current time.
|
|
15165
16258
|
*
|
|
16259
|
+
* @dbxUtil
|
|
16260
|
+
* @dbxUtilCategory date
|
|
16261
|
+
* @dbxUtilTags date, past, compare, predicate, time
|
|
16262
|
+
* @dbxUtilRelated is-equal-date, is-date
|
|
16263
|
+
*
|
|
15166
16264
|
* @param input - The date to check
|
|
15167
16265
|
* @returns True if the date is in the past
|
|
15168
16266
|
*/ function isPast(input) {
|
|
@@ -15366,6 +16464,7 @@ var MINUTE_OF_DAY_MAXMIMUM = MINUTES_IN_DAY - 1;
|
|
|
15366
16464
|
* context(0); // true
|
|
15367
16465
|
* context(10); // false
|
|
15368
16466
|
* ```
|
|
16467
|
+
* @__NO_SIDE_EFFECTS__
|
|
15369
16468
|
*/ function isEqualContext(contextValue, fn) {
|
|
15370
16469
|
return function(value) {
|
|
15371
16470
|
return fn(contextValue, value);
|
|
@@ -15395,6 +16494,7 @@ var MINUTE_OF_DAY_MAXMIMUM = MINUTES_IN_DAY - 1;
|
|
|
15395
16494
|
* context([0, 0, 0]); // true
|
|
15396
16495
|
* context([0, 1, 2]); // false
|
|
15397
16496
|
* ```
|
|
16497
|
+
* @__NO_SIDE_EFFECTS__
|
|
15398
16498
|
*/ function areEqualContext(contextValue, fn) {
|
|
15399
16499
|
var isEqual = isEqualContext(contextValue, fn);
|
|
15400
16500
|
return function(input) {
|
|
@@ -15563,6 +16663,13 @@ var MINUTE_OF_DAY_MAXMIMUM = MINUTES_IN_DAY - 1;
|
|
|
15563
16663
|
* fn(obj);
|
|
15564
16664
|
* // obj.x === 1
|
|
15565
16665
|
* ```
|
|
16666
|
+
*
|
|
16667
|
+
* @dbxUtil
|
|
16668
|
+
* @dbxUtilCategory value
|
|
16669
|
+
* @dbxUtilTags modifier, map, factory, compose
|
|
16670
|
+
* @dbxUtilRelated maybe-modifier-map-to-function, modifier
|
|
16671
|
+
*
|
|
16672
|
+
* @__NO_SIDE_EFFECTS__
|
|
15566
16673
|
*/ function modifierMapToFunction(map) {
|
|
15567
16674
|
var _maybeModifierMapToFunction;
|
|
15568
16675
|
return (_maybeModifierMapToFunction = maybeModifierMapToFunction(map)) !== null && _maybeModifierMapToFunction !== void 0 ? _maybeModifierMapToFunction : NOOP_MODIFIER;
|
|
@@ -15572,8 +16679,14 @@ var MINUTE_OF_DAY_MAXMIMUM = MINUTES_IN_DAY - 1;
|
|
|
15572
16679
|
*
|
|
15573
16680
|
* Returns undefined if no map is provided, allowing callers to distinguish "no modifiers" from "empty modifiers".
|
|
15574
16681
|
*
|
|
16682
|
+
* @dbxUtil
|
|
16683
|
+
* @dbxUtilCategory value
|
|
16684
|
+
* @dbxUtilTags modifier, map, factory, compose, optional
|
|
16685
|
+
* @dbxUtilRelated modifier-map-to-function, modifier
|
|
16686
|
+
*
|
|
15575
16687
|
* @param map - the modifier map to convert
|
|
15576
16688
|
* @returns a composed modifier function, or `undefined` if no map is provided
|
|
16689
|
+
* @__NO_SIDE_EFFECTS__
|
|
15577
16690
|
*/ function maybeModifierMapToFunction(map) {
|
|
15578
16691
|
var fn;
|
|
15579
16692
|
if (map != null) {
|
|
@@ -15845,6 +16958,14 @@ function _ts_generator$7(thisArg, body) {
|
|
|
15845
16958
|
* const fallback = mappedUseFn(undefined, () => 'wrong', 'default');
|
|
15846
16959
|
* // fallback === 'default'
|
|
15847
16960
|
* ```
|
|
16961
|
+
*
|
|
16962
|
+
* @dbxUtil
|
|
16963
|
+
* @dbxUtilCategory value
|
|
16964
|
+
* @dbxUtilKind factory
|
|
16965
|
+
* @dbxUtilTags value, use, map, factory, optional, fallback
|
|
16966
|
+
* @dbxUtilRelated wrap-use-function, use-context-function
|
|
16967
|
+
*
|
|
16968
|
+
* @__NO_SIDE_EFFECTS__
|
|
15848
16969
|
*/ function mappedUseFunction(map) {
|
|
15849
16970
|
return wrapUseFunction(useValue, map);
|
|
15850
16971
|
}
|
|
@@ -15852,9 +16973,16 @@ function _ts_generator$7(thisArg, body) {
|
|
|
15852
16973
|
* Wraps an existing {@link MappedUseFunction} with an additional mapping step, allowing further transformation
|
|
15853
16974
|
* of the intermediate value before it reaches the consumer.
|
|
15854
16975
|
*
|
|
16976
|
+
* @dbxUtil
|
|
16977
|
+
* @dbxUtilCategory value
|
|
16978
|
+
* @dbxUtilKind factory
|
|
16979
|
+
* @dbxUtilTags value, use, map, wrap, compose, factory
|
|
16980
|
+
* @dbxUtilRelated mapped-use-function, use-value
|
|
16981
|
+
*
|
|
15855
16982
|
* @param mappedUseFn - the existing mapped use function to wrap
|
|
15856
16983
|
* @param map - additional transformation applied to the intermediate value
|
|
15857
16984
|
* @returns a new MappedUseFunction with the extra mapping layer
|
|
16985
|
+
* @__NO_SIDE_EFFECTS__
|
|
15858
16986
|
*/ function wrapUseFunction(mappedUseFn, map) {
|
|
15859
16987
|
return function(input, useFn, defaultValue) {
|
|
15860
16988
|
return mappedUseFn(input, function(value) {
|
|
@@ -15866,9 +16994,16 @@ function _ts_generator$7(thisArg, body) {
|
|
|
15866
16994
|
* Creates a {@link UseContextFunction} by binding a consumer and optional default value, so callers
|
|
15867
16995
|
* only need to supply the input.
|
|
15868
16996
|
*
|
|
16997
|
+
* @dbxUtil
|
|
16998
|
+
* @dbxUtilCategory value
|
|
16999
|
+
* @dbxUtilKind factory
|
|
17000
|
+
* @dbxUtilTags value, use, context, factory, bind, default
|
|
17001
|
+
* @dbxUtilRelated use-value, mapped-use-function
|
|
17002
|
+
*
|
|
15869
17003
|
* @param use - the consumer function to bind
|
|
15870
17004
|
* @param defaultValue - fallback when input is null/undefined
|
|
15871
17005
|
* @returns a single-argument function that applies the bound consumer
|
|
17006
|
+
* @__NO_SIDE_EFFECTS__
|
|
15872
17007
|
*/ function useContextFunction(use, defaultValue) {
|
|
15873
17008
|
return function(input) {
|
|
15874
17009
|
var result;
|
|
@@ -15940,6 +17075,14 @@ function _ts_generator$7(thisArg, body) {
|
|
|
15940
17075
|
* const result = await mappedUseAsyncFn(1, () => Promise.resolve('hello'));
|
|
15941
17076
|
* // result === 'hello'
|
|
15942
17077
|
* ```
|
|
17078
|
+
*
|
|
17079
|
+
* @dbxUtil
|
|
17080
|
+
* @dbxUtilCategory value
|
|
17081
|
+
* @dbxUtilKind factory
|
|
17082
|
+
* @dbxUtilTags value, use, async, map, factory, promise
|
|
17083
|
+
* @dbxUtilRelated wrap-use-async-function, mapped-use-function
|
|
17084
|
+
*
|
|
17085
|
+
* @__NO_SIDE_EFFECTS__
|
|
15943
17086
|
*/ function mappedUseAsyncFunction(map) {
|
|
15944
17087
|
return wrapUseAsyncFunction(useAsync, map);
|
|
15945
17088
|
}
|
|
@@ -15947,9 +17090,16 @@ function _ts_generator$7(thisArg, body) {
|
|
|
15947
17090
|
* Wraps an existing {@link MappedUseAsyncFunction} with an additional async-capable mapping step,
|
|
15948
17091
|
* allowing further transformation of the intermediate value before it reaches the consumer.
|
|
15949
17092
|
*
|
|
17093
|
+
* @dbxUtil
|
|
17094
|
+
* @dbxUtilCategory value
|
|
17095
|
+
* @dbxUtilKind factory
|
|
17096
|
+
* @dbxUtilTags value, use, async, map, wrap, compose, factory, promise
|
|
17097
|
+
* @dbxUtilRelated mapped-use-async-function, wrap-use-function
|
|
17098
|
+
*
|
|
15950
17099
|
* @param mappedUsePromiseFn - the existing async mapped use function to wrap
|
|
15951
17100
|
* @param map - additional transformation (sync or async) applied to the intermediate value
|
|
15952
17101
|
* @returns a new MappedUseAsyncFunction with the extra mapping layer
|
|
17102
|
+
* @__NO_SIDE_EFFECTS__
|
|
15953
17103
|
*/ function wrapUseAsyncFunction(mappedUsePromiseFn, map) {
|
|
15954
17104
|
return function(input, useFn, defaultValue) {
|
|
15955
17105
|
return mappedUsePromiseFn(input, function(value) {
|
|
@@ -15988,12 +17138,19 @@ function _ts_generator$7(thisArg, body) {
|
|
|
15988
17138
|
* @returns A factory function that returns the next encoded string identifier on each call
|
|
15989
17139
|
* @throws Error if `increaseBy` is 0
|
|
15990
17140
|
*
|
|
17141
|
+
* @dbxUtil
|
|
17142
|
+
* @dbxUtilCategory model
|
|
17143
|
+
* @dbxUtilKind factory
|
|
17144
|
+
* @dbxUtilTags model, id, factory, sequential, incrementing, dencoder
|
|
17145
|
+
* @dbxUtilRelated id-batch-factory, number-string-dencoder-function
|
|
17146
|
+
*
|
|
15991
17147
|
* @example
|
|
15992
17148
|
* ```ts
|
|
15993
17149
|
* const factory = sequentialIncrementingNumberStringModelIdFactory({ startAt: 0 });
|
|
15994
17150
|
* const first = factory(); // encoded representation of 0
|
|
15995
17151
|
* const second = factory(); // encoded representation of 1
|
|
15996
17152
|
* ```
|
|
17153
|
+
* @__NO_SIDE_EFFECTS__
|
|
15997
17154
|
*/ function sequentialIncrementingNumberStringModelIdFactory() {
|
|
15998
17155
|
var config = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
|
|
15999
17156
|
var inputTranformFunction = config.transform, inputDencoder = config.dencoder, currentIndex = config.currentIndex, inputStartAt = config.startAt, inputIncreaseBy = config.increaseBy;
|
|
@@ -16048,8 +17205,15 @@ function _unsupported_iterable_to_array$c(o, minLen) {
|
|
|
16048
17205
|
* The first object is stored fully. Subsequent objects store only fields that changed from the previous entry.
|
|
16049
17206
|
* Null in a delta entry means the field was cleared. Undefined (missing key) means no change.
|
|
16050
17207
|
*
|
|
17208
|
+
* @dbxUtil
|
|
17209
|
+
* @dbxUtilCategory object
|
|
17210
|
+
* @dbxUtilKind factory
|
|
17211
|
+
* @dbxUtilTags object, delta, array, compress, expand, factory
|
|
17212
|
+
* @dbxUtilRelated equality-comparator-function, object-keys-equality-comparator-function
|
|
17213
|
+
*
|
|
16051
17214
|
* @param config - Configuration with the equality checker that defines which fields to track
|
|
16052
17215
|
* @returns A compressor with `compress` and `expand` methods
|
|
17216
|
+
* @__NO_SIDE_EFFECTS__
|
|
16053
17217
|
*/ function objectDeltaArrayCompressor(config) {
|
|
16054
17218
|
var _equalityChecker = config.equalityChecker;
|
|
16055
17219
|
var assignKnownValuesToCopy = assignValuesToPOJOFunction({
|
|
@@ -16692,8 +17856,15 @@ function _unsupported_iterable_to_array$b(o, minLen) {
|
|
|
16692
17856
|
/**
|
|
16693
17857
|
* Creates a function that returns the name for a given DayOfWeek.
|
|
16694
17858
|
*
|
|
17859
|
+
* @dbxUtil
|
|
17860
|
+
* @dbxUtilCategory date
|
|
17861
|
+
* @dbxUtilKind factory
|
|
17862
|
+
* @dbxUtilTags date, week, day-of-week, name, factory, format
|
|
17863
|
+
* @dbxUtilRelated days-of-week-name-map
|
|
17864
|
+
*
|
|
16695
17865
|
* @param transform - Optional configuration for abbreviation and casing
|
|
16696
17866
|
* @returns A function that maps DayOfWeek values to name strings
|
|
17867
|
+
* @__NO_SIDE_EFFECTS__
|
|
16697
17868
|
*/ function daysOfWeekNameFunction(transform) {
|
|
16698
17869
|
var map = daysOfWeekNameMap(transform);
|
|
16699
17870
|
return function(dayOfWeek) {
|
|
@@ -17211,9 +18382,16 @@ function _object_spread_props$3(target, source) {
|
|
|
17211
18382
|
/**
|
|
17212
18383
|
* Wraps an existing factory with a {@link ToStringFunction} to produce strings from the factory's output.
|
|
17213
18384
|
*
|
|
18385
|
+
* @dbxUtil
|
|
18386
|
+
* @dbxUtilCategory string
|
|
18387
|
+
* @dbxUtilKind factory
|
|
18388
|
+
* @dbxUtilTags string, factory, wrap, transform, to-string
|
|
18389
|
+
* @dbxUtilRelated string-from-date-factory, string-from-time-factory
|
|
18390
|
+
*
|
|
17214
18391
|
* @param factory - the original value factory
|
|
17215
18392
|
* @param toStringFunction - function to convert the factory's output to a string
|
|
17216
18393
|
* @returns a new factory that produces string values
|
|
18394
|
+
* @__NO_SIDE_EFFECTS__
|
|
17217
18395
|
*/ function stringFactoryFromFactory(factory, toStringFunction) {
|
|
17218
18396
|
return function() {
|
|
17219
18397
|
return toStringFunction(factory());
|
|
@@ -17221,9 +18399,16 @@ function _object_spread_props$3(target, source) {
|
|
|
17221
18399
|
}
|
|
17222
18400
|
/**
|
|
17223
18401
|
* Creates a factory that returns a string based on the input date.
|
|
17224
|
-
|
|
18402
|
+
*
|
|
18403
|
+
* @dbxUtil
|
|
18404
|
+
* @dbxUtilCategory string
|
|
18405
|
+
* @dbxUtilKind factory
|
|
18406
|
+
* @dbxUtilTags string, date, factory, transform, slice
|
|
18407
|
+
* @dbxUtilRelated string-from-time-factory, string-factory-from-factory, transform-string-function
|
|
18408
|
+
*
|
|
17225
18409
|
* @param config Configuration for the factory.
|
|
17226
18410
|
* @returns A factory that returns a string based on the input date.
|
|
18411
|
+
* @__NO_SIDE_EFFECTS__
|
|
17227
18412
|
*/ function stringFromDateFactory(config) {
|
|
17228
18413
|
var _ref;
|
|
17229
18414
|
var takeFromEnd = config.takeFromEnd, transformStringConfig = config.transformStringConfig, dateToString = config.dateToString;
|
|
@@ -17241,8 +18426,15 @@ function _object_spread_props$3(target, source) {
|
|
|
17241
18426
|
/**
|
|
17242
18427
|
* Creates a factory that returns a string based on the Unix timestamp of the input date.
|
|
17243
18428
|
*
|
|
18429
|
+
* @dbxUtil
|
|
18430
|
+
* @dbxUtilCategory string
|
|
18431
|
+
* @dbxUtilKind factory
|
|
18432
|
+
* @dbxUtilTags string, date, time, timestamp, factory, suffix
|
|
18433
|
+
* @dbxUtilRelated string-from-date-factory
|
|
18434
|
+
*
|
|
17244
18435
|
* @param digitsFromEnd The number of digits to return from the end of the generated string. Defaults to 7.
|
|
17245
18436
|
* @returns A StringFromDateFactory.
|
|
18437
|
+
* @__NO_SIDE_EFFECTS__
|
|
17246
18438
|
*/ function stringFromTimeFactory() {
|
|
17247
18439
|
var digitsFromEnd = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : 7;
|
|
17248
18440
|
return stringFromDateFactory({
|
|
@@ -17850,8 +19042,15 @@ function _performAsyncTask(_0, _1) {
|
|
|
17850
19042
|
* Creates a reusable function that performs tasks in parallel with optional concurrency limits
|
|
17851
19043
|
* and non-concurrent task key constraints.
|
|
17852
19044
|
*
|
|
19045
|
+
* @dbxUtil
|
|
19046
|
+
* @dbxUtilCategory promise
|
|
19047
|
+
* @dbxUtilKind factory
|
|
19048
|
+
* @dbxUtilTags promise, parallel, factory, concurrency, async, tasks
|
|
19049
|
+
* @dbxUtilRelated perform-tasks-in-parallel, perform-async-tasks-function
|
|
19050
|
+
*
|
|
17853
19051
|
* @param config - Configuration for task factory, parallelism limits, and concurrency keys.
|
|
17854
19052
|
* @returns A function that accepts an array of inputs and returns a Promise resolving when all tasks complete.
|
|
19053
|
+
* @__NO_SIDE_EFFECTS__
|
|
17855
19054
|
*/ function performTasksInParallelFunction(config) {
|
|
17856
19055
|
var taskFactory = config.taskFactory, sequential = config.sequential, nonConcurrentTaskKeyFactory = config.nonConcurrentTaskKeyFactory, inputMaxParallelTasks = config.maxParallelTasks; config.waitBetweenTasks;
|
|
17857
19056
|
var defaultNonConcurrentTaskKeyFactory = makeDefaultNonConcurrentTaskKeyFactory();
|
|
@@ -17893,8 +19092,15 @@ function _performAsyncTask(_0, _1) {
|
|
|
17893
19092
|
* Creates a function that pulls task inputs from a factory and executes them in parallel
|
|
17894
19093
|
* with configurable concurrency limits and non-concurrent key constraints.
|
|
17895
19094
|
*
|
|
19095
|
+
* @dbxUtil
|
|
19096
|
+
* @dbxUtilCategory promise
|
|
19097
|
+
* @dbxUtilKind factory
|
|
19098
|
+
* @dbxUtilTags promise, parallel, factory, concurrency, async, pull-tasks
|
|
19099
|
+
* @dbxUtilRelated perform-tasks-in-parallel-function
|
|
19100
|
+
*
|
|
17896
19101
|
* @param config - Configuration for the task factory, parallelism, and concurrency behavior.
|
|
17897
19102
|
* @returns a function that accepts a task input factory and returns a Promise that resolves when all tasks complete
|
|
19103
|
+
* @__NO_SIDE_EFFECTS__
|
|
17898
19104
|
*/ function performTasksFromFactoryInParallelFunction(config) {
|
|
17899
19105
|
/**
|
|
17900
19106
|
* @returns null
|
|
@@ -18160,7 +19366,14 @@ function _performAsyncTask(_0, _1) {
|
|
|
18160
19366
|
/**
|
|
18161
19367
|
* Creates a default non-concurrent task key factory that generates unique incrementing number strings.
|
|
18162
19368
|
*
|
|
19369
|
+
* @dbxUtil
|
|
19370
|
+
* @dbxUtilCategory promise
|
|
19371
|
+
* @dbxUtilKind factory
|
|
19372
|
+
* @dbxUtilTags promise, parallel, key, factory, unique, incrementing
|
|
19373
|
+
* @dbxUtilRelated perform-tasks-in-parallel-function, incrementing-number-factory
|
|
19374
|
+
*
|
|
18163
19375
|
* @returns A {@link StringFactory} that produces unique keys for identifying non-concurrent tasks.
|
|
19376
|
+
* @__NO_SIDE_EFFECTS__
|
|
18164
19377
|
*/ function makeDefaultNonConcurrentTaskKeyFactory() {
|
|
18165
19378
|
return stringFactoryFromFactory(incrementingNumberFactory(), function(x) {
|
|
18166
19379
|
return x.toString();
|
|
@@ -18523,8 +19736,15 @@ function _ts_generator$3(thisArg, body) {
|
|
|
18523
19736
|
* Creates a {@link TryWithPromiseFactoriesFunction} that sequentially tries each promise factory
|
|
18524
19737
|
* until one returns a non-null value (or a Maybe value if `successOnMaybe` is true).
|
|
18525
19738
|
*
|
|
19739
|
+
* @dbxUtil
|
|
19740
|
+
* @dbxUtilCategory promise
|
|
19741
|
+
* @dbxUtilKind factory
|
|
19742
|
+
* @dbxUtilTags promise, factory, try, sequential, fallback, async
|
|
19743
|
+
* @dbxUtilRelated run-named-async-tasks-function
|
|
19744
|
+
*
|
|
18526
19745
|
* @param config - Configuration including the array of promise factories and default behavior options.
|
|
18527
19746
|
* @returns A function that tries each factory in order for a given input.
|
|
19747
|
+
* @__NO_SIDE_EFFECTS__
|
|
18528
19748
|
*/ function tryWithPromiseFactoriesFunction(config) {
|
|
18529
19749
|
var promiseFactories = config.promiseFactories, defaultSuccessOnMaybe = config.successOnMaybe, defaultThrowErrors = config.throwErrors;
|
|
18530
19750
|
return function(input, config) {
|
|
@@ -18854,8 +20074,15 @@ function _ts_generator$2(thisArg, body) {
|
|
|
18854
20074
|
/**
|
|
18855
20075
|
* Creates a new RunNamedAsyncTasksFunction.
|
|
18856
20076
|
*
|
|
20077
|
+
* @dbxUtil
|
|
20078
|
+
* @dbxUtilCategory promise
|
|
20079
|
+
* @dbxUtilKind factory
|
|
20080
|
+
* @dbxUtilTags promise, async, task, factory, named, parallel
|
|
20081
|
+
* @dbxUtilRelated try-with-promise-factories-function
|
|
20082
|
+
*
|
|
18857
20083
|
* @param config Optional configuration.
|
|
18858
20084
|
* @returns A new RunNamedAsyncTasksFunction.
|
|
20085
|
+
* @__NO_SIDE_EFFECTS__
|
|
18859
20086
|
*/ function runNamedAsyncTasksFunction(config) {
|
|
18860
20087
|
var _ref = config !== null && config !== void 0 ? config : {}, onTaskSuccess = _ref.onTaskSuccess, onTaskFailure = _ref.onTaskFailure;
|
|
18861
20088
|
return function(inputTasks, options) {
|
|
@@ -19078,9 +20305,16 @@ function _is_native_reflect_construct$2() {
|
|
|
19078
20305
|
/**
|
|
19079
20306
|
* Creates a new Timer from the input duration.
|
|
19080
20307
|
*
|
|
20308
|
+
* @dbxUtil
|
|
20309
|
+
* @dbxUtilCategory date
|
|
20310
|
+
* @dbxUtilKind factory
|
|
20311
|
+
* @dbxUtilTags date, time, timer, factory, duration
|
|
20312
|
+
* @dbxUtilRelated timer
|
|
20313
|
+
*
|
|
19081
20314
|
* @param duration - The duration of the timer.
|
|
19082
20315
|
* @param startImmediately - Whether the timer should start immediately. Defaults to true.
|
|
19083
20316
|
* @returns The new Timer.
|
|
20317
|
+
* @__NO_SIDE_EFFECTS__
|
|
19084
20318
|
*/ function makeTimer(duration) {
|
|
19085
20319
|
var startImmediately = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : true;
|
|
19086
20320
|
var createdAt = new Date();
|
|
@@ -19572,8 +20806,15 @@ function _compareObjects(a, b, pojoFilter) {
|
|
|
19572
20806
|
*
|
|
19573
20807
|
* Fields can be specified as simple field names (using the default `===` comparator) or as config objects with custom comparators.
|
|
19574
20808
|
*
|
|
20809
|
+
* @dbxUtil
|
|
20810
|
+
* @dbxUtilCategory object
|
|
20811
|
+
* @dbxUtilKind factory
|
|
20812
|
+
* @dbxUtilTags object, equality, fields, comparator, factory
|
|
20813
|
+
* @dbxUtilRelated object-keys-equality-comparator-function, object-key-equality-comparator-function
|
|
20814
|
+
*
|
|
19575
20815
|
* @param config - Configuration with the fields to compare and an optional default equality function
|
|
19576
20816
|
* @returns A function that compares two objects and reports which fields are equal/unequal
|
|
20817
|
+
* @__NO_SIDE_EFFECTS__
|
|
19577
20818
|
*/ function objectFieldEqualityChecker(config) {
|
|
19578
20819
|
var fields = config.fields, _config_defaultEqualityFunction = config.defaultEqualityFunction, defaultEqualityFunction = _config_defaultEqualityFunction === void 0 ? function(a, b) {
|
|
19579
20820
|
return a === b;
|
|
@@ -19621,8 +20862,15 @@ function _compareObjects(a, b, pojoFilter) {
|
|
|
19621
20862
|
* Returns `true` if both arrays have the same length and produce identical key sets.
|
|
19622
20863
|
* Handles `null`/`undefined` inputs via {@link safeEqualityComparatorFunction}.
|
|
19623
20864
|
*
|
|
20865
|
+
* @dbxUtil
|
|
20866
|
+
* @dbxUtilCategory object
|
|
20867
|
+
* @dbxUtilKind factory
|
|
20868
|
+
* @dbxUtilTags object, key, equality, comparator, factory, array
|
|
20869
|
+
* @dbxUtilRelated object-key-equality-comparator-function, safe-equality-comparator-function
|
|
20870
|
+
*
|
|
19624
20871
|
* @param readKey - Function to extract one or more keys from each object
|
|
19625
20872
|
* @returns An equality comparator for arrays of keyed objects
|
|
20873
|
+
* @__NO_SIDE_EFFECTS__
|
|
19626
20874
|
*/ function objectKeysEqualityComparatorFunction(readKey) {
|
|
19627
20875
|
var readKeysSet = readKeysSetFunction(readKey);
|
|
19628
20876
|
var readKeysArray = readKeysFunction(readKey);
|
|
@@ -19646,8 +20894,15 @@ function _compareObjects(a, b, pojoFilter) {
|
|
|
19646
20894
|
*
|
|
19647
20895
|
* Handles `null`/`undefined` inputs via {@link safeEqualityComparatorFunction}.
|
|
19648
20896
|
*
|
|
20897
|
+
* @dbxUtil
|
|
20898
|
+
* @dbxUtilCategory object
|
|
20899
|
+
* @dbxUtilKind factory
|
|
20900
|
+
* @dbxUtilTags object, key, equality, comparator, factory
|
|
20901
|
+
* @dbxUtilRelated object-keys-equality-comparator-function, safe-equality-comparator-function
|
|
20902
|
+
*
|
|
19649
20903
|
* @param readKey - Function to extract the key from an object
|
|
19650
20904
|
* @returns An equality comparator for keyed objects
|
|
20905
|
+
* @__NO_SIDE_EFFECTS__
|
|
19651
20906
|
*/ function objectKeyEqualityComparatorFunction(readKey) {
|
|
19652
20907
|
return safeEqualityComparatorFunction(function(a, b) {
|
|
19653
20908
|
return readKey(a) === readKey(b);
|
|
@@ -19711,8 +20966,15 @@ function _unsupported_iterable_to_array$7(o, minLen) {
|
|
|
19711
20966
|
/**
|
|
19712
20967
|
* Creates a reusable {@link MapObjectMapFunction} that applies {@link mapObjectMap} with the given mapping function.
|
|
19713
20968
|
*
|
|
20969
|
+
* @dbxUtil
|
|
20970
|
+
* @dbxUtilCategory object
|
|
20971
|
+
* @dbxUtilKind factory
|
|
20972
|
+
* @dbxUtilTags object, map, transform, factory, values
|
|
20973
|
+
* @dbxUtilRelated map-object-map, map-object-keys-function
|
|
20974
|
+
*
|
|
19714
20975
|
* @param mapFn - Function that transforms each value (receives value and key)
|
|
19715
20976
|
* @returns A function that maps all values in an input object map
|
|
20977
|
+
* @__NO_SIDE_EFFECTS__
|
|
19716
20978
|
*/ function mapObjectMapFunction(mapFn) {
|
|
19717
20979
|
return function(object) {
|
|
19718
20980
|
return mapObjectMap(object, mapFn);
|
|
@@ -19746,8 +21008,15 @@ function _unsupported_iterable_to_array$7(o, minLen) {
|
|
|
19746
21008
|
/**
|
|
19747
21009
|
* Creates a reusable {@link MapObjectKeysFunction} that transforms the keys of an input object using the given mapping function.
|
|
19748
21010
|
*
|
|
21011
|
+
* @dbxUtil
|
|
21012
|
+
* @dbxUtilCategory object
|
|
21013
|
+
* @dbxUtilKind factory
|
|
21014
|
+
* @dbxUtilTags object, map, keys, transform, factory, rename
|
|
21015
|
+
* @dbxUtilRelated map-object-map-function, map-object-keys-to-lowercase
|
|
21016
|
+
*
|
|
19749
21017
|
* @param mapKeyFn - Function that computes the new key from the old key and its value
|
|
19750
21018
|
* @returns A function that remaps keys on any input object
|
|
21019
|
+
* @__NO_SIDE_EFFECTS__
|
|
19751
21020
|
*/ function mapObjectKeysFunction(mapKeyFn) {
|
|
19752
21021
|
return function(object) {
|
|
19753
21022
|
var target = {};
|
|
@@ -19865,9 +21134,16 @@ function _type_of$2(obj) {
|
|
|
19865
21134
|
* If the field does not exist on the source but a default is configured, the default is used.
|
|
19866
21135
|
* Otherwise, the target is left unchanged.
|
|
19867
21136
|
*
|
|
21137
|
+
* @dbxUtil
|
|
21138
|
+
* @dbxUtilCategory model
|
|
21139
|
+
* @dbxUtilKind factory
|
|
21140
|
+
* @dbxUtilTags model, copy, field, factory, default
|
|
21141
|
+
* @dbxUtilRelated make-model-map-functions, modify-model-map-functions
|
|
21142
|
+
*
|
|
19868
21143
|
* @param key - The property key to copy
|
|
19869
21144
|
* @param inputConfig - Optional config with a default value for the field
|
|
19870
21145
|
* @returns A function that copies the field from source to target
|
|
21146
|
+
* @__NO_SIDE_EFFECTS__
|
|
19871
21147
|
*/ function makeCopyModelFieldFunction(key, inputConfig) {
|
|
19872
21148
|
var config = inputConfig !== null && inputConfig !== void 0 ? inputConfig : {};
|
|
19873
21149
|
var hasDefault = objectHasKey(config, 'default');
|
|
@@ -19933,8 +21209,15 @@ function _unsupported_iterable_to_array$6(o, minLen) {
|
|
|
19933
21209
|
*
|
|
19934
21210
|
* The `to` function converts from the model (V) to data (D), while `from` converts back from data (D) to model (V).
|
|
19935
21211
|
*
|
|
21212
|
+
* @dbxUtil
|
|
21213
|
+
* @dbxUtilCategory model
|
|
21214
|
+
* @dbxUtilKind factory
|
|
21215
|
+
* @dbxUtilTags model, conversion, map, factory, bidirectional, fields
|
|
21216
|
+
* @dbxUtilRelated to-model-map-functions, modify-model-map-functions, model-field-conversions
|
|
21217
|
+
*
|
|
19936
21218
|
* @param fields - Field conversion definitions for each key in the model
|
|
19937
21219
|
* @returns Object with `from` and `to` mapping functions
|
|
21220
|
+
* @__NO_SIDE_EFFECTS__
|
|
19938
21221
|
*/ function makeModelMapFunctions(fields) {
|
|
19939
21222
|
var keys = filterKeyValueTuples(fields);
|
|
19940
21223
|
var conversionsByKey = keys.map(function(param) {
|
|
@@ -19970,8 +21253,15 @@ function _unsupported_iterable_to_array$6(o, minLen) {
|
|
|
19970
21253
|
*
|
|
19971
21254
|
* Supports optional filtering by field names and skipping undefined values via {@link ModelConversionOptions}.
|
|
19972
21255
|
*
|
|
21256
|
+
* @dbxUtil
|
|
21257
|
+
* @dbxUtilCategory model
|
|
21258
|
+
* @dbxUtilKind factory
|
|
21259
|
+
* @dbxUtilTags model, conversion, factory, fields, map, transform
|
|
21260
|
+
* @dbxUtilRelated make-model-map-functions, model-field-map-functions
|
|
21261
|
+
*
|
|
19973
21262
|
* @param fields - Array of `[key, convertFn]` tuples defining how each field is converted
|
|
19974
21263
|
* @returns A function that converts an input object to an output object
|
|
21264
|
+
* @__NO_SIDE_EFFECTS__
|
|
19975
21265
|
*/ function makeModelConversionFieldValuesFunction(fields) {
|
|
19976
21266
|
return function(input, inputTarget, options) {
|
|
19977
21267
|
var target = inputTarget !== null && inputTarget !== void 0 ? inputTarget : {};
|
|
@@ -20008,8 +21298,15 @@ function _unsupported_iterable_to_array$6(o, minLen) {
|
|
|
20008
21298
|
/**
|
|
20009
21299
|
* Compiles a {@link ModelFieldMapFunctionsConfig} into resolved {@link ModelFieldMapFunctions} with `from` and `to` mapping functions.
|
|
20010
21300
|
*
|
|
21301
|
+
* @dbxUtil
|
|
21302
|
+
* @dbxUtilCategory model
|
|
21303
|
+
* @dbxUtilKind factory
|
|
21304
|
+
* @dbxUtilTags model, field, map, factory, conversion, bidirectional
|
|
21305
|
+
* @dbxUtilRelated model-field-map-function, make-model-map-functions
|
|
21306
|
+
*
|
|
20011
21307
|
* @param config - Configuration with `from` and `to` field map configs
|
|
20012
21308
|
* @returns Compiled field map functions
|
|
21309
|
+
* @__NO_SIDE_EFFECTS__
|
|
20013
21310
|
*/ function modelFieldMapFunctions(config) {
|
|
20014
21311
|
return {
|
|
20015
21312
|
from: modelFieldMapFunction(config.from),
|
|
@@ -20024,8 +21321,15 @@ function _unsupported_iterable_to_array$6(o, minLen) {
|
|
|
20024
21321
|
* - Null/undefined input with `convertMaybe`: delegates to that function
|
|
20025
21322
|
* - Null/undefined input with `default` or `defaultInput`: uses the appropriate fallback
|
|
20026
21323
|
*
|
|
21324
|
+
* @dbxUtil
|
|
21325
|
+
* @dbxUtilCategory model
|
|
21326
|
+
* @dbxUtilKind factory
|
|
21327
|
+
* @dbxUtilTags model, field, map, factory, maybe, default, convert
|
|
21328
|
+
* @dbxUtilRelated model-field-map-functions, make-model-map-functions
|
|
21329
|
+
*
|
|
20027
21330
|
* @param config - Configuration specifying how to convert values and handle null/undefined
|
|
20028
21331
|
* @returns A function that maps Maybe input values to output values
|
|
21332
|
+
* @__NO_SIDE_EFFECTS__
|
|
20029
21333
|
*/ function modelFieldMapFunction(config) {
|
|
20030
21334
|
var convert = config.convert;
|
|
20031
21335
|
var convertMaybe = 'convertMaybe' in config ? config.convertMaybe : undefined;
|
|
@@ -20066,8 +21370,15 @@ function _unsupported_iterable_to_array$6(o, minLen) {
|
|
|
20066
21370
|
*
|
|
20067
21371
|
* Accepts a pre-built `mapFunctions` reference, a `fieldConversions` ref, or a `fields` config.
|
|
20068
21372
|
*
|
|
21373
|
+
* @dbxUtil
|
|
21374
|
+
* @dbxUtilCategory model
|
|
21375
|
+
* @dbxUtilKind factory
|
|
21376
|
+
* @dbxUtilTags model, conversion, map, factory, normalize, resolve
|
|
21377
|
+
* @dbxUtilRelated make-model-map-functions, to-model-field-conversions
|
|
21378
|
+
*
|
|
20069
21379
|
* @param input - Input that can be resolved to model map functions
|
|
20070
21380
|
* @returns Bidirectional model map functions
|
|
21381
|
+
* @__NO_SIDE_EFFECTS__
|
|
20071
21382
|
*/ function toModelMapFunctions(input) {
|
|
20072
21383
|
var mapFunctions;
|
|
20073
21384
|
if ('mapFunctions' in input) {
|
|
@@ -20166,8 +21477,15 @@ function _object_spread$2(target) {
|
|
|
20166
21477
|
*
|
|
20167
21478
|
* Optionally copies the input object before modification to avoid mutating the original.
|
|
20168
21479
|
*
|
|
21480
|
+
* @dbxUtil
|
|
21481
|
+
* @dbxUtilCategory model
|
|
21482
|
+
* @dbxUtilKind factory
|
|
21483
|
+
* @dbxUtilTags model, map, modify, factory, modifier, copy
|
|
21484
|
+
* @dbxUtilRelated make-model-map-functions, modify-model-map-function
|
|
21485
|
+
*
|
|
20169
21486
|
* @param config - Configuration with the base map functions, modifiers, and copy options
|
|
20170
21487
|
* @returns New model map functions with modifiers applied before each conversion
|
|
21488
|
+
* @__NO_SIDE_EFFECTS__
|
|
20171
21489
|
*/ function modifyModelMapFunctions(config) {
|
|
20172
21490
|
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
21491
|
var from = mapFunctions.from, to = mapFunctions.to;
|
|
@@ -20185,10 +21503,17 @@ function _object_spread$2(target) {
|
|
|
20185
21503
|
* When `copy` is true (default), the input is shallow-copied before modification to avoid mutating the original.
|
|
20186
21504
|
* If no modifier is provided, the original map function is returned unchanged.
|
|
20187
21505
|
*
|
|
21506
|
+
* @dbxUtil
|
|
21507
|
+
* @dbxUtilCategory model
|
|
21508
|
+
* @dbxUtilKind factory
|
|
21509
|
+
* @dbxUtilTags model, map, modify, factory, modifier, wrap
|
|
21510
|
+
* @dbxUtilRelated modify-model-map-functions, model-field-map-function
|
|
21511
|
+
*
|
|
20188
21512
|
* @param mapFn - The base map function to wrap
|
|
20189
21513
|
* @param modifyModel - Optional modifier to apply before mapping
|
|
20190
21514
|
* @param copy - Whether to shallow-copy the input before modifying; defaults to true
|
|
20191
21515
|
* @returns The wrapped map function, or the original if no modifier is provided
|
|
21516
|
+
* @__NO_SIDE_EFFECTS__
|
|
20192
21517
|
*/ function modifyModelMapFunction(mapFn, modifyModel) {
|
|
20193
21518
|
var copy = arguments.length > 2 && arguments[2] !== void 0 ? arguments[2] : true;
|
|
20194
21519
|
return modifyModel ? function(input, target, options) {
|
|
@@ -20203,8 +21528,15 @@ function _object_spread$2(target) {
|
|
|
20203
21528
|
/**
|
|
20204
21529
|
* Creates a function that reads a Node.js ReadableStream and converts its contents to a string using the specified encoding.
|
|
20205
21530
|
*
|
|
21531
|
+
* @dbxUtil
|
|
21532
|
+
* @dbxUtilCategory nodejs
|
|
21533
|
+
* @dbxUtilKind factory
|
|
21534
|
+
* @dbxUtilTags nodejs, stream, readable, string, factory, encoding
|
|
21535
|
+
* @dbxUtilRelated readable-stream-to-buffer, readable-stream-to-base64
|
|
21536
|
+
*
|
|
20206
21537
|
* @param encoding - The buffer encoding to use (e.g., 'utf-8', 'base64')
|
|
20207
21538
|
* @returns A function that consumes a ReadableStream and resolves to its string content
|
|
21539
|
+
* @__NO_SIDE_EFFECTS__
|
|
20208
21540
|
*/ function readableStreamToStringFunction(encoding) {
|
|
20209
21541
|
return function(stream) {
|
|
20210
21542
|
return readableStreamToBuffer(stream).then(function(x) {
|
|
@@ -20637,6 +21969,7 @@ function _unsupported_iterable_to_array$5(o, minLen) {
|
|
|
20637
21969
|
/**
|
|
20638
21970
|
* Special key used to register a catch-all handler that matches any unhandled key.
|
|
20639
21971
|
*/ var CATCH_ALL_HANDLE_RESULT_KEY = '__CATCH_ALL_HANDLE_RESULT_KEY__';
|
|
21972
|
+
// @__NO_SIDE_EFFECTS__
|
|
20640
21973
|
function handlerFactory(readKey, options) {
|
|
20641
21974
|
var _ref, _ref1;
|
|
20642
21975
|
var defaultResultValue = (_ref = options === null || options === void 0 ? void 0 : options.defaultResult) !== null && _ref !== void 0 ? _ref : true;
|
|
@@ -20685,8 +22018,15 @@ function handlerFactory(readKey, options) {
|
|
|
20685
22018
|
/**
|
|
20686
22019
|
* Convenience function that creates a new {@link Handler} from the given key reader using default options.
|
|
20687
22020
|
*
|
|
22021
|
+
* @dbxUtil
|
|
22022
|
+
* @dbxUtilCategory service
|
|
22023
|
+
* @dbxUtilKind factory
|
|
22024
|
+
* @dbxUtilTags service, handler, factory, dispatch, key, convenience
|
|
22025
|
+
* @dbxUtilRelated handler-factory
|
|
22026
|
+
*
|
|
20688
22027
|
* @param readKey - Function to extract the dispatch key from an input value.
|
|
20689
22028
|
* @returns A new Handler instance.
|
|
22029
|
+
* @__NO_SIDE_EFFECTS__
|
|
20690
22030
|
*/ function makeHandler(readKey) {
|
|
20691
22031
|
return handlerFactory(readKey)();
|
|
20692
22032
|
}
|
|
@@ -20720,9 +22060,16 @@ function handlerFactory(readKey, options) {
|
|
|
20720
22060
|
/**
|
|
20721
22061
|
* Creates a {@link HandlerSetFunction} that registers a handler function on a pre-defined key.
|
|
20722
22062
|
*
|
|
22063
|
+
* @dbxUtil
|
|
22064
|
+
* @dbxUtilCategory service
|
|
22065
|
+
* @dbxUtilKind factory
|
|
22066
|
+
* @dbxUtilTags service, handler, set, factory, register
|
|
22067
|
+
* @dbxUtilRelated handler-mapped-set-function, handler-factory
|
|
22068
|
+
*
|
|
20723
22069
|
* @param accessor - The handler set accessor to register on.
|
|
20724
22070
|
* @param key - The key (or keys) to associate the handler with.
|
|
20725
22071
|
* @returns A function that accepts a handler function and registers it for the given key.
|
|
22072
|
+
* @__NO_SIDE_EFFECTS__
|
|
20726
22073
|
*/ function handlerSetFunction(accessor, key) {
|
|
20727
22074
|
var fn = function fn(handlerFunction) {
|
|
20728
22075
|
accessor.set(key, handlerFunction); // set the handler on the pre-defined key.
|
|
@@ -20734,10 +22081,17 @@ function handlerFactory(readKey, options) {
|
|
|
20734
22081
|
* Creates a {@link HandlerMappedSetFunction} that maps the handler's native input type to a different
|
|
20735
22082
|
* type before invoking the registered handler function.
|
|
20736
22083
|
*
|
|
22084
|
+
* @dbxUtil
|
|
22085
|
+
* @dbxUtilCategory service
|
|
22086
|
+
* @dbxUtilKind factory
|
|
22087
|
+
* @dbxUtilTags service, handler, set, mapped, factory, transform
|
|
22088
|
+
* @dbxUtilRelated handler-set-function, handler-mapped-set-function-factory
|
|
22089
|
+
*
|
|
20737
22090
|
* @param accessor - The handler set accessor to register on.
|
|
20738
22091
|
* @param key - The key (or keys) to associate the handler with.
|
|
20739
22092
|
* @param mapFn - Function to map from the handler's native type to the handler function's expected type.
|
|
20740
22093
|
* @returns A function that accepts a mapped handler function and registers it.
|
|
22094
|
+
* @__NO_SIDE_EFFECTS__
|
|
20741
22095
|
*/ function handlerMappedSetFunction(accessor, key, mapFn) {
|
|
20742
22096
|
var handlerSet = handlerSetFunction(accessor, key);
|
|
20743
22097
|
return function(handlerFunction) {
|
|
@@ -20751,9 +22105,16 @@ function handlerFactory(readKey, options) {
|
|
|
20751
22105
|
/**
|
|
20752
22106
|
* Creates a {@link HandlerMappedSetFunctionFactory} that produces mapped set functions for any given key.
|
|
20753
22107
|
*
|
|
22108
|
+
* @dbxUtil
|
|
22109
|
+
* @dbxUtilCategory service
|
|
22110
|
+
* @dbxUtilKind factory
|
|
22111
|
+
* @dbxUtilTags service, handler, mapped, factory, dispatch
|
|
22112
|
+
* @dbxUtilRelated handler-mapped-set-function, handler-set-function
|
|
22113
|
+
*
|
|
20754
22114
|
* @param accessor - The handler set accessor to register on.
|
|
20755
22115
|
* @param mapFn - Function to map from the handler's native type to the handler function's expected type.
|
|
20756
22116
|
* @returns A factory that creates HandlerMappedSetFunctions for specific keys.
|
|
22117
|
+
* @__NO_SIDE_EFFECTS__
|
|
20757
22118
|
*/ function handlerMappedSetFunctionFactory(accessor, mapFn) {
|
|
20758
22119
|
return function(key) {
|
|
20759
22120
|
return handlerMappedSetFunction(accessor, key, mapFn);
|
|
@@ -20763,8 +22124,15 @@ function handlerFactory(readKey, options) {
|
|
|
20763
22124
|
* Creates a {@link HandlerConfigurerFactory} that produces configurers for binding handler functions
|
|
20764
22125
|
* to a handler instance with automatic `this` binding.
|
|
20765
22126
|
*
|
|
22127
|
+
* @dbxUtil
|
|
22128
|
+
* @dbxUtilCategory service
|
|
22129
|
+
* @dbxUtilKind factory
|
|
22130
|
+
* @dbxUtilTags service, handler, configurer, factory, bind
|
|
22131
|
+
* @dbxUtilRelated handler-bind-accessor, handler-factory
|
|
22132
|
+
*
|
|
20766
22133
|
* @param config - Configuration providing the accessor-to-configurer mapping.
|
|
20767
22134
|
* @returns A factory that creates HandlerConfigurers for specific handlers.
|
|
22135
|
+
* @__NO_SIDE_EFFECTS__
|
|
20768
22136
|
*/ function handlerConfigurerFactory(config) {
|
|
20769
22137
|
return function(handler) {
|
|
20770
22138
|
return function(bindTo, configure) {
|
|
@@ -21828,8 +23196,15 @@ function mimeTypeForFileExtension(extension) {
|
|
|
21828
23196
|
/**
|
|
21829
23197
|
* Creates a {@link SortByStringFunction} that sorts values in ascending alphabetical order using `localeCompare`.
|
|
21830
23198
|
*
|
|
23199
|
+
* @dbxUtil
|
|
23200
|
+
* @dbxUtilCategory string
|
|
23201
|
+
* @dbxUtilKind factory
|
|
23202
|
+
* @dbxUtilTags string, sort, compare, alphabetical, factory, locale
|
|
23203
|
+
* @dbxUtilRelated sort-by-label-function
|
|
23204
|
+
*
|
|
21831
23205
|
* @param readStringFn - Function to extract a string from each value for comparison.
|
|
21832
23206
|
* @returns A comparator function suitable for use with `Array.sort()`.
|
|
23207
|
+
* @__NO_SIDE_EFFECTS__
|
|
21833
23208
|
*/ function sortByStringFunction(readStringFn) {
|
|
21834
23209
|
return function(a, b) {
|
|
21835
23210
|
var as = readStringFn(a);
|
|
@@ -21846,8 +23221,15 @@ function mimeTypeForFileExtension(extension) {
|
|
|
21846
23221
|
/**
|
|
21847
23222
|
* Creates a {@link SearchStringFilterFunction} that filters values based on whether their string representation matches the filter text.
|
|
21848
23223
|
*
|
|
23224
|
+
* @dbxUtil
|
|
23225
|
+
* @dbxUtilCategory string
|
|
23226
|
+
* @dbxUtilKind factory
|
|
23227
|
+
* @dbxUtilTags string, search, filter, factory, match, decision
|
|
23228
|
+
* @dbxUtilRelated case-insensitive-filter-by-index-of-decision-factory
|
|
23229
|
+
*
|
|
21849
23230
|
* @param config - A read function or full configuration specifying how to extract and match search strings.
|
|
21850
23231
|
* @returns A function that filters an array of values by a search/filter text string.
|
|
23232
|
+
* @__NO_SIDE_EFFECTS__
|
|
21851
23233
|
*/ function searchStringFilterFunction(config) {
|
|
21852
23234
|
var _ref = typeof config === 'function' ? {
|
|
21853
23235
|
readStrings: config
|
|
@@ -21942,8 +23324,15 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
21942
23324
|
/**
|
|
21943
23325
|
* Creates a {@link SplitStringTreeFactory} that builds tree structures by splitting strings on the configured separator.
|
|
21944
23326
|
*
|
|
23327
|
+
* @dbxUtil
|
|
23328
|
+
* @dbxUtilCategory string
|
|
23329
|
+
* @dbxUtilKind factory
|
|
23330
|
+
* @dbxUtilTags string, tree, split, separator, factory, hierarchy
|
|
23331
|
+
* @dbxUtilRelated add-to-split-string-tree, find-best-split-string-tree-match
|
|
23332
|
+
*
|
|
21945
23333
|
* @param config - Configuration specifying the separator and optional metadata merge strategy.
|
|
21946
23334
|
* @returns A factory function that creates or extends split string trees.
|
|
23335
|
+
* @__NO_SIDE_EFFECTS__
|
|
21947
23336
|
*/ function splitStringTreeFactory(config) {
|
|
21948
23337
|
var separator = config.separator;
|
|
21949
23338
|
var fn = function fn(input, existing) {
|
|
@@ -22103,6 +23492,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
22103
23492
|
* @template N The type of the TreeNode to be created. Defaults to TreeNode<T, any> if not specified by ExpandTreeWithNodeBuilder.
|
|
22104
23493
|
* @param config An ExpandTree<T> or ExpandTreeWithNodeBuilder<T, N> configuration object.
|
|
22105
23494
|
* @returns An ExpandTreeFunction<T, N> that takes a root value and returns its corresponding tree structure.
|
|
23495
|
+
* @__NO_SIDE_EFFECTS__
|
|
22106
23496
|
*/ function expandTreeFunction(config) {
|
|
22107
23497
|
var _config_makeNode;
|
|
22108
23498
|
var makeNodeFromConfig = (_config_makeNode = config.makeNode) !== null && _config_makeNode !== void 0 ? _config_makeNode : function(basicNode) {
|
|
@@ -22195,6 +23585,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
22195
23585
|
* visited.push(id);
|
|
22196
23586
|
* });
|
|
22197
23587
|
* ```
|
|
23588
|
+
* @__NO_SIDE_EFFECTS__
|
|
22198
23589
|
*/ function exploreTreeFunction(config) {
|
|
22199
23590
|
var _ref, _ref1, _ref2;
|
|
22200
23591
|
var defaultMapNodeFn = (_ref = config === null || config === void 0 ? void 0 : config.mapNodeFunction) !== null && _ref !== void 0 ? _ref : MAP_IDENTITY;
|
|
@@ -22245,6 +23636,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
22245
23636
|
* });
|
|
22246
23637
|
* // Visits: root -> child1 -> leaf1 -> leaf2 -> child2 -> leaf3
|
|
22247
23638
|
* ```
|
|
23639
|
+
* @__NO_SIDE_EFFECTS__
|
|
22248
23640
|
*/ function depthFirstExploreTreeTraversalFactoryFunction() {
|
|
22249
23641
|
return function(visit, continueTraversal) {
|
|
22250
23642
|
return function(node, nodeMappedValue, visitDecision) {
|
|
@@ -22283,6 +23675,7 @@ function _unsupported_iterable_to_array(o, minLen) {
|
|
|
22283
23675
|
* });
|
|
22284
23676
|
* // Visits: root -> child1, child2, child3 -> leaf1, leaf2, leaf3
|
|
22285
23677
|
* ```
|
|
23678
|
+
* @__NO_SIDE_EFFECTS__
|
|
22286
23679
|
*/ function breadthFirstExploreTreeTraversalFactoryFunction() {
|
|
22287
23680
|
return function(visit, continueTraversal) {
|
|
22288
23681
|
var queue = [];
|
|
@@ -22455,6 +23848,7 @@ function _object_spread_props(target, source) {
|
|
|
22455
23848
|
* const ids = flattenIds(rootNode);
|
|
22456
23849
|
* // ['root', 'child1', 'leaf1', 'leaf2', 'child2', 'leaf3']
|
|
22457
23850
|
* ```
|
|
23851
|
+
* @__NO_SIDE_EFFECTS__
|
|
22458
23852
|
*/ function flattenTreeToArrayFunction(mapNodeFnOrConfig, defaultAddNodeFn) {
|
|
22459
23853
|
var _config_shouldAddNodeFunction;
|
|
22460
23854
|
var config = typeof mapNodeFnOrConfig === 'function' ? {
|
|
@@ -22493,6 +23887,7 @@ function _object_spread_props(target, source) {
|
|
|
22493
23887
|
* @param expand An ExpandTreeFunction (values: T[]) => N[] that converts an array of T into an array of tree nodes N.
|
|
22494
23888
|
* @param flatten A FlattenTreeFunction (tree: N, array?: V[]) => V[] that flattens a tree of N nodes into an array of V values.
|
|
22495
23889
|
* @returns An ExpandFlattenTreeFunction (values: T[]) => V[] that performs the combined expansion and flattening.
|
|
23890
|
+
* @__NO_SIDE_EFFECTS__
|
|
22496
23891
|
*/ function expandFlattenTreeFunction(expand, flatten) {
|
|
22497
23892
|
return function(values) {
|
|
22498
23893
|
return flatten(expandTrees(values, expand));
|
|
@@ -22619,6 +24014,7 @@ function invertMaybeBoolean(x) {
|
|
|
22619
24014
|
* const coinFlip = booleanFactory({ chance: 50 });
|
|
22620
24015
|
* coinFlip(); // true or false with equal probability
|
|
22621
24016
|
* ```
|
|
24017
|
+
* @__NO_SIDE_EFFECTS__
|
|
22622
24018
|
*/ function booleanFactory(config) {
|
|
22623
24019
|
var inputChance = config.chance;
|
|
22624
24020
|
var chance = inputChance / 100;
|
|
@@ -22796,6 +24192,7 @@ function _define_property$1(obj, key, value) {
|
|
|
22796
24192
|
* @param decodeValues - An array of potential original string values.
|
|
22797
24193
|
* @param hashFn - A function that takes a string and returns its hashed representation.
|
|
22798
24194
|
* @returns A {@link HashDecodeMap} for decoding hashed values.
|
|
24195
|
+
* @__NO_SIDE_EFFECTS__
|
|
22799
24196
|
*/ function makeHashDecodeMap(decodeValues, hashFn) {
|
|
22800
24197
|
var keyValuePairs = decodeValues.map(function(x) {
|
|
22801
24198
|
return [
|
|
@@ -23584,6 +24981,7 @@ exports.RAW_MIME_TYPE = RAW_MIME_TYPE;
|
|
|
23584
24981
|
exports.REGEX_SPECIAL_CHARACTERS = REGEX_SPECIAL_CHARACTERS;
|
|
23585
24982
|
exports.REGEX_SPECIAL_CHARACTERS_SET = REGEX_SPECIAL_CHARACTERS_SET;
|
|
23586
24983
|
exports.RelationChange = RelationChange;
|
|
24984
|
+
exports.SECONDS_IN_DAY = SECONDS_IN_DAY;
|
|
23587
24985
|
exports.SECONDS_IN_HOUR = SECONDS_IN_HOUR;
|
|
23588
24986
|
exports.SECONDS_IN_MINUTE = SECONDS_IN_MINUTE;
|
|
23589
24987
|
exports.SHARED_MEMORY_STORAGE = SHARED_MEMORY_STORAGE;
|