@oscarpalmer/atoms 0.218.0 → 0.219.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.
Files changed (50) hide show
  1. package/dist/array/filter.d.mts +38 -4
  2. package/dist/array/find.d.mts +34 -0
  3. package/dist/array/first.d.mts +40 -4
  4. package/dist/array/last.d.mts +46 -10
  5. package/dist/array/partition.d.mts +24 -8
  6. package/dist/array/reverse.d.mts +6 -0
  7. package/dist/array/reverse.mjs +6 -0
  8. package/dist/array/select.d.mts +97 -116
  9. package/dist/array/select.mjs +19 -15
  10. package/dist/array/single.d.mts +22 -0
  11. package/dist/array/single.mjs +1 -1
  12. package/dist/array/sort.d.mts +54 -0
  13. package/dist/color/space/hex.d.mts +8 -0
  14. package/dist/color/space/hex.mjs +8 -0
  15. package/dist/index.d.mts +716 -170
  16. package/dist/index.mjs +293 -68
  17. package/dist/internal/array/callbacks.mjs +1 -1
  18. package/dist/internal/array/find.d.mts +3 -3
  19. package/dist/internal/array/find.mjs +71 -52
  20. package/dist/internal/array/shuffle.d.mts +5 -0
  21. package/dist/internal/array/shuffle.mjs +5 -0
  22. package/dist/internal/math/aggregate.d.mts +69 -21
  23. package/dist/internal/math/misc.d.mts +14 -0
  24. package/dist/internal/math/misc.mjs +14 -0
  25. package/dist/internal/number.d.mts +18 -0
  26. package/dist/internal/number.mjs +18 -0
  27. package/dist/internal/string/case.d.mts +63 -0
  28. package/dist/internal/string/case.mjs +63 -0
  29. package/dist/internal/string/misc.d.mts +20 -0
  30. package/dist/internal/string/misc.mjs +20 -0
  31. package/dist/logger.d.mts +12 -0
  32. package/dist/logger.mjs +12 -0
  33. package/dist/math.d.mts +90 -0
  34. package/dist/math.mjs +7 -0
  35. package/dist/models/array/array.find.model.d.mts +26 -0
  36. package/dist/models/array/array.misc.model.d.mts +2 -4
  37. package/dist/models/index.d.mts +1 -1
  38. package/dist/models/value/value.merge.model.d.mts +3 -3
  39. package/dist/promise/misc.d.mts +6 -0
  40. package/dist/promise/misc.mjs +6 -0
  41. package/dist/promise/timed.d.mts +3 -0
  42. package/dist/promise/timed.mjs +3 -0
  43. package/dist/queue.d.mts +0 -1
  44. package/dist/queue.mjs +1 -1
  45. package/dist/string/index.d.mts +15 -1
  46. package/dist/string/index.mjs +15 -1
  47. package/dist/string/match.d.mts +24 -0
  48. package/dist/string/match.mjs +24 -0
  49. package/dist/string/template.d.mts +4 -0
  50. package/package.json +1 -1
package/dist/index.mjs CHANGED
@@ -8,7 +8,7 @@ function getArrayCallback(value) {
8
8
  switch (typeof value) {
9
9
  case "function": return value;
10
10
  case "number":
11
- case "string": return typeof value === "string" && value.includes(".") ? void 0 : (obj) => obj[value];
11
+ case "string": return (obj) => obj?.[value];
12
12
  default: return;
13
13
  }
14
14
  }
@@ -21,6 +21,15 @@ function getArrayCallbacks(bool, key, value) {
21
21
  }
22
22
  //#endregion
23
23
  //#region src/internal/array/find.ts
24
+ function addResult(result, mapped, flat) {
25
+ if (!flat) {
26
+ result.matched.push(mapped);
27
+ return;
28
+ }
29
+ const array = Array.isArray(mapped) ? mapped : [mapped];
30
+ const { length } = array;
31
+ for (let index = 0; index < length; index += 1) result.matched.push(array[index]);
32
+ }
24
33
  function createFindParameters(original) {
25
34
  const { length } = original;
26
35
  return {
@@ -29,24 +38,27 @@ function createFindParameters(original) {
29
38
  value: length === 1 && typeof original[0] !== "function" ? original[0] : original[1]
30
39
  };
31
40
  }
41
+ function findAbsoluteValueOrDefault(array, parameters, defaultValue, useDefaultValue, reversed) {
42
+ if (parameters.length === 0) {
43
+ if (Array.isArray(array) && array.length > 0) return reversed ? array.at(-1) : array[0];
44
+ return useDefaultValue ? defaultValue : void 0;
45
+ }
46
+ const index = findValue(ARRAY_FIND_VALUE_INDEX, array, parameters, reversed);
47
+ if (index === -1) return useDefaultValue ? defaultValue : void 0;
48
+ return array[index];
49
+ }
32
50
  function findComplexValues(parameters) {
33
- const { array, keyCallback, length, mapAfter, mapBefore, result, type, value } = parameters;
51
+ const { array, arrayLength, callback, limit, result, type, value } = parameters;
34
52
  const keys = /* @__PURE__ */ new Set();
35
- for (let index = 0; index < length; index += 1) {
36
- const item = array[index];
37
- let keyed;
38
- let transformed;
39
- if (mapBefore == null) {
40
- keyed = keyCallback?.(item, index, array) ?? item;
41
- transformed = item;
42
- } else {
43
- transformed = mapBefore(item, index, array);
44
- keyed = keyCallback?.(transformed, index, array) ?? transformed;
45
- }
53
+ for (let arrayIndex = 0; arrayIndex < arrayLength; arrayIndex += 1) {
54
+ const arrayItem = array[arrayIndex];
55
+ const keyed = callback == null ? arrayItem : callback(arrayItem, arrayIndex, array);
56
+ const mapped = arrayItem;
46
57
  if (type === "all" && Object.is(keyed, value) || type === "unique" && !keys.has(keyed)) {
47
58
  keys.add(keyed);
48
- result.matched.push(mapAfter?.(item, index, array) ?? transformed);
49
- } else result.notMatched.push(item);
59
+ result.matched.push(mapped);
60
+ if (result.matched.length >= limit) return result;
61
+ } else result.notMatched.push(arrayItem);
50
62
  }
51
63
  return result;
52
64
  }
@@ -54,13 +66,28 @@ function findSimpleValue(array, value, findIndex, reversed) {
54
66
  if (findIndex) return reversed ? array.lastIndexOf(value) : array.indexOf(value);
55
67
  return reversed ? array.findLast((item) => Object.is(item, value)) : array.find((item) => Object.is(item, value));
56
68
  }
57
- function findSimpleValues(array, length, value, boolCallback, mapBefore, mapAfter, result) {
58
- const callback = boolCallback ?? ((item) => Object.is(item, value));
59
- for (let index = 0; index < length; index += 1) {
60
- const item = array[index];
61
- const transformed = mapBefore?.(item, index, array) ?? item;
62
- if (callback(transformed, index, array)) result.matched.push(mapAfter?.(item, index, array) ?? transformed);
63
- else result.notMatched.push(item);
69
+ function findSimpleValues(parameters) {
70
+ const { array, arrayLength, callback, flat, limit, map, result, value } = parameters;
71
+ const { after, before } = map ?? {};
72
+ const handler = callback ?? ((item) => Object.is(item, value));
73
+ for (let arrayIndex = 0; arrayIndex < arrayLength; arrayIndex += 1) {
74
+ const arrayItem = array[arrayIndex];
75
+ let mapped = before == null ? arrayItem : before(arrayItem, arrayIndex, array);
76
+ if (!flat || after != null) {
77
+ if (handler(mapped, arrayIndex, array)) {
78
+ mapped = after == null ? mapped : after(arrayItem, arrayIndex, array);
79
+ addResult(result, mapped, flat);
80
+ if (result.matched.length >= limit) return result;
81
+ } else result.notMatched.push(arrayItem);
82
+ continue;
83
+ }
84
+ const flatItems = Array.isArray(mapped) ? mapped : [mapped];
85
+ const flatLength = flatItems.length;
86
+ for (let flatIndex = 0; flatIndex < flatLength; flatIndex += 1) {
87
+ const flatItem = flatItems[flatIndex];
88
+ if (handler(flatItem, arrayIndex, array)) result.matched.push(flatItem);
89
+ else result.notMatched.push(flatItem);
90
+ }
64
91
  }
65
92
  return result;
66
93
  }
@@ -84,50 +111,42 @@ function findValueInArray(array, callback, value, findIndex, reversed) {
84
111
  }
85
112
  return findIndex ? -1 : void 0;
86
113
  }
87
- function findAbsoluteValueOrDefault(array, parameters, defaultValue, useDefaultValue, reversed) {
88
- if (parameters.length === 0) {
89
- if (Array.isArray(array) && array.length > 0) return reversed ? array.at(-1) : array[0];
90
- return useDefaultValue ? defaultValue : void 0;
91
- }
92
- const index = findValue(ARRAY_FIND_VALUE_INDEX, array, parameters, reversed);
93
- if (index === -1) return useDefaultValue ? defaultValue : void 0;
94
- return array[index];
95
- }
96
- function findValues(type, array, parameters, mapper) {
114
+ function findValues(type, array, parameters, options) {
97
115
  const result = {
98
116
  matched: [],
99
117
  notMatched: []
100
118
  };
101
- if (!Array.isArray(array) || array.length === 0) return result;
102
- const { length } = array;
119
+ if (!Array.isArray(array)) return result;
120
+ const arrayLength = array.length;
121
+ if (arrayLength === 0) return result;
103
122
  const { bool, key, value } = createFindParameters(parameters);
104
123
  const callbacks = getArrayCallbacks(bool, key);
105
- if (type === "unique" && callbacks?.keyed == null && length >= 100) {
124
+ if (type === "unique" && callbacks?.keyed == null && arrayLength >= 100) {
106
125
  result.matched = [...new Set(array)];
107
126
  return result;
108
127
  }
109
- const mapCallback = getArrayCallback(mapper?.callback);
110
- const mapReverse = mapper?.reverse ?? false;
111
- let mapAfter;
112
- let mapBefore;
113
- if (mapCallback == null) {
114
- mapAfter = void 0;
115
- mapBefore = void 0;
116
- } else {
117
- mapAfter = mapReverse ? void 0 : mapCallback;
118
- mapBefore = mapReverse ? mapCallback : void 0;
119
- }
120
- if (callbacks?.bool != null || type === "all" && key == null) return findSimpleValues(array, length, value, callbacks?.bool, mapBefore, mapAfter, result);
121
- return findComplexValues({
128
+ const limit = options?.limit ?? Number.POSITIVE_INFINITY;
129
+ const flat = options?.map?.flat ?? false;
130
+ const mapCallback = getArrayCallback(options?.map?.callback);
131
+ const mapReverse = options?.map?.reverse ?? false;
132
+ let map;
133
+ if (mapCallback != null) map = {
134
+ before: mapReverse ? mapCallback : void 0,
135
+ after: mapReverse ? void 0 : mapCallback
136
+ };
137
+ const simple = callbacks?.bool != null || type === "all" && key == null;
138
+ const findParameters = {
122
139
  array,
123
- length,
124
- mapAfter,
125
- mapBefore,
140
+ arrayLength,
141
+ flat,
142
+ limit,
143
+ map,
126
144
  result,
127
145
  type,
128
146
  value,
129
- keyCallback: callbacks?.keyed
130
- });
147
+ callback: simple ? callbacks?.bool : callbacks?.keyed
148
+ };
149
+ return simple ? findSimpleValues(findParameters) : findComplexValues(findParameters);
131
150
  }
132
151
  //#endregion
133
152
  //#region src/array/filter.ts
@@ -506,6 +525,13 @@ function startsWithArray(haystack, needle, key) {
506
525
  * @param value Number to round down
507
526
  * @param decimals Number of decimal places to round to _(defaults to `0`)_
508
527
  * @returns Rounded number, or `Number.NaN` if the value if unable to be rounded
528
+ *
529
+ * @example
530
+ * ```typescript
531
+ * floor(10.567, 2); // => 10.56
532
+ * floor(10.567); // => 10
533
+ * floor('abc'); // => Number.NaN
534
+ * ```
509
535
  */
510
536
  function floor(value, decimals) {
511
537
  return roundNumber(Math.floor, value, decimals);
@@ -516,6 +542,13 @@ function floor(value, decimals) {
516
542
  * @param value Number to round
517
543
  * @param decimals Number of decimal places to round to _(defaults to `0`)_
518
544
  * @returns Rounded number, or `Number.NaN` if the value if unable to be rounded
545
+ *
546
+ * @example
547
+ * ```typescript
548
+ * round(10.567, 2); // => 10.57
549
+ * round(10.567); // => 11
550
+ * round('abc'); // => Number.NaN
551
+ * ```
519
552
  */
520
553
  function round(value, decimals) {
521
554
  return roundNumber(Math.round, value, decimals);
@@ -573,6 +606,11 @@ const RANDOM_DIVISOR = 2 ** 32;
573
606
  *
574
607
  * @param array Original array
575
608
  * @returns Shuffled array
609
+ *
610
+ * @example
611
+ * ```typescript
612
+ * shuffle([1, 2, 3]); // => [3, 1, 2] (maybe? it's random, you know)
613
+ * ```
576
614
  */
577
615
  function shuffle(array) {
578
616
  if (!Array.isArray(array)) return [];
@@ -805,6 +843,12 @@ function push(array, pushed) {
805
843
  *
806
844
  * @param array Array to reverse
807
845
  * @returns Reversed array
846
+ *
847
+ * @example
848
+ * ```typescript
849
+ * reverse([1, 2, 3]); // => [3, 2, 1]
850
+ * reverse(['a', 'b', 'c']); // => ['c', 'b', 'a']
851
+ * ```
808
852
  */
809
853
  function reverse(array) {
810
854
  if (!Array.isArray(array)) return [];
@@ -822,7 +866,7 @@ function reverse(array) {
822
866
  //#endregion
823
867
  //#region src/array/single.ts
824
868
  function single(array, ...parameters) {
825
- const { matched } = findValues("all", array, parameters);
869
+ const { matched } = findValues("all", array, parameters, { limit: 2 });
826
870
  if (matched.length > 1) throw new Error(SINGLE_MESSAGE);
827
871
  return matched[0];
828
872
  }
@@ -1053,22 +1097,28 @@ move.indices = moveIndices;
1053
1097
  move.toIndex = moveToIndex;
1054
1098
  //#endregion
1055
1099
  //#region src/array/select.ts
1056
- function filterAndMap(array, ...parameters) {
1057
- return selectValues(array, parameters);
1100
+ function filterAndFlatMap(array, filter, mapper) {
1101
+ return selectValues(array, filter, mapper, true, false);
1102
+ }
1103
+ function filterAndMap(array, filter, mapper) {
1104
+ return selectValues(array, filter, mapper, false, false);
1105
+ }
1106
+ function flatMapAndFilter(array, mapper, filter) {
1107
+ return selectValues(array, filter, mapper, true, true);
1058
1108
  }
1059
- function mapAndFilter(array, ...parameters) {
1060
- return findValues("all", array, parameters, {
1061
- callback: parameters.shift(),
1062
- reverse: true
1063
- }).matched;
1109
+ function mapAndFilter(array, mapper, filter) {
1110
+ return selectValues(array, filter, mapper, false, true);
1064
1111
  }
1065
- function selectValues(array, parameters) {
1066
- return findValues("all", array, parameters, {
1067
- callback: parameters.pop(),
1068
- reverse: false
1069
- }).matched;
1112
+ function selectValues(array, filter, mapper, flat, reverse) {
1113
+ return findValues("all", array, [filter], { map: {
1114
+ flat,
1115
+ reverse,
1116
+ callback: mapper
1117
+ } }).matched;
1070
1118
  }
1119
+ filterAndMap.flat = filterAndFlatMap;
1071
1120
  filterAndMap.reverse = mapAndFilter;
1121
+ mapAndFilter.flat = flatMapAndFilter;
1072
1122
  //#endregion
1073
1123
  //#region src/models/value/value.misc.model.ts
1074
1124
  const COMPARE_NAME = "compare";
@@ -1194,9 +1244,15 @@ function getString(value) {
1194
1244
  const asString = String(value.valueOf?.() ?? value);
1195
1245
  return asString.startsWith("[object ") ? JSON.stringify(value) : asString;
1196
1246
  }
1247
+ /**
1248
+ * @internal
1249
+ */
1197
1250
  function ignoreKey(key) {
1198
1251
  return STRING_EXPRESSION_IGNORED.test(key);
1199
1252
  }
1253
+ /**
1254
+ * @internal
1255
+ */
1200
1256
  function interpolate(strings, values) {
1201
1257
  const { length } = strings;
1202
1258
  let interpolated = "";
@@ -1214,6 +1270,14 @@ function interpolate(strings, values) {
1214
1270
  * @param array Array of values
1215
1271
  * @param delimiter Delimiter to use between values
1216
1272
  * @returns Joined string
1273
+ * @example
1274
+ * ```typescript
1275
+ * join(['a', 'b', 'c']); // => 'abc'
1276
+ * join(['a', 'b', 'c'], ', '); // => 'a, b, c'
1277
+ * join(['a', '', 'c']); // => 'ac'
1278
+ * join([null, 'b', undefined]); // => 'b'
1279
+ * join([]); // => ''
1280
+ * ```
1217
1281
  */
1218
1282
  function join(array, delimiter) {
1219
1283
  if (!Array.isArray(array)) return "";
@@ -1229,9 +1293,15 @@ function join(array, delimiter) {
1229
1293
  function tryCallback(value, callback) {
1230
1294
  return unwrap(attempt(() => callback(value)), value);
1231
1295
  }
1296
+ /**
1297
+ * @internal
1298
+ */
1232
1299
  function tryDecode(value) {
1233
1300
  return tryCallback(value, decodeURIComponent);
1234
1301
  }
1302
+ /**
1303
+ * @internal
1304
+ */
1235
1305
  function tryEncode(value) {
1236
1306
  return tryCallback(value, encodeURIComponent);
1237
1307
  }
@@ -2219,6 +2289,13 @@ const EXPRESSION_WHITESPACE_ONLY = /^\s*$/;
2219
2289
  * @param minimum Minimum value
2220
2290
  * @param maximum Maximum value _(inclusive)_
2221
2291
  * @returns `true` if the value is between the minimum and maximum, otherwise `false`
2292
+ *
2293
+ * @example
2294
+ * ```typescript
2295
+ * between(5, 1, 10); // => true
2296
+ * between(0, 1, 10); // => false
2297
+ * between(10, 10, 10); // => true
2298
+ * ```
2222
2299
  */
2223
2300
  function between(value, minimum, maximum) {
2224
2301
  if (![
@@ -2261,6 +2338,17 @@ function clamp(value, minimum, maximum, loop) {
2261
2338
  *
2262
2339
  * @param value Original value
2263
2340
  * @returns Original value as a number, or `Number.NaN` if the value is unable to be parsed
2341
+ *
2342
+ * @example
2343
+ * ```typescript
2344
+ * getNumber(null) // => Number.NaN
2345
+ * getNumber('foo') // => Number.NaN
2346
+ * getNumber('123') // => 123
2347
+ * getNumber(true) // => 1
2348
+ * getNumber([1, 2, 3]) // => Number.NaN
2349
+ * getNumber({a: 1}) // => Number.NaN
2350
+ * getNumber(() => 123) // => 123
2351
+ * ```
2264
2352
  */
2265
2353
  function getNumber(value) {
2266
2354
  if (typeof value === "number") return value;
@@ -2493,6 +2581,14 @@ const STRING_REPLACEMENT_CAMEL_CASE = "$1-$2";
2493
2581
  *
2494
2582
  * @param value String to convert
2495
2583
  * @returns Camel-cased string
2584
+ *
2585
+ * @example
2586
+ * ```typescript
2587
+ * camelCase('this is camel case'); // => 'thisIsCamelCase'
2588
+ * camelCase('ThisIsCamelCase'); // => 'thisIsCamelCase'
2589
+ * camelCase('this-is-camel-case'); // => 'thisIsCamelCase'
2590
+ * camelCase('this_is_camel_case'); // => 'thisIsCamelCase'
2591
+ * ```
2496
2592
  */
2497
2593
  function camelCase(value) {
2498
2594
  return toCase(STRING_CASE_CAMEL, value, true, false);
@@ -2502,6 +2598,14 @@ function camelCase(value) {
2502
2598
  *
2503
2599
  * @param value String to capitalize
2504
2600
  * @returns Capitalized string
2601
+ *
2602
+ * @example
2603
+ * ```typescript
2604
+ * capitalize('this is a test'); // => 'This is a test'
2605
+ * capitalize('This Is A Test'); // => 'This is a test'
2606
+ * capitalize('t'); // => 'T'
2607
+ * capitalize(''); // => ''
2608
+ * ```
2505
2609
  */
2506
2610
  function capitalize(value) {
2507
2611
  if (typeof value !== "string" || value.length === 0) return "";
@@ -2513,6 +2617,14 @@ function capitalize(value) {
2513
2617
  *
2514
2618
  * @param value String to convert
2515
2619
  * @returns Kebab-cased string
2620
+ *
2621
+ * @example
2622
+ * ```typescript
2623
+ * kebabCase('this is kebab case'); // => 'this-is-kebab-case'
2624
+ * kebabCase('ThisIsKebabCase'); // => 'this-is-kebab-case'
2625
+ * kebabCase('this-is-kebab-case'); // => 'this-is-kebab-case'
2626
+ * kebabCase('this_is_kebab_case'); // => 'this-is-kebab-case'
2627
+ * ```
2516
2628
  */
2517
2629
  function kebabCase(value) {
2518
2630
  return toCase(STRING_CASE_KEBAB, value, false, false);
@@ -2522,6 +2634,13 @@ function kebabCase(value) {
2522
2634
  *
2523
2635
  * @param value String to convert
2524
2636
  * @returns Lower-cased string
2637
+ *
2638
+ * @example
2639
+ * ```typescript
2640
+ * lowerCase('THIS IS A TEST'); // => 'this is a test'
2641
+ * lowerCase('this is a test'); // => 'this is a test'
2642
+ * lowerCase('t'); // => 't'
2643
+ * ```
2525
2644
  */
2526
2645
  function lowerCase(value) {
2527
2646
  if (typeof value !== "string") return "";
@@ -2533,6 +2652,14 @@ function lowerCase(value) {
2533
2652
  *
2534
2653
  * @param value String to convert
2535
2654
  * @returns Pascal-cased string
2655
+ *
2656
+ * @example
2657
+ * ```typescript
2658
+ * pascalCase('this is pascal case'); // => 'ThisIsPascalCase'
2659
+ * pascalCase('ThisIsPascalCase'); // => 'ThisIsPascalCase'
2660
+ * pascalCase('this-is-pascal-case'); // => 'ThisIsPascalCase'
2661
+ * pascalCase('this_is_pascal_case'); // => 'ThisIsPascalCase'
2662
+ * ```
2536
2663
  */
2537
2664
  function pascalCase(value) {
2538
2665
  return toCase(STRING_CASE_PASCAL, value, true, true);
@@ -2542,6 +2669,14 @@ function pascalCase(value) {
2542
2669
  *
2543
2670
  * @param value String to convert
2544
2671
  * @returns Snake-cased string
2672
+ *
2673
+ * @example
2674
+ * ```typescript
2675
+ * snakeCase('this is snake case'); // => 'this_is_snake_case'
2676
+ * snakeCase('ThisIsSnakeCase'); // => 'this_is_snake_case'
2677
+ * snakeCase('this-is-snake-case'); // => 'this_is_snake_case'
2678
+ * snakeCase('this_is_snake_case'); // => 'this_is_snake_case'
2679
+ * ```
2545
2680
  */
2546
2681
  function snakeCase(value) {
2547
2682
  return toCase(STRING_CASE_SNAKE, value, false, false);
@@ -2551,6 +2686,14 @@ function snakeCase(value) {
2551
2686
  *
2552
2687
  * @param value String to convert
2553
2688
  * @returns Title-cased string
2689
+ *
2690
+ * @example
2691
+ * ```typescript
2692
+ * titleCase('this is a test'); // => 'This Is A Test'
2693
+ * titleCase('This Is A Test'); // => 'This Is A Test'
2694
+ * titleCase('t'); // => 'T'
2695
+ * titleCase(''); // => ''
2696
+ * ```
2554
2697
  */
2555
2698
  function titleCase(value) {
2556
2699
  if (typeof value !== "string" || value.length === 0) return "";
@@ -2593,6 +2736,14 @@ function toCaseCallback(value) {
2593
2736
  *
2594
2737
  * @param value String to convert
2595
2738
  * @returns Upper-cased string
2739
+ *
2740
+ * @example
2741
+ * ```typescript
2742
+ * upperCase('this is a test'); // => 'THIS IS A TEST'
2743
+ * upperCase('This Is A Test'); // => 'THIS IS A TEST'
2744
+ * upperCase('t'); // => 'T'
2745
+ * upperCase(''); // => ''
2746
+ * ```
2596
2747
  */
2597
2748
  function upperCase(value) {
2598
2749
  if (typeof value !== "string" || value.length === 0) return "";
@@ -3337,6 +3488,9 @@ function isRejected(value) {
3337
3488
  function cancelable(executor) {
3338
3489
  return new CancelablePromise(executor);
3339
3490
  }
3491
+ /**
3492
+ * @internal
3493
+ */
3340
3494
  function handleResult(status, parameters) {
3341
3495
  const { aborter, complete, data, handlers, index, key, value } = parameters;
3342
3496
  if (aborter?.signal.aborted ?? false) return;
@@ -3360,6 +3514,9 @@ function handleResult(status, parameters) {
3360
3514
  handlers.resolve(data.result);
3361
3515
  }
3362
3516
  }
3517
+ /**
3518
+ * @internal
3519
+ */
3363
3520
  function settlePromise(settler, value, aborter) {
3364
3521
  aborter?.cancel();
3365
3522
  settler(value);
@@ -3390,6 +3547,9 @@ function delay(options) {
3390
3547
  }
3391
3548
  //#endregion
3392
3549
  //#region src/promise/timed.ts
3550
+ /**
3551
+ * @internal
3552
+ */
3393
3553
  async function getTimedPromise(promise, time, signal) {
3394
3554
  const aborter = createAborter(signal, () => {
3395
3555
  limiter.cancel();
@@ -3581,6 +3741,14 @@ const FUZZY_SYMBOL = Symbol(FUZZY_PROPERTY);
3581
3741
  * @param needle String to look for
3582
3742
  * @param ignoreCase Ignore case when matching? _(defaults to `false`)_
3583
3743
  * @returns `true` if the string ends with the given substring, otherwise `false`
3744
+ *
3745
+ * @example
3746
+ * ```typescript
3747
+ * endsWith('this is a test', 'test'); // => true
3748
+ * endsWith('this is a test', 'Test'); // => false
3749
+ * endsWith('this is a test', 'Test', true); // => true
3750
+ * endsWith('this is a test', 'not'); // => false
3751
+ * ```
3584
3752
  */
3585
3753
  function endsWith(haystack, needle, ignoreCase) {
3586
3754
  return match(STRING_MATCH_ENDS_WITH, haystack, needle, ignoreCase === true);
@@ -3592,6 +3760,14 @@ function endsWith(haystack, needle, ignoreCase) {
3592
3760
  * @param needle String to look for
3593
3761
  * @param ignoreCase Ignore case when matching? _(defaults to `false`)_
3594
3762
  * @returns `true` if the string includes the given substring, otherwise `false`
3763
+ *
3764
+ * @example
3765
+ * ```typescript
3766
+ * includes('this is a test', 'is'); // => true
3767
+ * includes('this is a test', 'Is'); // => false
3768
+ * includes('this is a test', 'Is', true); // => true
3769
+ * includes('this is a test', 'not'); // => false
3770
+ * ```
3595
3771
  */
3596
3772
  function includes(haystack, needle, ignoreCase) {
3597
3773
  return match(STRING_MATCH_INCLUDES, haystack, needle, ignoreCase === true);
@@ -3611,6 +3787,14 @@ function matchCallback(haystack, needle, ignoreCase) {
3611
3787
  * @param needle String to look for
3612
3788
  * @param ignoreCase Ignore case when matching? _(defaults to `false`)_
3613
3789
  * @returns `true` if the string starts with the given substring, otherwise `false`
3790
+ *
3791
+ * @example
3792
+ * ```typescript
3793
+ * startsWith('this is a test', 'this'); // => true
3794
+ * startsWith('this is a test', 'This'); // => false
3795
+ * startsWith('this is a test', 'This', true); // => true
3796
+ * startsWith('this is a test', 'not'); // => false
3797
+ * ```
3614
3798
  */
3615
3799
  function startsWith(haystack, needle, ignoreCase) {
3616
3800
  return match(STRING_MATCH_STARTS_WITH, haystack, needle, ignoreCase === true);
@@ -3855,7 +4039,7 @@ function getUuid(html) {
3855
4039
  *
3856
4040
  * @param value JSON string to parse
3857
4041
  * @param reviver Reviver function to transform the parsed values
3858
- * @returns Parsed value or `undefined` if parsing fails
4042
+ * @returns Parsed value, or `undefined` if parsing fails
3859
4043
  */
3860
4044
  function parse(value, reviver) {
3861
4045
  try {
@@ -3869,6 +4053,13 @@ function parse(value, reviver) {
3869
4053
  *
3870
4054
  * @param value String to trim
3871
4055
  * @returns Trimmed string
4056
+ * @example
4057
+ * ```typescript
4058
+ * trim(' this is a test '); // => 'this is a test'
4059
+ * trim('this is a test'); // => 'this is a test'
4060
+ * trim(' '); // => ''
4061
+ * trim(''); // => ''
4062
+ * ```
3872
4063
  */
3873
4064
  function trim(value) {
3874
4065
  return typeof value === "string" ? value.trim() : "";
@@ -3880,6 +4071,13 @@ function trim(value) {
3880
4071
  * @param length Maximum length of the string after truncation
3881
4072
  * @param suffix Suffix to append to the truncated string
3882
4073
  * @returns Truncated string
4074
+ * @example
4075
+ * ```typescript
4076
+ * truncate('this is a test', 7); // => 'this is'
4077
+ * truncate('this is a test', 7, '...'); // => 'this ...'
4078
+ * truncate('this is a test', 20); // => 'this is a test'
4079
+ * truncate('this is a test', 0); // => ''
4080
+ * ```
3883
4081
  */
3884
4082
  function truncate(value, length, suffix) {
3885
4083
  if (typeof value !== "string" || typeof length !== "number" || length === 0) return "";
@@ -5929,6 +6127,14 @@ function getHexaColor$1() {
5929
6127
  * @param value Value to normalize
5930
6128
  * @param alpha Include alpha channel _(opacity)_? _(defaults to `false`)_
5931
6129
  * @returns Normalized hex color
6130
+ *
6131
+ * @example
6132
+ * ```typescript
6133
+ * getNormalizedHex('#abc'); // => '#aabbcc'
6134
+ * getNormalizedHex('#abc', true); // => '#aabbccff'
6135
+ * getNormalizedHex(123); // => '#000000'
6136
+ * getNormalizedHex(123, true); // => '#000000ff'
6137
+ * ```
5932
6138
  */
5933
6139
  function getNormalizedHex(value, alpha) {
5934
6140
  const includeAlpha = alpha === true;
@@ -6703,12 +6909,24 @@ function getTimeLoggerStop() {
6703
6909
  }
6704
6910
  return noop;
6705
6911
  }
6912
+ /**
6913
+ * Is the value a _Logger_?
6914
+ *
6915
+ * @param value Value to check
6916
+ * @returns `true` if the value is a _Logger_, otherwise `false`
6917
+ */
6706
6918
  function isLogger(value) {
6707
6919
  return isLoggerInstance(LOGGER_NAME, value);
6708
6920
  }
6709
6921
  function isLoggerInstance(name, value) {
6710
6922
  return typeof value === "object" && value !== null && "$logger" in value && value["$logger"] === name;
6711
6923
  }
6924
+ /**
6925
+ * Is the value a _TimeLogger_?
6926
+ *
6927
+ * @param value Value to check
6928
+ * @returns `true` if the value is a _TimeLogger_, otherwise `false`
6929
+ */
6712
6930
  function isTimeLogger(value) {
6713
6931
  return isLoggerInstance(LOGGER_NAME_TIMED, value);
6714
6932
  }
@@ -6734,6 +6952,13 @@ function average(array, key) {
6734
6952
  * @param value Number to round up
6735
6953
  * @param decimals Number of decimal places to round to _(defaults to `0`)_
6736
6954
  * @returns Rounded number, or `Number.NaN` if the value if unable to be rounded
6955
+ *
6956
+ * @example
6957
+ * ```typescript
6958
+ * ceil(1.234, 2); // => 1.24
6959
+ * ceil(1.234); // => 2
6960
+ * ceil('abc'); // => Number.NaN
6961
+ * ```
6737
6962
  */
6738
6963
  function ceil(value, decimals) {
6739
6964
  return roundNumber(Math.ceil, value, decimals);
@@ -7353,4 +7578,4 @@ var SizedSet = class extends Set {
7353
7578
  }
7354
7579
  };
7355
7580
  //#endregion
7356
- export { CancelablePromise, Logger, PromiseTimeoutError, RetryError, SORT_DIRECTION_ASCENDING, SORT_DIRECTION_DESCENDING, SizedMap, SizedSet, push as append, push, assert, assertCondition, assertDefined, assertInstanceOf, assertIs, assertProperty, assign, asyncAttempt, asyncAttemptRun, asyncDebounce, asyncFail, asyncFlow, asyncMatchResult, asyncOnce, asyncPipe, asyncRun, asyncSucceed, asyncThrottle, asyncUse, attempt, attemptAsyncFlow, attemptAsyncPipe, attemptFlow, attemptPipe, attemptPromise, attemptRun, average, beacon, between, camelCase, cancelable, capitalize, ceil, chunk, clamp, clone, compact, compare, copy, count, debounce, deburr, dedent, delay, deregisterCloner, deregisterComparator, deregisterEqualizer, diff, difference, drop, endsWith, endsWithArray, equal, error, exclude, exists, fail, filter, filterAndMap, filterAndMap as select, find, findLast, first, firstOrDefault, flatFreeze, flatten, floor, flow, freeze, fromQuery, toPromise as fromResult, toPromise, fuzzy, fuzzyMatch, getArray, getArrayComparison, getColor, getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getHwbColor, getHwbaColor, getNormalizedHex, getNumber, getRandom, getRandomBoolean, getRandomCharacters, getRandomColor, getRandomFloatingNumber as getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems, getRgbColor, getRgbaColor, getSortedIndex, getString, getTimedPromise, getUuid, getValue, groupArraysBy, groupBy, handleResult, hasValue, hasValueResult, herald, hexToHsl, hexToHsla, hexToHwb, hexToHwba, hexToRgb, hexToRgba, hslToHex, hslToHwb, hslToHwba, hslToRgb, hslToRgba, hwbToHex, hwbToHsl, hwbToHsla, hwbToRgb, hwbToRgba, ignoreKey, inMap, inSet, includes, includesArray, indexOf, indexOfArray, initializeAssigner, initializeCloner, initializeEqualizer, initializeMerger, initializeNormalizer, initializeSorter, initializeTemplater, initializeTransformer, insert, interpolate, intersection, isArrayOrPlainObject, isAsyncFailure, isAsyncGenerator, isAsyncGeneratorFunction, isAsyncOnce, isAsyncPlan, isAsyncStep, isAsyncSuccess, isBeacon, isBeaconSubscription, isColor, isConstructor, isEmpty, isError, isFailure, isFrozen, isFulfilled, isFuzzy, isGenerator, isGeneratorFunction, isHerald, isHeraldEvents, isHeraldSubscription, isHexColor, isHslColor, isHslaColor, isHwbColor, isHwbaColor, isInstanceOf, isKey, isKeyedQueue, isLogger, isNonArrayOrPlainObject, isNonConstructor, isNonEmpty, isNonInstanceOf, isNonKey, isNonNullable, isNonNullableOrEmpty, isNonNullableOrWhitespace, isNonNumber, isNonNumerical, isNonObject, isNonPlainObject, isNonPrimitive, isNonTemplateStringsArray, isNonTypedArray, isNullable, isNullableOrEmpty, isNullableOrWhitespace, isNumber, isNumerical, isObject, isObservable, isOk, isOnce, isPlainObject, isPlan, isPrimitive, isQueue, isQueueInstance, isRejected, isResult, isRgbColor, isRgbaColor, isSorted, isStep, isSubscription, isSubscriptions, isSuccess, isTemplateStringsArray, isTimeLogger, isTypedArray, join, kebabCase, keyedQueue, last, lastIndexOf, lastOrDefault, lowerCase, mapAndFilter, mapAndFilter as reverseSelect, matchResult, max, median, memoize, merge, min, move, moveIndices, moveToIndex, noop, normalize, ok, omit, once, parse, partition, pascalCase, pick, pipe, plan, promises, queue, range, registerCloner, registerComparator, registerEqualizer, resultPromises, retry, reverse, rgbToHex, rgbToHsl, rgbToHsla, rgbToHwb, rgbToHwba, round, run, setValue, settlePromise, shake, shuffle, single, slice, smush, snakeCase, sort, splice, startsWith, startsWithArray, subscriptions, succeed, sum, swap, take, template, throttle, timed, times, titleCase, toMap, toMapArrays, toQuery, toRecord, toRecordArrays, toResult, toSet, toggle, transform, trim, truncate, tryDecode, tryEncode, union, unique, unsmush, unwrap, update, upperCase, use, words };
7581
+ export { CancelablePromise, Logger, PromiseTimeoutError, RetryError, SORT_DIRECTION_ASCENDING, SORT_DIRECTION_DESCENDING, SizedMap, SizedSet, push as append, push, assert, assertCondition, assertDefined, assertInstanceOf, assertIs, assertProperty, assign, asyncAttempt, asyncAttemptRun, asyncDebounce, asyncFail, asyncFlow, asyncMatchResult, asyncOnce, asyncPipe, asyncRun, asyncSucceed, asyncThrottle, asyncUse, attempt, attemptAsyncFlow, attemptAsyncPipe, attemptFlow, attemptPipe, attemptPromise, attemptRun, average, beacon, between, camelCase, cancelable, capitalize, ceil, chunk, clamp, clone, compact, compare, copy, count, debounce, deburr, dedent, delay, deregisterCloner, deregisterComparator, deregisterEqualizer, diff, difference, drop, endsWith, endsWithArray, equal, error, exclude, exists, fail, filter, filterAndFlatMap, filterAndMap, filterAndMap as select, find, findLast, first, firstOrDefault, flatFreeze, flatMapAndFilter, flatten, floor, flow, freeze, fromQuery, toPromise as fromResult, toPromise, fuzzy, fuzzyMatch, getArray, getArrayComparison, getColor, getForegroundColor, getHexColor, getHexaColor, getHslColor, getHslaColor, getHwbColor, getHwbaColor, getNormalizedHex, getNumber, getRandom, getRandomBoolean, getRandomCharacters, getRandomColor, getRandomFloatingNumber as getRandomFloat, getRandomHex, getRandomInteger, getRandomItem, getRandomItems, getRgbColor, getRgbaColor, getSortedIndex, getString, getTimedPromise, getUuid, getValue, groupArraysBy, groupBy, handleResult, hasValue, hasValueResult, herald, hexToHsl, hexToHsla, hexToHwb, hexToHwba, hexToRgb, hexToRgba, hslToHex, hslToHwb, hslToHwba, hslToRgb, hslToRgba, hwbToHex, hwbToHsl, hwbToHsla, hwbToRgb, hwbToRgba, ignoreKey, inMap, inSet, includes, includesArray, indexOf, indexOfArray, initializeAssigner, initializeCloner, initializeEqualizer, initializeMerger, initializeNormalizer, initializeSorter, initializeTemplater, initializeTransformer, insert, interpolate, intersection, isArrayOrPlainObject, isAsyncFailure, isAsyncGenerator, isAsyncGeneratorFunction, isAsyncOnce, isAsyncPlan, isAsyncStep, isAsyncSuccess, isBeacon, isBeaconSubscription, isColor, isConstructor, isEmpty, isError, isFailure, isFrozen, isFulfilled, isFuzzy, isGenerator, isGeneratorFunction, isHerald, isHeraldEvents, isHeraldSubscription, isHexColor, isHslColor, isHslaColor, isHwbColor, isHwbaColor, isInstanceOf, isKey, isKeyedQueue, isLogger, isNonArrayOrPlainObject, isNonConstructor, isNonEmpty, isNonInstanceOf, isNonKey, isNonNullable, isNonNullableOrEmpty, isNonNullableOrWhitespace, isNonNumber, isNonNumerical, isNonObject, isNonPlainObject, isNonPrimitive, isNonTemplateStringsArray, isNonTypedArray, isNullable, isNullableOrEmpty, isNullableOrWhitespace, isNumber, isNumerical, isObject, isObservable, isOk, isOnce, isPlainObject, isPlan, isPrimitive, isQueue, isRejected, isResult, isRgbColor, isRgbaColor, isSorted, isStep, isSubscription, isSubscriptions, isSuccess, isTemplateStringsArray, isTimeLogger, isTypedArray, join, kebabCase, keyedQueue, last, lastIndexOf, lastOrDefault, lowerCase, mapAndFilter, mapAndFilter as reverseSelect, matchResult, max, median, memoize, merge, min, move, moveIndices, moveToIndex, noop, normalize, ok, omit, once, parse, partition, pascalCase, pick, pipe, plan, promises, queue, range, registerCloner, registerComparator, registerEqualizer, resultPromises, retry, reverse, rgbToHex, rgbToHsl, rgbToHsla, rgbToHwb, rgbToHwba, round, run, setValue, settlePromise, shake, shuffle, single, slice, smush, snakeCase, sort, splice, startsWith, startsWithArray, subscriptions, succeed, sum, swap, take, template, throttle, timed, times, titleCase, toMap, toMapArrays, toQuery, toRecord, toRecordArrays, toResult, toSet, toggle, transform, trim, truncate, tryDecode, tryEncode, union, unique, unsmush, unwrap, update, upperCase, use, words };
@@ -3,7 +3,7 @@ function getArrayCallback(value) {
3
3
  switch (typeof value) {
4
4
  case "function": return value;
5
5
  case "number":
6
- case "string": return typeof value === "string" && value.includes(".") ? void 0 : (obj) => obj[value];
6
+ case "string": return (obj) => obj?.[value];
7
7
  default: return;
8
8
  }
9
9
  }
@@ -1,8 +1,8 @@
1
- import { ArrayFindMapper, ArrayFindValueType, ArrayFindValuesResult, ArrayFindValuesType, ArrayParameters } from "../../models/array/array.find.model.mjs";
1
+ import { ArrayFindOptions, ArrayFindValueType, ArrayFindValuesResult, ArrayFindValuesType, ArrayParameters } from "../../models/array/array.find.model.mjs";
2
2
  //#region src/internal/array/find.d.ts
3
3
  export declare function createFindParameters(original: unknown[]): ArrayParameters;
4
+ export declare function findAbsoluteValueOrDefault(array: unknown[], parameters: unknown[], defaultValue: unknown, useDefaultValue: boolean, reversed: boolean): unknown;
4
5
  export declare function findValue(type: Exclude<ArrayFindValueType, "item">, array: unknown[], parameters: unknown[], reversed: boolean): number;
5
6
  export declare function findValue(type: Exclude<ArrayFindValueType, "index">, array: unknown[], parameters: unknown[], reversed: boolean): unknown;
6
- export declare function findAbsoluteValueOrDefault(array: unknown[], parameters: unknown[], defaultValue: unknown, useDefaultValue: boolean, reversed: boolean): unknown;
7
- export declare function findValues(type: ArrayFindValuesType, array: unknown[], parameters: unknown[], mapper?: ArrayFindMapper): ArrayFindValuesResult;
7
+ export declare function findValues(type: ArrayFindValuesType, array: unknown[], parameters: unknown[], options?: ArrayFindOptions): ArrayFindValuesResult;
8
8
  //#endregion