@dereekb/util 13.0.7 → 13.2.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 (143) hide show
  1. package/fetch/package.json +2 -2
  2. package/index.cjs.js +4107 -1516
  3. package/index.esm.js +4107 -1516
  4. package/package.json +1 -2
  5. package/src/lib/array/array.d.ts +92 -47
  6. package/src/lib/array/array.find.d.ts +14 -18
  7. package/src/lib/array/array.index.d.ts +43 -14
  8. package/src/lib/array/array.indexed.d.ts +66 -17
  9. package/src/lib/array/array.limit.d.ts +11 -0
  10. package/src/lib/array/array.make.d.ts +9 -3
  11. package/src/lib/array/array.map.d.ts +20 -8
  12. package/src/lib/array/array.number.d.ts +63 -5
  13. package/src/lib/array/array.random.d.ts +12 -9
  14. package/src/lib/array/array.set.d.ts +24 -1
  15. package/src/lib/array/array.string.d.ts +104 -0
  16. package/src/lib/array/array.unique.d.ts +60 -8
  17. package/src/lib/array/array.value.d.ts +20 -11
  18. package/src/lib/assertion/assertion.d.ts +30 -2
  19. package/src/lib/assertion/assertion.generic.d.ts +8 -0
  20. package/src/lib/assertion/assertion.number.d.ts +16 -0
  21. package/src/lib/auth/auth.role.claims.d.ts +14 -8
  22. package/src/lib/boolean.d.ts +54 -1
  23. package/src/lib/contact/domain.d.ts +22 -4
  24. package/src/lib/contact/random.d.ts +24 -0
  25. package/src/lib/date/date.d.ts +8 -13
  26. package/src/lib/date/hour.d.ts +51 -32
  27. package/src/lib/date/minute.d.ts +4 -4
  28. package/src/lib/date/time.d.ts +12 -3
  29. package/src/lib/date/week.d.ts +77 -10
  30. package/src/lib/error/error.d.ts +54 -3
  31. package/src/lib/error/error.server.d.ts +25 -2
  32. package/src/lib/filter/filter.d.ts +12 -7
  33. package/src/lib/function/function.boolean.d.ts +4 -4
  34. package/src/lib/function/function.d.ts +2 -5
  35. package/src/lib/function/function.forward.d.ts +19 -3
  36. package/src/lib/getter/getter.cache.d.ts +9 -5
  37. package/src/lib/getter/getter.d.ts +39 -22
  38. package/src/lib/getter/getter.map.d.ts +10 -4
  39. package/src/lib/getter/getter.util.d.ts +3 -3
  40. package/src/lib/grouping.d.ts +98 -31
  41. package/src/lib/hash.d.ts +15 -8
  42. package/src/lib/iterable/iterable.d.ts +62 -50
  43. package/src/lib/iterable/iterable.map.d.ts +4 -4
  44. package/src/lib/iterate.d.ts +17 -1
  45. package/src/lib/key.d.ts +32 -10
  46. package/src/lib/lifecycle.d.ts +10 -1
  47. package/src/lib/map/map.d.ts +17 -16
  48. package/src/lib/map/map.intersection.d.ts +5 -4
  49. package/src/lib/map/map.key.d.ts +16 -15
  50. package/src/lib/misc/host.d.ts +6 -3
  51. package/src/lib/model/id.batch.d.ts +7 -3
  52. package/src/lib/model/id.factory.d.ts +16 -1
  53. package/src/lib/model/model.conversion.d.ts +49 -6
  54. package/src/lib/model/model.conversion.field.d.ts +13 -3
  55. package/src/lib/model/model.copy.d.ts +11 -0
  56. package/src/lib/model/model.d.ts +174 -1
  57. package/src/lib/model/model.modify.d.ts +24 -5
  58. package/src/lib/nodejs/stream.d.ts +8 -6
  59. package/src/lib/number/bitwise.dencoder.d.ts +43 -3
  60. package/src/lib/number/bound.d.ts +34 -5
  61. package/src/lib/number/dollar.d.ts +13 -6
  62. package/src/lib/number/factory.d.ts +11 -3
  63. package/src/lib/number/number.d.ts +55 -32
  64. package/src/lib/number/random.d.ts +13 -3
  65. package/src/lib/number/round.d.ts +47 -26
  66. package/src/lib/number/sort.d.ts +7 -1
  67. package/src/lib/number/transform.d.ts +16 -0
  68. package/src/lib/object/object.array.d.ts +16 -2
  69. package/src/lib/object/object.array.delta.d.ts +6 -2
  70. package/src/lib/object/object.d.ts +33 -5
  71. package/src/lib/object/object.empty.d.ts +4 -2
  72. package/src/lib/object/object.equal.d.ts +21 -4
  73. package/src/lib/object/object.filter.tuple.d.ts +105 -3
  74. package/src/lib/object/object.key.d.ts +13 -6
  75. package/src/lib/object/object.map.d.ts +30 -19
  76. package/src/lib/page/page.d.ts +21 -0
  77. package/src/lib/page/page.filter.d.ts +16 -9
  78. package/src/lib/path/path.d.ts +101 -14
  79. package/src/lib/path/path.tree.d.ts +16 -0
  80. package/src/lib/promise/callback.d.ts +18 -0
  81. package/src/lib/promise/is.d.ts +10 -3
  82. package/src/lib/promise/map.d.ts +5 -3
  83. package/src/lib/promise/poll.d.ts +14 -4
  84. package/src/lib/promise/promise.d.ts +84 -18
  85. package/src/lib/promise/promise.factory.d.ts +18 -2
  86. package/src/lib/promise/promise.limit.d.ts +22 -2
  87. package/src/lib/promise/promise.loop.d.ts +69 -1
  88. package/src/lib/promise/promise.ref.d.ts +14 -2
  89. package/src/lib/promise/promise.task.d.ts +8 -4
  90. package/src/lib/promise/promise.type.d.ts +4 -4
  91. package/src/lib/promise/use.d.ts +6 -4
  92. package/src/lib/promise/wait.d.ts +5 -2
  93. package/src/lib/relation/relation.d.ts +98 -0
  94. package/src/lib/service/handler.config.d.ts +47 -9
  95. package/src/lib/service/handler.d.ts +43 -1
  96. package/src/lib/service/typed.service.d.ts +21 -2
  97. package/src/lib/set/set.allowed.d.ts +6 -4
  98. package/src/lib/set/set.d.ts +174 -46
  99. package/src/lib/set/set.decision.d.ts +4 -2
  100. package/src/lib/set/set.delta.d.ts +16 -3
  101. package/src/lib/set/set.hashset.d.ts +43 -0
  102. package/src/lib/set/set.selection.d.ts +7 -3
  103. package/src/lib/sort.d.ts +36 -16
  104. package/src/lib/string/char.d.ts +48 -34
  105. package/src/lib/string/dencoder.d.ts +84 -13
  106. package/src/lib/string/factory.d.ts +13 -4
  107. package/src/lib/string/html.d.ts +7 -6
  108. package/src/lib/string/mimetype.d.ts +65 -1
  109. package/src/lib/string/prefix.d.ts +21 -7
  110. package/src/lib/string/record.d.ts +7 -4
  111. package/src/lib/string/replace.d.ts +77 -33
  112. package/src/lib/string/search.d.ts +19 -9
  113. package/src/lib/string/sort.d.ts +10 -1
  114. package/src/lib/string/string.d.ts +74 -21
  115. package/src/lib/string/transform.d.ts +7 -0
  116. package/src/lib/string/tree.d.ts +91 -29
  117. package/src/lib/string/url.d.ts +148 -63
  118. package/src/lib/tree/tree.explore.d.ts +84 -17
  119. package/src/lib/tree/tree.flatten.d.ts +44 -7
  120. package/src/lib/type.d.ts +15 -12
  121. package/src/lib/value/address.d.ts +66 -17
  122. package/src/lib/value/bound.d.ts +253 -17
  123. package/src/lib/value/build.d.ts +30 -5
  124. package/src/lib/value/comparator.d.ts +53 -25
  125. package/src/lib/value/cron.d.ts +14 -6
  126. package/src/lib/value/decision.d.ts +57 -13
  127. package/src/lib/value/equal.d.ts +44 -13
  128. package/src/lib/value/indexed.d.ts +253 -82
  129. package/src/lib/value/label.d.ts +16 -5
  130. package/src/lib/value/map.d.ts +77 -20
  131. package/src/lib/value/maybe.d.ts +47 -49
  132. package/src/lib/value/modifier.d.ts +82 -27
  133. package/src/lib/value/point.d.ts +248 -54
  134. package/src/lib/value/url.d.ts +10 -3
  135. package/src/lib/value/use.d.ts +99 -8
  136. package/src/lib/value/vector.d.ts +71 -9
  137. package/test/index.cjs.js +86 -23
  138. package/test/index.esm.js +86 -23
  139. package/test/package.json +2 -2
  140. package/test/src/lib/shared/shared.d.ts +31 -5
  141. package/test/src/lib/shared/shared.fail.d.ts +72 -9
  142. package/test/src/lib/shared/shared.function.d.ts +40 -2
  143. package/test/src/lib/shared/shared.wrap.d.ts +20 -1
@@ -4,13 +4,21 @@ import { type Minutes } from '../date/date';
4
4
  */
5
5
  export type CronExpression = string;
6
6
  /**
7
- * Creates a CronExpression for the input number of minutes.
7
+ * Creates a {@link CronExpression} that repeats at approximately every N minutes.
8
8
  *
9
- * Note that if the number of minutes is greater than 60, it will generate an expression that
10
- * isn't exactly n number of minutes apart from the previous execution, but instead create
11
- * an expression that is n/60 hours apart and take place on the n%60th minute.
9
+ * For values under 60, produces a cron expression using minute intervals (e.g., 5 produces every 5th minute).
10
+ * For values of 60 or more, the expression is split into hours and minutes (e.g., 90 minutes becomes
11
+ * every 1 hour at minute 30), which means intervals won't be exactly N minutes apart.
12
12
  *
13
- * @param inputMinutes
14
- * @returns
13
+ * @param inputMinutes - interval in minutes between executions
14
+ *
15
+ * @example
16
+ * ```ts
17
+ * // For intervals under 60 minutes:
18
+ * cronExpressionRepeatingEveryNMinutes(5); // returns a cron for every 5th minute
19
+ *
20
+ * // For intervals of 60+ minutes:
21
+ * cronExpressionRepeatingEveryNMinutes(90); // returns a cron for every 1 hour at minute 30
22
+ * ```
15
23
  */
16
24
  export declare function cronExpressionRepeatingEveryNMinutes(inputMinutes: Minutes): CronExpression;
@@ -2,34 +2,78 @@ import { type FactoryWithRequiredInput } from '../getter/getter';
2
2
  import { type MapFunction, type AsyncMapFunction } from './map';
3
3
  import { type Maybe } from './maybe.type';
4
4
  /**
5
- * A map function that derives a boolean from the input.
5
+ * A map function that derives a boolean decision from the input value.
6
6
  */
7
7
  export type DecisionFunction<I> = MapFunction<I, boolean>;
8
+ /**
9
+ * Async variant of {@link DecisionFunction}.
10
+ */
8
11
  export type AsyncDecisionFunction<I> = AsyncMapFunction<DecisionFunction<I>>;
12
+ /**
13
+ * Factory that creates a {@link DecisionFunction} from a configuration value.
14
+ */
9
15
  export type DecisionFunctionFactory<C, I> = FactoryWithRequiredInput<DecisionFunction<I>, C>;
16
+ /**
17
+ * Creates a {@link DecisionFunction} that always returns the given boolean, regardless of input.
18
+ *
19
+ * Useful for providing a constant decision where a function is expected.
20
+ *
21
+ * @param decision - the constant boolean value to return
22
+ *
23
+ * @example
24
+ * ```ts
25
+ * const alwaysTrue = decisionFunction(true);
26
+ * alwaysTrue('anything'); // true
27
+ * ```
28
+ */
10
29
  export declare function decisionFunction<I>(decision: boolean): DecisionFunction<I>;
11
30
  /**
12
- * Used to invert a decision function by returning the opposite of what it returns.
31
+ * Inverts a decision function so it returns the opposite boolean value.
32
+ *
33
+ * When `invert` is false or omitted, the original function is returned unchanged.
13
34
  *
14
- * @param filterFn
15
- * @param invert whether or not to apply the inversion.
16
- * @returns
35
+ * @param fn - the decision function to potentially invert
36
+ * @param invert - whether to apply the inversion
37
+ *
38
+ * @example
39
+ * ```ts
40
+ * const isPositive: DecisionFunction<number> = (x) => x > 0;
41
+ * const isNotPositive = invertDecision(isPositive, true);
42
+ * isNotPositive(5); // false
43
+ * ```
17
44
  */
18
45
  export declare const invertDecision: <F extends DecisionFunction<any>>(fn: F, invert?: boolean) => F;
19
46
  /**
20
- * Creates a DecisionFunction from the input.
47
+ * Normalizes a boolean value, a {@link DecisionFunction}, or undefined into a consistent {@link DecisionFunction}.
48
+ *
49
+ * If the input is undefined, falls back to a constant function returning `defaultIfUndefined`.
21
50
  *
22
- * @param valueOrFunction
23
- * @param defaultIfUndefined
24
- * @returns
51
+ * @param valueOrFunction - a boolean, decision function, or undefined
52
+ * @param defaultIfUndefined - fallback boolean when the input is nullish (defaults to true)
53
+ *
54
+ * @example
55
+ * ```ts
56
+ * const fn = asDecisionFunction(true);
57
+ * fn('anything'); // true
58
+ *
59
+ * const fn2 = asDecisionFunction(undefined, false);
60
+ * fn2('anything'); // false
61
+ * ```
25
62
  */
26
63
  export declare function asDecisionFunction<T = unknown>(valueOrFunction: Maybe<boolean | DecisionFunction<T>>, defaultIfUndefined?: boolean): DecisionFunction<T>;
27
64
  /**
28
- * Creates a DecisionFunction from the input. If the input is not a function then that value is returned.
65
+ * Creates a {@link DecisionFunction} that checks strict equality against the given value.
66
+ *
67
+ * If the input is already a function, it is returned as-is, allowing callers to pass either a
68
+ * concrete value or a custom decision function interchangeably.
29
69
  *
30
- * If the input is
70
+ * @param equalityValue - the value to compare against, or an existing decision function
31
71
  *
32
- * @param equalityValue
33
- * @returns
72
+ * @example
73
+ * ```ts
74
+ * const isThree = isEqualToValueDecisionFunction(3);
75
+ * isThree(3); // true
76
+ * isThree(4); // false
77
+ * ```
34
78
  */
35
79
  export declare function isEqualToValueDecisionFunction<T>(equalityValue: T | DecisionFunction<T>): T extends DecisionFunction<T> ? T : DecisionFunction<T>;
@@ -11,28 +11,59 @@ export type IsEqualContext<T = unknown> = (x: T) => boolean;
11
11
  */
12
12
  export type AreEqualContext<T = unknown> = (x: IterableOrValue<T>) => boolean;
13
13
  /**
14
- * Creates an IsEqualContext
14
+ * Creates an {@link IsEqualContext} that captures a reference value and uses the provided comparator
15
+ * to check whether subsequent values are equal to it.
15
16
  *
16
- * @param contextValue
17
- * @param fn
18
- * @returns
17
+ * @param contextValue - the reference value to compare against
18
+ * @param fn - the equality comparator
19
+ *
20
+ * @example
21
+ * ```ts
22
+ * const isEqual = (a: number, b: number) => a === b;
23
+ * const context = isEqualContext(0, isEqual);
24
+ *
25
+ * context(0); // true
26
+ * context(10); // false
27
+ * ```
19
28
  */
20
29
  export declare function isEqualContext<T>(contextValue: T, fn: EqualityComparatorFunction<T>): IsEqualContext<T>;
21
30
  /**
22
- * Creates an AreEqualContext
31
+ * Creates an {@link AreEqualContext} that checks whether a single value or all values in an iterable
32
+ * are equal to the captured reference value.
33
+ *
34
+ * Returns `true` only if every value in the input matches the context value according to the comparator.
35
+ *
36
+ * @param contextValue - the reference value to compare against
37
+ * @param fn - the equality comparator
23
38
  *
24
- * @param contextValue
25
- * @param fn
26
- * @returns
39
+ * @example
40
+ * ```ts
41
+ * const isEqual = (a: number, b: number) => a === b;
42
+ * const context = areEqualContext(0, isEqual);
43
+ *
44
+ * context([0, 0, 0]); // true
45
+ * context([0, 1, 2]); // false
46
+ * ```
27
47
  */
28
48
  export declare function areEqualContext<T>(contextValue: T, fn: EqualityComparatorFunction<T>): AreEqualContext<T>;
29
49
  /**
30
- * Returns true if all input values are equal.
50
+ * Returns `true` if all values in the input are equal according to the provided comparator.
51
+ *
52
+ * Empty iterables and single-value inputs return `true` by default, since there is nothing to contradict equality.
53
+ * Uses the first value as the reference and checks all remaining values against it.
54
+ *
55
+ * @param values - the values to compare
56
+ * @param fn - the equality comparator
57
+ *
58
+ * @example
59
+ * ```ts
60
+ * const isEqual = (a: unknown, b: unknown) => a === b;
31
61
  *
32
- * Arrays that are empty or have one value will return true by default.
62
+ * allObjectsAreEqual([undefined, undefined, undefined], isEqual);
63
+ * // true
33
64
  *
34
- * @param values
35
- * @param fn
36
- * @returns
65
+ * allObjectsAreEqual([undefined, 'test', undefined], isEqual);
66
+ * // false
67
+ * ```
37
68
  */
38
69
  export declare function allObjectsAreEqual<T>(values: IterableOrValue<T>, fn: EqualityComparatorFunction<T>): boolean;