@dereekb/util 13.15.0 → 13.16.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/index.cjs.js CHANGED
@@ -385,7 +385,7 @@ function _unsupported_iterable_to_array$B(o, minLen) {
385
385
  * @throws {Error} If input is not an array.
386
386
  */ function wrapTuples(input) {
387
387
  if (!Array.isArray(input)) {
388
- throw new Error('Input is not an array/tuple...');
388
+ throw new TypeError('Input is not an array/tuple...');
389
389
  }
390
390
  var result;
391
391
  // check if the first item is an array. Tuples can contain arrays as the first value.
@@ -470,7 +470,7 @@ function _unsupported_iterable_to_array$A(o, minLen) {
470
470
  * @dbxUtilTags array, convert, ensure, normalize, maybe, nullish
471
471
  * @dbxUtilRelated convert-maybe-to-non-empty-array, convert-to-array, as-array
472
472
  */ function convertMaybeToArray(arrayOrValue) {
473
- return arrayOrValue != null ? convertToArray(arrayOrValue) : [];
473
+ return arrayOrValue == null ? [] : convertToArray(arrayOrValue);
474
474
  }
475
475
  /**
476
476
  * Alias for {@link convertMaybeToArray}. Converts a maybe value or array into an array, returning an empty array for nullish input.
@@ -1075,9 +1075,9 @@ function _unsupported_iterable_to_array$z(o, minLen) {
1075
1075
  * @param values - The values to filter.
1076
1076
  * @returns Intersection between the input values and the reference set.
1077
1077
  */ function keepFromSetCopy(set, values) {
1078
- return values != null ? filterValuesToSet(asIterable(values), function(x) {
1078
+ return values == null ? new Set() : filterValuesToSet(asIterable(values), function(x) {
1079
1079
  return set.has(x);
1080
- }) : new Set();
1080
+ });
1081
1081
  }
1082
1082
  /**
1083
1083
  * Filters the array to only include values that exist in the given set.
@@ -1274,15 +1274,15 @@ function _unsupported_iterable_to_array$z(o, minLen) {
1274
1274
  var set;
1275
1275
  if (config.keysToFind != null) {
1276
1276
  set = asSet(config.keysToFind);
1277
- } else if (config.valuesToFind != null) {
1278
- set = readKeysSetFrom(readKey, config.valuesToFind);
1279
- } else {
1277
+ } else if (config.valuesToFind == null) {
1280
1278
  set = new Set();
1279
+ } else {
1280
+ set = readKeysSetFrom(readKey, config.valuesToFind);
1281
1281
  }
1282
1282
  var filterFn = setHasValueFunction(set, exclude);
1283
1283
  return values.filter(function(x) {
1284
1284
  var key = readKey(x);
1285
- return key != null ? filterFn(key) : exclude;
1285
+ return key == null ? exclude : filterFn(key);
1286
1286
  });
1287
1287
  }
1288
1288
  /**
@@ -1838,12 +1838,12 @@ function _type_of$l(obj) {
1838
1838
  */ function filterMaybeArrayFunction(filterFn) {
1839
1839
  return function(values) {
1840
1840
  var result;
1841
- if (values != null) {
1841
+ if (values == null) {
1842
+ result = [];
1843
+ } else {
1842
1844
  result = values.filter(function(v, i, arr) {
1843
1845
  return filterFn(v, i, arr);
1844
1846
  });
1845
- } else {
1846
- result = [];
1847
1847
  }
1848
1848
  return result;
1849
1849
  };
@@ -2193,7 +2193,7 @@ function _unsupported_iterable_to_array$x(o, minLen) {
2193
2193
  * @param readKey - Function to extract a key from a value.
2194
2194
  * @returns Flat array of resolved non-null keys.
2195
2195
  */ function readKeysFromFilterUniqueFunctionAdditionalKeysInput(additionalKeysInput, readKey) {
2196
- return filterMaybeArrayValues(additionalKeysInput != null ? Array.isArray(additionalKeysInput) ? additionalKeysInput : readKeysFromFilterUniqueFunctionAdditionalKeys(additionalKeysInput, readKey) : []);
2196
+ return filterMaybeArrayValues(additionalKeysInput == null ? [] : Array.isArray(additionalKeysInput) ? additionalKeysInput : readKeysFromFilterUniqueFunctionAdditionalKeys(additionalKeysInput, readKey));
2197
2197
  }
2198
2198
  /**
2199
2199
  * Reads keys from a {@link FilterUniqueFunctionAdditionalKeys} object by combining explicit keys with keys derived from values.
@@ -3468,12 +3468,12 @@ function makeValuesGroupMap(values, groupKeyFn) {
3468
3468
  values.forEach(function(x) {
3469
3469
  var key = groupKeyFn(x);
3470
3470
  var array = map.get(key);
3471
- if (array != null) {
3472
- array.push(x);
3473
- } else {
3471
+ if (array == null) {
3474
3472
  map.set(key, [
3475
3473
  x
3476
3474
  ]);
3475
+ } else {
3476
+ array.push(x);
3477
3477
  }
3478
3478
  });
3479
3479
  }
@@ -3773,7 +3773,7 @@ function _unsupported_iterable_to_array$s(o, minLen) {
3773
3773
  var selectedValuesSet = new Set(selectedValues);
3774
3774
  return function(value) {
3775
3775
  var key = readKey(value);
3776
- return key != null ? selectedValuesSet.has(key) : defaultIfKeyNull;
3776
+ return key == null ? defaultIfKeyNull : selectedValuesSet.has(key);
3777
3777
  };
3778
3778
  };
3779
3779
  }
@@ -4654,14 +4654,14 @@ var DOLLAR_AMOUNT_STRING_REGEX = /^\$?(\d+)\.?(\d\d)$/;
4654
4654
  var min = config.min, max = config.max, roundConfig = config.round;
4655
4655
  var round = roundingInput !== null && roundingInput !== void 0 ? roundingInput : roundConfig;
4656
4656
  var fn;
4657
- if (min != null) {
4658
- var range = max - min;
4657
+ if (min == null) {
4659
4658
  fn = function fn() {
4660
- return Math.random() * range + min;
4659
+ return Math.random() * max;
4661
4660
  };
4662
4661
  } else {
4662
+ var range = max - min;
4663
4663
  fn = function fn() {
4664
- return Math.random() * max;
4664
+ return Math.random() * range + min;
4665
4665
  };
4666
4666
  }
4667
4667
  if (round && round !== 'none') {
@@ -5194,7 +5194,7 @@ function reduceNumbersFn(reduceFn, emptyArrayValue) {
5194
5194
  * @param input - Optional initial values to populate the set.
5195
5195
  * @returns A HashSet keyed by index number.
5196
5196
  */ function hashSetForIndexed(input) {
5197
- var values = input != null ? asArray(input) : undefined;
5197
+ var values = input == null ? undefined : asArray(input);
5198
5198
  return new HashSet({
5199
5199
  readKey: readIndexNumber
5200
5200
  }, values);
@@ -6534,6 +6534,84 @@ function caseInsensitiveString(input) {
6534
6534
  */ function splitJoinNameString(input) {
6535
6535
  return SPACE_STRING_SPLIT_JOIN.splitJoinRemainder(input, 2);
6536
6536
  }
6537
+ /**
6538
+ * Default maximum number of initials produced by a {@link NameToInitialsFunction}.
6539
+ */ var DEFAULT_NAME_TO_INITIALS_MAX_INITIALS = 2;
6540
+ /**
6541
+ * Default minimum number of initials produced by a {@link NameToInitialsFunction}.
6542
+ */ var DEFAULT_NAME_TO_INITIALS_MIN_INITIALS = 1;
6543
+ /**
6544
+ * Creates a {@link NameToInitialsFunction} that derives display initials from a name or short character string.
6545
+ *
6546
+ * Useful for avatar fallbacks where a name (e.g. `'Michelle B'`) or a literal token (e.g. `'BB'`)
6547
+ * should collapse to a compact label. By default a single-word input yields a single initial; raise
6548
+ * `minInitials` to pull more leading characters from a lone word.
6549
+ *
6550
+ * @param config - Configuration controlling the minimum and maximum number of initials.
6551
+ * @returns A reusable function that derives initials from input names.
6552
+ *
6553
+ * @dbxUtil
6554
+ * @dbxUtilCategory string
6555
+ * @dbxUtilKind factory
6556
+ * @dbxUtilTags string, name, initials, avatar, abbreviate, person, factory
6557
+ * @dbxUtilRelated split-join-name-string, capitalize-first-letter
6558
+ *
6559
+ * @example
6560
+ * ```ts
6561
+ * const toInitials = nameToInitialsFactory();
6562
+ * toInitials('Michelle B'); // 'MB'
6563
+ * toInitials('Michelle'); // 'M'
6564
+ *
6565
+ * const toPaddedInitials = nameToInitialsFactory({ minInitials: 2 });
6566
+ * toPaddedInitials('Michelle'); // 'MI'
6567
+ * toPaddedInitials('BB'); // 'BB'
6568
+ * ```
6569
+ *
6570
+ * @__NO_SIDE_EFFECTS__
6571
+ */ function nameToInitialsFactory(config) {
6572
+ var _ref, _ref1;
6573
+ var maxInitials = (_ref = config === null || config === void 0 ? void 0 : config.maxInitials) !== null && _ref !== void 0 ? _ref : DEFAULT_NAME_TO_INITIALS_MAX_INITIALS;
6574
+ var minInitials = Math.min((_ref1 = config === null || config === void 0 ? void 0 : config.minInitials) !== null && _ref1 !== void 0 ? _ref1 : DEFAULT_NAME_TO_INITIALS_MIN_INITIALS, maxInitials);
6575
+ return function(name) {
6576
+ var trimmed = name.trim();
6577
+ var result;
6578
+ if (trimmed) {
6579
+ var words = trimmed.split(/\s+/);
6580
+ if (words.length > 1) {
6581
+ result = words.slice(0, maxInitials).map(function(word) {
6582
+ return word.charAt(0);
6583
+ }).join('');
6584
+ } else {
6585
+ result = words[0].slice(0, minInitials);
6586
+ }
6587
+ } else {
6588
+ result = '';
6589
+ }
6590
+ return result.toUpperCase();
6591
+ };
6592
+ }
6593
+ /**
6594
+ * Derives display initials from a name or short character string using the default configuration.
6595
+ *
6596
+ * Multi-word inputs use the first character of each of the first two words; single-word inputs use
6597
+ * the first character verbatim. The result is always uppercased.
6598
+ *
6599
+ * @param name - Name or character string to derive initials from.
6600
+ * @returns Uppercased initials, or an empty string when the input is blank.
6601
+ *
6602
+ * @dbxUtil
6603
+ * @dbxUtilCategory string
6604
+ * @dbxUtilTags string, name, initials, avatar, abbreviate, person
6605
+ * @dbxUtilRelated name-to-initials-factory, split-join-name-string, capitalize-first-letter
6606
+ *
6607
+ * @example
6608
+ * ```ts
6609
+ * nameToInitials('Michelle B'); // 'MB'
6610
+ * nameToInitials('A'); // 'A'
6611
+ * nameToInitials('BB'); // 'B'
6612
+ * nameToInitials('Michelle'); // 'M'
6613
+ * ```
6614
+ */ var nameToInitials = nameToInitialsFactory();
6537
6615
  /**
6538
6616
  * Creates a string that repeats the given string a specified number of times.
6539
6617
  *
@@ -6569,7 +6647,7 @@ function caseInsensitiveString(input) {
6569
6647
  */ function cutStringFunction(config) {
6570
6648
  var inputMaxLength = config.maxLength, maxLengthIncludesEndText = config.maxLengthIncludesEndText, inputEndText = config.endText;
6571
6649
  var endText = inputEndText === undefined ? DEFAULT_CUT_STRING_END_TEXT : '';
6572
- var maxLength = maxLengthIncludesEndText !== false ? inputMaxLength - endText.length : inputMaxLength;
6650
+ var maxLength = maxLengthIncludesEndText === false ? inputMaxLength : inputMaxLength - endText.length;
6573
6651
  return function(input) {
6574
6652
  var result = input;
6575
6653
  if (input != null) {
@@ -6781,12 +6859,12 @@ function caseInsensitiveString(input) {
6781
6859
  }
6782
6860
  var transform = baseTransform;
6783
6861
  if (config.trim) {
6784
- if (baseTransform != null) {
6862
+ if (baseTransform == null) {
6863
+ transform = stringTrimFunction;
6864
+ } else {
6785
6865
  transform = function transform(x) {
6786
6866
  return baseTransform(stringTrimFunction(x));
6787
6867
  };
6788
- } else {
6789
- transform = stringTrimFunction;
6790
6868
  }
6791
6869
  }
6792
6870
  transform !== null && transform !== void 0 ? transform : transform = MAP_IDENTITY;
@@ -7581,15 +7659,15 @@ function _unsupported_iterable_to_array$r(o, minLen) {
7581
7659
  * @__NO_SIDE_EFFECTS__
7582
7660
  */ function filterKeyValueTuplesFunction(filter) {
7583
7661
  var result;
7584
- if (filter != null) {
7662
+ if (filter == null) {
7663
+ result = allKeyValueTuples;
7664
+ } else {
7585
7665
  var filterFn = filterKeyValueTupleFunction(filter);
7586
7666
  result = function result(obj) {
7587
7667
  return allKeyValueTuples(obj).filter(function(kv, i) {
7588
7668
  return filterFn(kv, i);
7589
7669
  });
7590
7670
  };
7591
- } else {
7592
- result = allKeyValueTuples;
7593
7671
  }
7594
7672
  return result;
7595
7673
  }
@@ -8021,10 +8099,10 @@ function _unsupported_iterable_to_array$q(o, minLen) {
8021
8099
  * @__NO_SIDE_EFFECTS__
8022
8100
  */ function overrideInObjectFunctionFactory(param) {
8023
8101
  var filter = param.filter, copy = param.copy, _param_dynamic = param.dynamic, dynamic = _param_dynamic === void 0 ? false : _param_dynamic;
8024
- var filterToRelevantValuesObject = filter != null ? filterFromPOJOFunction({
8102
+ var filterToRelevantValuesObject = filter == null ? defaultFilterFromPOJOFunctionNoCopy : filterFromPOJOFunction({
8025
8103
  filter: filter,
8026
8104
  copy: false
8027
- }) : defaultFilterFromPOJOFunctionNoCopy;
8105
+ });
8028
8106
  return function(from) {
8029
8107
  var rebuildTemplate = function rebuildTemplate() {
8030
8108
  var template = {};
@@ -8837,7 +8915,7 @@ function isInSetDecisionFunction(set, inputReadValue) {
8837
8915
  * @param input
8838
8916
  * @returns
8839
8917
  */ function maybeSet(input) {
8840
- return input != null ? new Set(asArray(input)) : input;
8918
+ return input == null ? input : new Set(asArray(input));
8841
8919
  }
8842
8920
 
8843
8921
  function _array_like_to_array$p(arr, len) {
@@ -8931,7 +9009,7 @@ var DEFAULT_AUTH_ROLE_CLAIMS_EMPTY_VALUE = null;
8931
9009
  // since checking uses equivalence, the objects will never match equivalence via the === properly.
8932
9010
  // AuthRoleClaimsFactoryConfigEntryEncodeOptions is likely to be used for these cases unknownways, but this will help avoid unexpected errors.
8933
9011
  if ((typeof expectedValue === "undefined" ? "undefined" : _type_of$d(expectedValue)) === 'object') {
8934
- throw new Error("failed decoding claims. Expected value to be a string or number. Object isn't supported with simple claims.");
9012
+ throw new TypeError("failed decoding claims. Expected value to be a string or number. Object isn't supported with simple claims.");
8935
9013
  }
8936
9014
  if (inverse) {
8937
9015
  var inverseMode = inverse === true ? 'any' : inverse;
@@ -11041,13 +11119,13 @@ function _unsupported_iterable_to_array$n(o, minLen) {
11041
11119
  ]) : splitAt;
11042
11120
  var firstOccurence = findFirstCharacterOccurence(splitSet, input);
11043
11121
  var result;
11044
- if (firstOccurence != null) {
11045
- result = splitStringAtIndex(input, firstOccurence, false);
11046
- } else {
11122
+ if (firstOccurence == null) {
11047
11123
  result = [
11048
11124
  input,
11049
11125
  undefined
11050
11126
  ];
11127
+ } else {
11128
+ result = splitStringAtIndex(input, firstOccurence, false);
11051
11129
  }
11052
11130
  return result;
11053
11131
  };
@@ -12437,7 +12515,7 @@ function _unsupported_iterable_to_array$l(o, minLen) {
12437
12515
  * @returns Whether the input is a standard internet-accessible website URL.
12438
12516
  */ function isStandardInternetAccessibleWebsiteUrl(input) {
12439
12517
  var protocol = readWebsiteProtocol(input);
12440
- return hasWebsiteTopLevelDomain(input) && (protocol != null ? isKnownHttpWebsiteProtocol(protocol) : true);
12518
+ return hasWebsiteTopLevelDomain(input) && (protocol == null ? true : isKnownHttpWebsiteProtocol(protocol));
12441
12519
  }
12442
12520
  /**
12443
12521
  * Creates a {@link WebsiteUrl} by merging the base path with additional path segments, preserving the original protocol.
@@ -12475,22 +12553,22 @@ function _unsupported_iterable_to_array$l(o, minLen) {
12475
12553
  var config = arguments.length > 0 && arguments[0] !== void 0 ? arguments[0] : {};
12476
12554
  var removeQueryParameters = config.removeQueryParameters, ignoredBasePath = config.ignoredBasePath, isolatePathComponents = config.isolatePathComponents, removeTrailingSlash = config.removeTrailingSlash;
12477
12555
  var basePathRegex = ignoredBasePath ? new RegExp('^' + escapeStringForRegex(toAbsoluteSlashPathStartType(ignoredBasePath))) : undefined;
12478
- var isolateRange = isolatePathComponents != null ? isolateSlashPathFunction({
12556
+ var isolateRange = isolatePathComponents == null ? undefined : isolateSlashPathFunction({
12479
12557
  range: isolatePathComponents,
12480
12558
  startType: 'absolute'
12481
- }) : undefined;
12559
+ });
12482
12560
  var replaceTrailingSlash = removeTrailingSlash === true ? replaceLastCharacterIfIsFunction('', SLASH_PATH_SEPARATOR) : undefined;
12483
12561
  var pathTransform = chainMapSameFunctions([
12484
12562
  // remove any base path
12485
- basePathRegex != null ? function(inputPath) {
12563
+ basePathRegex == null ? undefined : function(inputPath) {
12486
12564
  return inputPath.replace(basePathRegex, '');
12487
- } : undefined,
12565
+ },
12488
12566
  // remove the query parameters
12489
- removeQueryParameters != null ? function(inputPath) {
12567
+ removeQueryParameters == null ? undefined : function(inputPath) {
12490
12568
  return websitePathAndQueryPair(inputPath).path;
12491
- } : undefined,
12569
+ },
12492
12570
  // isolate range
12493
- isolateRange != null ? function(inputPath) {
12571
+ isolateRange == null ? undefined : function(inputPath) {
12494
12572
  var result = isolateRange(inputPath);
12495
12573
  // retain the query if one is available.
12496
12574
  if (removeQueryParameters !== true) {
@@ -12500,12 +12578,12 @@ function _unsupported_iterable_to_array$l(o, minLen) {
12500
12578
  }
12501
12579
  }
12502
12580
  return result;
12503
- } : undefined,
12581
+ },
12504
12582
  // remove trailing slash from path
12505
- replaceTrailingSlash != null ? function(inputPath) {
12583
+ replaceTrailingSlash == null ? undefined : function(inputPath) {
12506
12584
  var _websitePathAndQueryPair = websitePathAndQueryPair(inputPath), path = _websitePathAndQueryPair.path, query = _websitePathAndQueryPair.query;
12507
12585
  return replaceTrailingSlash(path) + (query !== null && query !== void 0 ? query : '');
12508
- } : undefined
12586
+ }
12509
12587
  ]);
12510
12588
  return function(input) {
12511
12589
  return pathTransform(websitePathFromWebsiteUrl(input));
@@ -12824,9 +12902,7 @@ function _unsupported_iterable_to_array$k(o, minLen) {
12824
12902
  */ function coerceToEmailParticipants(param) {
12825
12903
  var _param_participants = param.participants, participants = _param_participants === void 0 ? [] : _param_participants, _param_emails = param.emails, emails = _param_emails === void 0 ? [] : _param_emails;
12826
12904
  var result;
12827
- if (!emails.length) {
12828
- result = participants;
12829
- } else {
12905
+ if (emails.length) {
12830
12906
  var participantEmails = participants.map(function(x) {
12831
12907
  return x.email;
12832
12908
  });
@@ -12836,6 +12912,8 @@ function _unsupported_iterable_to_array$k(o, minLen) {
12836
12912
  email: email
12837
12913
  };
12838
12914
  })));
12915
+ } else {
12916
+ result = participants;
12839
12917
  }
12840
12918
  return result;
12841
12919
  }
@@ -14064,7 +14142,9 @@ function _unsupported_iterable_to_array$g(o, minLen) {
14064
14142
  */ function primativeKeyDencoderMap(values) {
14065
14143
  var map = new Map();
14066
14144
  var valuesArray;
14067
- if (!Array.isArray(values)) {
14145
+ if (Array.isArray(values)) {
14146
+ valuesArray = values;
14147
+ } else {
14068
14148
  valuesArray = [];
14069
14149
  forEachKeyValue(values, {
14070
14150
  forEach: function forEach(pair) {
@@ -14072,8 +14152,6 @@ function _unsupported_iterable_to_array$g(o, minLen) {
14072
14152
  },
14073
14153
  filter: exports.KeyValueTypleValueFilter.UNDEFINED
14074
14154
  });
14075
- } else {
14076
- valuesArray = values;
14077
14155
  }
14078
14156
  valuesArray.forEach(function(value) {
14079
14157
  var _value = _sliced_to_array$c(value, 2), d = _value[0], e = _value[1];
@@ -14363,7 +14441,7 @@ function _unsupported_iterable_to_array$g(o, minLen) {
14363
14441
  * // true
14364
14442
  * ```
14365
14443
  */ function isCompleteUnitedStatesAddress(input) {
14366
- return input != null ? Boolean(input.line1 && input.city && input.state && input.zip) : false;
14444
+ return input == null ? false : Boolean(input.line1 && input.city && input.state && input.zip);
14367
14445
  }
14368
14446
  /**
14369
14447
  * Regex that matches valid two-letter US state and territory codes (uppercase only).
@@ -14444,8 +14522,8 @@ function _unsupported_iterable_to_array$g(o, minLen) {
14444
14522
  */ function vectorMinimumSizeResizeFunction(minSize) {
14445
14523
  return function(input) {
14446
14524
  return {
14447
- x: minSize.x != null ? Math.max(input.x, minSize.x) : input.x,
14448
- y: minSize.y != null ? Math.max(input.y, minSize.y) : input.y
14525
+ x: minSize.x == null ? input.x : Math.max(input.x, minSize.x),
14526
+ y: minSize.y == null ? input.y : Math.max(input.y, minSize.y)
14449
14527
  };
14450
14528
  };
14451
14529
  }
@@ -15087,8 +15165,8 @@ function latLngString(lat, lng) {
15087
15165
  * @__NO_SIDE_EFFECTS__
15088
15166
  */ function latLngPointFunction(config) {
15089
15167
  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;
15090
- var precisionFunction = precision != null ? latLngPointPrecisionFunction(precision, precisionRounding) : mapIdentityFunction();
15091
- var wrapFunction = wrap !== false ? wrapLatLngPoint : validate !== false ? validLatLngPointFunction(defaultValue) : undefined;
15168
+ var precisionFunction = precision == null ? mapIdentityFunction() : latLngPointPrecisionFunction(precision, precisionRounding);
15169
+ var wrapFunction = wrap === false ? validate === false ? undefined : validLatLngPointFunction(defaultValue) : wrapLatLngPoint;
15092
15170
  var mapFn = chainMapSameFunctions([
15093
15171
  wrapFunction,
15094
15172
  precisionFunction
@@ -15118,13 +15196,13 @@ function latLngString(lat, lng) {
15118
15196
  lat: lat.lat,
15119
15197
  lng: (_lat_lng = lat.lng) !== null && _lat_lng !== void 0 ? _lat_lng : lat.lon
15120
15198
  };
15121
- } else if (lng != null) {
15199
+ } else if (lng == null) {
15200
+ throw new Error('Invalid lat/lng input "'.concat(lat, ",").concat(lng, '"'));
15201
+ } else {
15122
15202
  latLng = {
15123
15203
  lat: lat,
15124
15204
  lng: lng
15125
15205
  };
15126
- } else {
15127
- throw new Error('Invalid lat/lng input "'.concat(lat, ",").concat(lng, '"'));
15128
15206
  }
15129
15207
  return mapFn(latLng); // round to a given precision
15130
15208
  };
@@ -15227,7 +15305,7 @@ function latLngString(lat, lng) {
15227
15305
  min: wrapLngValue(sw.lng),
15228
15306
  max: wrapLngValue(ne.lng)
15229
15307
  }, 'none');
15230
- var precisionFunction = precision != null ? latLngPointPrecisionFunction(precision, 'round') : mapIdentityFunction();
15308
+ var precisionFunction = precision == null ? mapIdentityFunction() : latLngPointPrecisionFunction(precision, 'round');
15231
15309
  return function() {
15232
15310
  return precisionFunction({
15233
15311
  lat: randomLatFactory(),
@@ -16456,7 +16534,7 @@ function dateFromDateOrTimeMillisecondsNumber(input) {
16456
16534
  return input.getTime() < Date.now();
16457
16535
  }
16458
16536
  function addMilliseconds(input, ms) {
16459
- return input != null ? new Date(input.getTime() + (ms !== null && ms !== void 0 ? ms : 0)) : input;
16537
+ return input == null ? input : new Date(input.getTime() + (ms !== null && ms !== void 0 ? ms : 0));
16460
16538
  }
16461
16539
 
16462
16540
  /**
@@ -17135,10 +17213,10 @@ function _ts_generator$7(thisArg, body) {
17135
17213
  * ```
17136
17214
  */ function useValue(input, use, defaultValue) {
17137
17215
  var result;
17138
- if (input != null) {
17139
- result = use(input);
17140
- } else {
17216
+ if (input == null) {
17141
17217
  result = getValueFromGetter(defaultValue);
17218
+ } else {
17219
+ result = use(input);
17142
17220
  }
17143
17221
  return result;
17144
17222
  }
@@ -17211,10 +17289,10 @@ function _ts_generator$7(thisArg, body) {
17211
17289
  */ function useContextFunction(use, defaultValue) {
17212
17290
  return function(input) {
17213
17291
  var result;
17214
- if (input != null) {
17215
- result = use(input);
17216
- } else {
17292
+ if (input == null) {
17217
17293
  result = getValueFromGetter(defaultValue);
17294
+ } else {
17295
+ result = use(input);
17218
17296
  }
17219
17297
  return result;
17220
17298
  };
@@ -17238,22 +17316,22 @@ function _ts_generator$7(thisArg, body) {
17238
17316
  return _ts_generator$7(this, function(_state) {
17239
17317
  switch(_state.label){
17240
17318
  case 0:
17241
- if (!(input != null)) return [
17319
+ if (!(input == null)) return [
17242
17320
  3,
17243
- 2
17321
+ 1
17244
17322
  ];
17323
+ result = getValueFromGetter(defaultValue);
17245
17324
  return [
17246
- 4,
17247
- use(input)
17325
+ 3,
17326
+ 3
17248
17327
  ];
17249
17328
  case 1:
17250
- result = _state.sent();
17251
17329
  return [
17252
- 3,
17253
- 3
17330
+ 4,
17331
+ use(input)
17254
17332
  ];
17255
17333
  case 2:
17256
- result = getValueFromGetter(defaultValue);
17334
+ result = _state.sent();
17257
17335
  _state.label = 3;
17258
17336
  case 3:
17259
17337
  return [
@@ -17366,7 +17444,7 @@ function _ts_generator$7(thisArg, body) {
17366
17444
  var increaseBy = inputIncreaseBy !== null && inputIncreaseBy !== void 0 ? inputIncreaseBy : 1;
17367
17445
  var dencoder = inputDencoder !== null && inputDencoder !== void 0 ? inputDencoder : NUMBER_STRING_DENCODER_64;
17368
17446
  var dencoderNumberValue = numberStringDencoderDecodedNumberValueFunction(dencoder);
17369
- var startAtFromCurrentIndex = currentIndex != null ? dencoderNumberValue(currentIndex) + increaseBy : undefined;
17447
+ var startAtFromCurrentIndex = currentIndex == null ? undefined : dencoderNumberValue(currentIndex) + increaseBy;
17370
17448
  var startAt = inputStartAt == null ? startAtFromCurrentIndex !== null && startAtFromCurrentIndex !== void 0 ? startAtFromCurrentIndex : 0 : dencoderNumberValue(inputStartAt);
17371
17449
  var transform = inputTranformFunction !== null && inputTranformFunction !== void 0 ? inputTranformFunction : mapIdentityFunction();
17372
17450
  var numberFactory = incrementingNumberFactory({
@@ -17661,7 +17739,7 @@ function _type_of$6(obj) {
17661
17739
  return unixDateTimeSecondsNumberFromDate(new Date());
17662
17740
  }
17663
17741
  function unixDateTimeSecondsNumberFromDate(date) {
17664
- return date != null ? Math.ceil(date.getTime() / 1000) : date;
17742
+ return date == null ? date : Math.ceil(date.getTime() / 1000);
17665
17743
  }
17666
17744
  function dateFromDateOrTimeSecondsNumber(input) {
17667
17745
  var result;
@@ -17685,7 +17763,7 @@ function dateFromDateOrTimeSecondsNumber(input) {
17685
17763
  * @dbxUtilTags date, unix, seconds, timestamp, convert, parse
17686
17764
  * @dbxUtilRelated unix-date-time-seconds-number-from-date, date-from-date-or-time-seconds-number
17687
17765
  */ function unixDateTimeSecondsNumberToDate(dateTimeNumber) {
17688
- return dateTimeNumber != null ? new Date(dateTimeNumber * 1000) : dateTimeNumber;
17766
+ return dateTimeNumber == null ? dateTimeNumber : new Date(dateTimeNumber * 1000);
17689
17767
  }
17690
17768
 
17691
17769
  /**
@@ -17742,7 +17820,7 @@ function dateFromDateOrTimeSecondsNumber(input) {
17742
17820
  } else if (expiresAt != null) {
17743
17821
  expirationDate = expiresAt;
17744
17822
  } else if (expiresIn != null) {
17745
- var date = parsedExpiresFromDate !== null && parsedExpiresFromDate !== void 0 ? parsedExpiresFromDate : defaultExpiresFromDateToNow !== false ? now : null;
17823
+ var date = parsedExpiresFromDate !== null && parsedExpiresFromDate !== void 0 ? parsedExpiresFromDate : defaultExpiresFromDateToNow === false ? null : now;
17746
17824
  expirationDate = addMilliseconds(date, expiresIn);
17747
17825
  }
17748
17826
  return expirationDate;
@@ -18326,10 +18404,10 @@ function _ts_generator$6(thisArg, body) {
18326
18404
  2,
18327
18405
  new Promise(function(resolve, reject) {
18328
18406
  var callback = function callback(err) {
18329
- if (err != null) {
18330
- reject(err);
18331
- } else {
18407
+ if (err == null) {
18332
18408
  resolve();
18409
+ } else {
18410
+ reject(err);
18333
18411
  }
18334
18412
  };
18335
18413
  use(callback);
@@ -20700,7 +20778,7 @@ function _is_native_reflect_construct$2() {
20700
20778
  * @returns Projected end instant; null when no duration remains to project.
20701
20779
  */ function approximateTimerEndDate(timer) {
20702
20780
  var durationRemaining = timer.durationRemaining;
20703
- return durationRemaining != null ? new Date(Date.now() + durationRemaining) : null;
20781
+ return durationRemaining == null ? null : new Date(Date.now() + durationRemaining);
20704
20782
  }
20705
20783
 
20706
20784
  /**
@@ -22285,7 +22363,7 @@ function handlerFactory(readKey, options) {
22285
22363
  base: function base(value) {
22286
22364
  var _ref;
22287
22365
  var key = readKey(value);
22288
- var handler = (_ref = key != null ? map.get(key) : undefined) !== null && _ref !== void 0 ? _ref : catchAll;
22366
+ var handler = (_ref = key == null ? undefined : map.get(key)) !== null && _ref !== void 0 ? _ref : catchAll;
22289
22367
  var handled;
22290
22368
  if (handler) {
22291
22369
  handled = Promise.resolve(handler(value)).then(function(x) {
@@ -24342,9 +24420,9 @@ function invertMaybeBoolean(x) {
24342
24420
  return reduceFn(a, b);
24343
24421
  }));
24344
24422
  };
24345
- return emptyArrayValue != null ? function(array) {
24423
+ return emptyArrayValue == null ? rFn : function(array) {
24346
24424
  return array.length ? rFn(array) : emptyArrayValue;
24347
- } : rFn;
24425
+ };
24348
24426
  }
24349
24427
  /**
24350
24428
  * Creates a new BooleanFactory that generates random boolean values based on chance.
@@ -24568,6 +24646,40 @@ function _define_property$1(obj, key, value) {
24568
24646
  });
24569
24647
  return filterMaybeArrayValues(values);
24570
24648
  }
24649
+ /**
24650
+ * FNV-1a 32-bit offset basis.
24651
+ */ var FNV_1A_OFFSET_BASIS = 0x811c9dc5;
24652
+ /**
24653
+ * FNV-1a 32-bit prime.
24654
+ */ var FNV_1A_PRIME = 0x01000193;
24655
+ /**
24656
+ * Computes a stable, non-negative 32-bit integer hash for the input string using the FNV-1a algorithm.
24657
+ *
24658
+ * Deterministic and dependency-free (no `Math.random`): the same input always yields the same value,
24659
+ * making it suitable for deterministically mapping a string onto a fixed-size set (e.g. picking a
24660
+ * curated color for a name via `hashStringToNumber(value) % colors.length`).
24661
+ *
24662
+ * @param value - String to hash.
24663
+ * @returns A non-negative integer in the range `[0, 2^32)`.
24664
+ *
24665
+ * @dbxUtil
24666
+ * @dbxUtilCategory hash
24667
+ * @dbxUtilTags hash, string, number, deterministic, fnv, bucket, index
24668
+ * @dbxUtilRelated decode-hashed-values
24669
+ *
24670
+ * @example
24671
+ * ```ts
24672
+ * hashStringToNumber('Michelle B'); // stable integer, same every call
24673
+ * hashStringToNumber('Michelle B') % 12; // deterministic bucket index 0-11
24674
+ * ```
24675
+ */ function hashStringToNumber(value) {
24676
+ var hash = FNV_1A_OFFSET_BASIS;
24677
+ for(var i = 0; i < value.length; i += 1){
24678
+ hash ^= value.charCodeAt(i);
24679
+ hash = Math.imul(hash, FNV_1A_PRIME);
24680
+ }
24681
+ return hash >>> 0;
24682
+ }
24571
24683
 
24572
24684
  function asyncGeneratorStep$1(gen, resolve, reject, _next, _throw, key, arg) {
24573
24685
  try {
@@ -25512,6 +25624,8 @@ exports.DEFAULT_AUTH_ROLE_CLAIMS_EMPTY_VALUE = DEFAULT_AUTH_ROLE_CLAIMS_EMPTY_VA
25512
25624
  exports.DEFAULT_CUT_STRING_END_TEXT = DEFAULT_CUT_STRING_END_TEXT;
25513
25625
  exports.DEFAULT_ENCRYPTED_FIELD_PREFIX = DEFAULT_ENCRYPTED_FIELD_PREFIX;
25514
25626
  exports.DEFAULT_LAT_LNG_STRING_VALUE = DEFAULT_LAT_LNG_STRING_VALUE;
25627
+ exports.DEFAULT_NAME_TO_INITIALS_MAX_INITIALS = DEFAULT_NAME_TO_INITIALS_MAX_INITIALS;
25628
+ exports.DEFAULT_NAME_TO_INITIALS_MIN_INITIALS = DEFAULT_NAME_TO_INITIALS_MIN_INITIALS;
25515
25629
  exports.DEFAULT_NUMBER_STRING_DENCODER_64_NEGATIVE_PREFIX = DEFAULT_NUMBER_STRING_DENCODER_64_NEGATIVE_PREFIX;
25516
25630
  exports.DEFAULT_RANDOM_EMAIL_FACTORY_CONFIG = DEFAULT_RANDOM_EMAIL_FACTORY_CONFIG;
25517
25631
  exports.DEFAULT_RANDOM_PHONE_NUMBER_FACTORY_CONFIG = DEFAULT_RANDOM_PHONE_NUMBER_FACTORY_CONFIG;
@@ -25945,6 +26059,7 @@ exports.hasValueOrNotEmptyObject = hasValueOrNotEmptyObject;
25945
26059
  exports.hasWebsiteDomain = hasWebsiteDomain;
25946
26060
  exports.hasWebsiteTopLevelDomain = hasWebsiteTopLevelDomain;
25947
26061
  exports.hashSetForIndexed = hashSetForIndexed;
26062
+ exports.hashStringToNumber = hashStringToNumber;
25948
26063
  exports.hourToFractionalHour = hourToFractionalHour;
25949
26064
  exports.hoursAndMinutesToString = hoursAndMinutesToString;
25950
26065
  exports.hoursAndMinutesToTimeUnit = hoursAndMinutesToTimeUnit;
@@ -26191,6 +26306,8 @@ exports.monthOfYearFromDateMonth = monthOfYearFromDateMonth;
26191
26306
  exports.monthOfYearFromUTCDate = monthOfYearFromUTCDate;
26192
26307
  exports.multiKeyValueMapFactory = multiKeyValueMapFactory;
26193
26308
  exports.multiValueMapBuilder = multiValueMapBuilder;
26309
+ exports.nameToInitials = nameToInitials;
26310
+ exports.nameToInitialsFactory = nameToInitialsFactory;
26194
26311
  exports.neMostLatLngPoint = neMostLatLngPoint;
26195
26312
  exports.nearestDivisibleValues = nearestDivisibleValues;
26196
26313
  exports.noop = noop;