@dereekb/util 11.1.8 → 12.0.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 (49) hide show
  1. package/fetch/index.cjs.js +3051 -2146
  2. package/fetch/index.esm.d.ts +1 -0
  3. package/fetch/index.esm.js +2904 -1888
  4. package/fetch/package.json +4 -3
  5. package/index.cjs.js +3771 -3654
  6. package/index.esm.d.ts +1 -0
  7. package/index.esm.js +3783 -5031
  8. package/package.json +4 -3
  9. package/src/lib/array/array.boolean.d.ts +50 -0
  10. package/src/lib/array/array.factory.d.ts +17 -14
  11. package/src/lib/array/array.filter.d.ts +34 -18
  12. package/src/lib/array/array.find.d.ts +17 -5
  13. package/src/lib/array/array.index.d.ts +2 -1
  14. package/src/lib/array/array.limit.d.ts +3 -2
  15. package/src/lib/assertion/assert.d.ts +9 -1
  16. package/src/lib/assertion/assert.error.d.ts +50 -7
  17. package/src/lib/auth/auth.role.d.ts +7 -0
  18. package/src/lib/boolean.d.ts +51 -6
  19. package/src/lib/contact/email.d.ts +33 -0
  20. package/src/lib/contact/phone.d.ts +48 -14
  21. package/src/lib/date/date.d.ts +109 -27
  22. package/src/lib/date/date.time.d.ts +25 -2
  23. package/src/lib/date/expires.d.ts +27 -21
  24. package/src/lib/date/time.d.ts +15 -24
  25. package/src/lib/grouping.d.ts +3 -0
  26. package/src/lib/nodejs/stream.d.ts +0 -2
  27. package/src/lib/relation/relation.d.ts +15 -11
  28. package/src/lib/set/set.delta.d.ts +1 -1
  29. package/src/lib/string/dencoder.d.ts +1 -1
  30. package/src/lib/string/html.d.ts +14 -1
  31. package/src/lib/string/index.d.ts +1 -0
  32. package/src/lib/string/prefix.d.ts +81 -0
  33. package/src/lib/string/replace.d.ts +2 -2
  34. package/src/lib/value/indexed.d.ts +7 -7
  35. package/src/lib/value/maybe.d.ts +10 -3
  36. package/test/CHANGELOG.md +9 -0
  37. package/test/package.json +3 -2
  38. package/test/src/lib/jest.d.ts +1 -1
  39. package/test/src/lib/jest.fail.d.ts +3 -3
  40. package/test/src/lib/jest.fail.js +15 -15
  41. package/test/src/lib/jest.fail.js.map +1 -1
  42. package/test/src/lib/jest.function.d.ts +1 -1
  43. package/test/src/lib/jest.function.js +2 -3
  44. package/test/src/lib/jest.function.js.map +1 -1
  45. package/test/src/lib/jest.js +3 -3
  46. package/test/src/lib/jest.js.map +1 -1
  47. package/test/src/lib/jest.wrap.d.ts +1 -1
  48. package/test/src/lib/jest.wrap.js +3 -3
  49. package/test/src/lib/jest.wrap.js.map +1 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@dereekb/util",
3
- "version": "11.1.8",
3
+ "version": "12.0.0",
4
4
  "exports": {
5
5
  ".": {
6
6
  "types": "./src/index.d.ts",
@@ -40,5 +40,6 @@
40
40
  },
41
41
  "dependencies": {},
42
42
  "module": "./index.esm.js",
43
- "main": "./index.cjs.js"
44
- }
43
+ "main": "./index.cjs.js",
44
+ "types": "./index.esm.d.ts"
45
+ }
@@ -1,5 +1,8 @@
1
1
  import { type ReadModelKeyFunction } from '../model/model';
2
2
  import { type Maybe } from '../value/maybe.type';
3
+ /**
4
+ * A string type used as a key in boolean arrays.
5
+ */
3
6
  export type BooleanStringKey = string;
4
7
  /**
5
8
  * Boolean represented by an array to describe the current state and reason why.
@@ -11,13 +14,57 @@ export type BooleanStringKeyArray = BooleanKeyArray<BooleanStringKey>;
11
14
  * Having any values in the array is considered "true".
12
15
  */
13
16
  export type BooleanKeyArray<T = string> = Maybe<T[]>;
17
+ /**
18
+ * Wraps a key reading function to ensure that empty string keys are not used in boolean key arrays.
19
+ * @param readKey - The key reading function to wrap
20
+ * @returns A wrapped key reading function that throws an error if an empty string is used as a key
21
+ */
14
22
  export declare function readBooleanKeySafetyWrap<T>(readKey: ReadModelKeyFunction<T>): ReadModelKeyFunction<T>;
23
+ /**
24
+ * Checks if a boolean key array evaluates to false (empty or undefined).
25
+ * @param value - The boolean key array to check
26
+ * @returns True if the array is empty or undefined, false otherwise
27
+ */
15
28
  export declare function isFalseBooleanKeyArray(value: BooleanKeyArray): boolean;
29
+ /**
30
+ * Checks if a boolean key array evaluates to true (has at least one value).
31
+ * @param value - The boolean key array to check
32
+ * @returns True if the array has at least one value, false otherwise
33
+ */
16
34
  export declare function isTrueBooleanKeyArray(value: BooleanKeyArray): boolean;
35
+ /**
36
+ * Inserts a value into a boolean key array, removing any existing values with the same key.
37
+ * @param array - The boolean key array to insert into
38
+ * @param value - The value to insert
39
+ * @param readKey - Function to extract the key from a value
40
+ * @returns A new boolean key array with the value inserted
41
+ */
17
42
  export declare function insertIntoBooleanKeyArray<T>(array: BooleanKeyArray<T>, value: T, readKey: ReadModelKeyFunction<T>): BooleanKeyArray<T>;
43
+ /**
44
+ * Removes a value from a boolean key array based on its key.
45
+ * @param array - The boolean key array to remove from
46
+ * @param value - The value to remove
47
+ * @param readKey - Function to extract the key from a value
48
+ * @returns A new boolean key array with the value removed
49
+ */
18
50
  export declare function removeFromBooleanKeyArray<T>(array: BooleanKeyArray<T>, value: T, readKey: ReadModelKeyFunction<T>): BooleanKeyArray<T>;
51
+ /**
52
+ * Removes values from a boolean key array that match the specified key.
53
+ * @param array - The boolean key array to remove from
54
+ * @param key - The key to match for removal
55
+ * @param readKey - Function to extract the key from a value
56
+ * @returns A new boolean key array with matching values removed
57
+ */
19
58
  export declare function removeByKeyFromBooleanKeyArray<T>(array: BooleanKeyArray<T>, key: string, readKey: ReadModelKeyFunction<T>): BooleanKeyArray<T>;
59
+ /**
60
+ * Utility type for working with boolean key arrays.
61
+ */
20
62
  export type BooleanKeyArrayUtility<T> = ReturnType<typeof booleanKeyArrayUtility<T>>;
63
+ /**
64
+ * Creates a utility object with functions for working with boolean key arrays.
65
+ * @param readKey - Function to extract the key from a value
66
+ * @returns An object with utility functions for boolean key arrays
67
+ */
21
68
  export declare function booleanKeyArrayUtility<T>(readKey: ReadModelKeyFunction<T>): {
22
69
  isFalse: (value: BooleanKeyArray) => boolean;
23
70
  isTrue: (value: BooleanKeyArray) => boolean;
@@ -26,6 +73,9 @@ export declare function booleanKeyArrayUtility<T>(readKey: ReadModelKeyFunction<
26
73
  remove: (array: BooleanKeyArray<T>, value: T) => BooleanKeyArray<T>;
27
74
  removeByKey: (array: BooleanKeyArray<T>, key: string) => BooleanKeyArray<T>;
28
75
  };
76
+ /**
77
+ * Utility for working with boolean string key arrays.
78
+ */
29
79
  export declare const BooleanStringKeyArrayUtility: {
30
80
  isFalse: (value: BooleanKeyArray) => boolean;
31
81
  isTrue: (value: BooleanKeyArray) => boolean;
@@ -2,47 +2,50 @@ import { type Factory, type FactoryWithIndex, type FactoryWithRequiredInput } fr
2
2
  import { type AsyncMapFunction } from '../value/map';
3
3
  /**
4
4
  * Factory that generates multiple values given a number of items to make.
5
+ * Takes a count parameter and returns an array of generated items.
5
6
  */
6
7
  export type ArrayFactory<T> = FactoryWithRequiredInput<T[], number>;
7
8
  /**
8
- * Async ArrayFactory
9
+ * Async version of ArrayFactory that returns a promise resolving to an array of items.
9
10
  */
10
11
  export type AsyncArrayFactory<T> = AsyncMapFunction<ArrayFactory<T>>;
11
12
  /**
12
13
  * Factory that generates a value for each input value.
14
+ * Takes an array of input values and returns an array of output values.
13
15
  */
14
16
  export type ArrayInputFactory<I, O> = FactoryWithRequiredInput<O[], I[]>;
15
17
  /**
16
- * Async ArrayInputFactory
18
+ * Async version of ArrayInputFactory that returns a promise resolving to an array of output values.
17
19
  */
18
20
  export type AsyncArrayInputFactory<I, O> = AsyncMapFunction<ArrayInputFactory<I, O>>;
19
21
  /**
20
- * Creates a new ArrayFactory.
22
+ * Creates a new ArrayFactory that generates multiple values.
21
23
  *
22
- * @param factory
23
- * @returns
24
+ * @param factory - The factory function used to generate each item
25
+ * @returns A function that takes a count parameter and returns an array of generated items
24
26
  */
25
27
  export declare function arrayFactory<T>(factory: Factory<T> | FactoryWithIndex<T>): ArrayFactory<T>;
26
28
  /**
27
- * Creates a ArrayInputFactory.
29
+ * Creates an ArrayInputFactory that transforms input values into output values.
28
30
  *
29
- * @param factory
30
- * @returns
31
+ * @param factory - The factory function used to transform each input value
32
+ * @returns A function that takes an array of input values and returns an array of output values
31
33
  */
32
34
  export declare function arrayInputFactory<O, I>(factory: FactoryWithRequiredInput<O, I>): ArrayInputFactory<I, O>;
33
35
  /**
34
36
  * Creates a factory that returns the items from the input array and returns null after the factory function has exhausted all array values.
35
37
  *
36
- * The factory can only be used once.
38
+ * The factory can only be used once as it maintains internal state.
37
39
  *
38
- * @param array
40
+ * @param array - The source array to pull values from
41
+ * @returns A factory function that returns items from the array or null when exhausted
39
42
  */
40
43
  export declare function terminatingFactoryFromArray<T>(array: T[]): Factory<T | null>;
41
44
  /**
45
+ * Creates a factory that returns the items from the input array and returns the specified terminating value when the array is exhausted.
42
46
  *
43
- * Creates a factory that returns the items from the input array and returns the terminating value if the input array is empty.
44
- *
45
- * @param array
46
- * @param terminatingValue
47
+ * @param array - The source array to pull values from
48
+ * @param terminatingValue - The value to return when all array items have been consumed
49
+ * @returns A factory function that returns items from the array or the terminating value when exhausted
47
50
  */
48
51
  export declare function terminatingFactoryFromArray<T, E>(array: T[], terminatingValue: E): Factory<T | E>;
@@ -1,48 +1,64 @@
1
1
  import { type MapFunction } from '../value/map';
2
2
  import { type DecisionFunction } from '../value/decision';
3
+ import { type AscendingSortCompareFunction } from '../sort';
3
4
  /**
4
- * Filters the input values by distance. The original order is retained.
5
+ * Filters the input values by distance while maintaining the original order of elements.
6
+ * Values that are too close to each other (based on the minDistance parameter) will be filtered out.
5
7
  *
6
- * If order is irrelevant, use filterValuesByDistanceNoOrder().
8
+ * If order is irrelevant, use filterValuesByDistanceNoOrder() instead.
9
+ *
10
+ * @param input - The array of values to filter
11
+ * @param minDistance - The minimum distance required between values
12
+ * @param getValue - Function that extracts a numeric value from each item for distance comparison
13
+ * @returns A filtered array with only values that are at least minDistance apart
7
14
  */
8
15
  export declare function filterValuesByDistance<T>(input: T[], minDistance: number, getValue: (value: T) => number | null): T[];
9
16
  /**
10
- * Filters the input values by an arbitrary "distance"/difference from eachother and returns the values sorted by their determined distance.
17
+ * Filters the input values by an arbitrary "distance"/difference from each other and returns the values sorted by their determined distance.
11
18
  *
12
- * This is useful in cases where many values are too "close" to eachother (Generally items that share the same time, or within seconds of eachother), and
19
+ * This is useful in cases where many values are too "close" to each other (generally items that share the same time, or within seconds of each other), and
13
20
  * we are only interested in seeing one of those items.
21
+ *
22
+ * @param input - The array of values to filter
23
+ * @param minDistance - The minimum distance required between values (inclusive)
24
+ * @param getValue - Function that extracts a numeric value from each item for distance comparison
25
+ * @returns A filtered array with only values that are at least minDistance apart, sorted by the extracted value
14
26
  */
15
27
  export declare function filterValuesByDistanceNoOrder<T>(input: T[], minDistance: number, getValue: (value: T) => number | null): T[];
16
28
  /**
17
29
  * Same as applyBestFit, but returns a new array, rather than modifying the existing array.
18
30
  *
19
- * @param input
20
- * @param filter
21
- * @param updateNonBestFit
31
+ * @param input - The array to filter for the best fit
32
+ * @param filter - Function that determines which items are candidates for the best fit
33
+ * @param compare - AscendingSortCompareFunction to compare two values to determine which is the best fit
34
+ * @param updateNonBestFit - Function that transforms non-best-fit items
35
+ * @returns A new array with only the best fit item and transformed non-best-fit items
22
36
  */
23
- export declare function makeBestFit<T>(input: T[], filter: (value: T) => boolean, compare: (a: T, b: T) => number, updateNonBestFit: (value: T) => T): T[];
37
+ export declare function makeBestFit<T>(input: T[], filter: (value: T) => boolean, compare: AscendingSortCompareFunction<T>, updateNonBestFit: (value: T) => T): T[];
24
38
  /**
25
39
  * Used for updating an array so that a single element becomes the "best fit" in whatever context is provided.
26
40
  *
27
41
  * For instance, if two items are selected but only one can be selected by design, this function can be used to
28
42
  * pick the best fit, and update the input array.
29
43
  *
30
- * @param input
31
- * @param filter
32
- * @param updateNonBestFit
33
- * @returns
44
+ * @param input - The array to modify in-place
45
+ * @param filter - Function that determines which items are candidates for the best fit
46
+ * @param compare - AscendingSortCompareFunction to compare two values to determine which is the best fit
47
+ * @param updateNonBestFit - Function that transforms non-best-fit items
48
+ * @returns The modified input array with only the best fit item and transformed non-best-fit items
34
49
  */
35
- export declare function applyBestFit<T>(input: T[], filter: (value: T) => boolean, compare: (a: T, b: T) => number, updateNonBestFit: (value: T) => T): T[];
50
+ export declare function applyBestFit<T>(input: T[], filter: (value: T) => boolean, compare: AscendingSortCompareFunction<T>, updateNonBestFit: (value: T) => T): T[];
36
51
  /**
37
52
  * Filters and maps the input values to an array.
53
+ * Combines filtering and mapping operations into a single pass over the data.
38
54
  */
39
55
  export type FilterAndMapFunction<I, O> = MapFunction<Iterable<I>, O[]>;
40
56
  /**
41
- * Filters the input values and maps all correct values to a new value.
57
+ * Creates a function that filters the input values and maps all matching values to a new value.
58
+ * This is a higher-order function that combines filtering and mapping operations.
42
59
  *
43
- * @param values
44
- * @param decisionFunction
45
- * @param mapFunction
46
- * @returns
60
+ * @param decisionFunction - Function that determines which items to include in the result
61
+ * @param mapFunction - Function that transforms each included item
62
+ * @returns A function that takes an iterable of input values and returns an array of transformed values
47
63
  */
48
64
  export declare function filterAndMapFunction<I, O>(decisionFunction: DecisionFunction<I>, mapFunction: MapFunction<I, O>): FilterAndMapFunction<I, O>;
@@ -1,21 +1,33 @@
1
1
  import { type SetIncludesMode } from '../set/set.mode';
2
2
  /**
3
3
  * A decision function used by the array find function.
4
+ * Similar to the predicate function in Array.prototype.find() or Array.prototype.filter().
5
+ * @template T - The type of elements in the array
4
6
  */
5
7
  export type ArrayFindDecisionFunction<T> = (value: T, index: number, obj: T[]) => boolean;
6
8
  /**
7
- * Returns a decision about an array based on it's input values using a preconfigured DecisionFunction and SetInclduesMode.
9
+ * Returns a decision about an array based on its input values using a preconfigured DecisionFunction and SetIncludesMode.
10
+ *
11
+ * @template T - The type of elements in the array
8
12
  */
9
13
  export type ArrayDecisionFunction<T> = (values: T[]) => boolean;
10
14
  /**
11
- * Creates a ArrayDecisionFunction based on the input decision and mode.
15
+ * Creates an ArrayDecisionFunction based on the input decision and mode.
12
16
  *
13
- * @param decision
14
- * @param mode
15
- * @returns
17
+ * @template T - The type of elements in the array
18
+ * @param decision - The function used to test individual elements of the array
19
+ * @param mode - The mode determining how the decision is applied ('any' or 'all')
20
+ * @returns A function that takes an array and returns a boolean decision based on the array elements
16
21
  */
17
22
  export declare function arrayDecisionFunction<T>(decision: ArrayFindDecisionFunction<T>, mode: SetIncludesMode): ArrayDecisionFunction<T>;
18
23
  /**
19
24
  * Returns true based on the input values and find decision.
25
+ * A convenience function that creates and immediately applies an array decision function.
26
+ *
27
+ * @template T - The type of elements in the array
28
+ * @param values - The array to evaluate
29
+ * @param decision - The function used to test individual elements of the array
30
+ * @param mode - The mode determining how the decision is applied ('any' or 'all')
31
+ * @returns A boolean indicating whether the array meets the decision criteria
20
32
  */
21
33
  export declare function arrayDecision<T>(values: T[], decision: ArrayFindDecisionFunction<T>, mode: SetIncludesMode): boolean;
@@ -1,3 +1,4 @@
1
+ import { type AscendingSortCompareFunction } from '../sort';
1
2
  import { type IndexNumber, type IndexRef, type IndexRangeInput } from '../value/indexed';
2
3
  import { type Maybe } from '../value/maybe.type';
3
4
  /**
@@ -33,7 +34,7 @@ export declare function findBest<T>(input: T[], compare: (a: T, b: T) => number)
33
34
  * @param compare
34
35
  * @returns
35
36
  */
36
- export declare function findBestIndexSetPair<T>(input: IndexSetPairSet<T>, compare: (a: T, b: T) => number): IndexSetPair<T>;
37
+ export declare function findBestIndexSetPair<T>(input: IndexSetPairSet<T>, compare: AscendingSortCompareFunction<T>): IndexSetPair<T>;
37
38
  /**
38
39
  * Slices a configured index range from the input array.
39
40
  */
@@ -3,11 +3,12 @@ export interface LimitArrayConfig {
3
3
  /**
4
4
  * Number of items in the list to limit in the result.
5
5
  */
6
- limit: number;
6
+ readonly limit: number;
7
7
  /**
8
8
  * If true the limit will be pulled from the end instead of the front of the array.
9
9
  */
10
- limitFromEnd?: boolean;
10
+ readonly limitFromEnd?: boolean;
11
11
  }
12
12
  export declare function limitArray<T>(array: T[], { limit, limitFromEnd }: Partial<LimitArrayConfig>): T[];
13
13
  export declare function limitArray<T>(array: Maybe<T[]>, { limit, limitFromEnd }: Partial<LimitArrayConfig>): Maybe<T[]>;
14
+ export declare function limitArray<T>(array: Maybe<T[]>, config: Maybe<Partial<LimitArrayConfig>>): Maybe<T[]>;
@@ -1,15 +1,23 @@
1
1
  /**
2
- * Interface for configuring a Description Assertion
2
+ * Interface for configuring a Description Assertion.
3
+ * Provides options for customizing assertion messages.
4
+ * @interface
3
5
  */
4
6
  export interface DescriptorAssertionOptions {
5
7
  message?: string;
6
8
  }
7
9
  /**
8
10
  * DescriptorAssertionOptions extension that also maps one value to another.
11
+ * Extends the base assertion options to include a mapping function.
12
+ * @interface
13
+ * @template T - The type of value being mapped
9
14
  */
10
15
  export interface MapDescriptorAssertionOptions<T> extends DescriptorAssertionOptions {
11
16
  /**
12
17
  * Maps the value after it has been validated.
18
+ * This function is applied to transform the value after the assertion passes.
19
+ * @param value - The value to transform after validation
20
+ * @returns The transformed value
13
21
  */
14
22
  map?: (value: T) => T;
15
23
  }
@@ -1,32 +1,75 @@
1
1
  import { type ReadableError } from '../error';
2
2
  import { BaseError } from 'make-error';
3
3
  import { type DescriptorAssertionOptions } from './assert';
4
+ /**
5
+ * Interface representing an assertion issue that occurred.
6
+ * Contains information about the object and property that failed the assertion.
7
+ * @interface
8
+ */
4
9
  export interface AssertionIssue {
5
10
  /**
6
- * Object that encoundered the issue.
11
+ * Object that encountered the issue.
7
12
  */
8
- target: object;
13
+ readonly target: object;
9
14
  /**
10
- * Property that
15
+ * Property key that failed the assertion.
11
16
  */
12
- propertyKey: string;
13
- options?: DescriptorAssertionOptions;
17
+ readonly propertyKey: string;
18
+ readonly options?: DescriptorAssertionOptions;
14
19
  }
20
+ /**
21
+ * Error code for assertion errors.
22
+ */
15
23
  export declare const ASSERTION_ERROR_CODE = "DBX_ASSERTION_ERROR";
24
+ /**
25
+ * Error thrown when an assertion fails.
26
+ * Extends BaseError and implements ReadableError interface.
27
+ */
16
28
  export declare class AssertionError extends BaseError implements ReadableError {
17
29
  readonly code = "DBX_ASSERTION_ERROR";
18
- private _target;
19
- private _property;
30
+ private readonly _target;
31
+ private readonly _property;
20
32
  constructor(error: {
21
33
  target: object;
22
34
  propertyKey: string;
23
35
  }, message: string);
36
+ /**
37
+ * Gets the target object that failed the assertion.
38
+ * @returns The target object
39
+ */
24
40
  get target(): object;
41
+ /**
42
+ * Gets the property key that failed the assertion.
43
+ * @returns The property key as a string
44
+ */
25
45
  get propertyKey(): string;
26
46
  }
47
+ /**
48
+ * Handler for assertion issues that builds and throws appropriate errors.
49
+ */
27
50
  export declare class AssertionIssueHandler {
51
+ /**
52
+ * Handles an assertion issue by throwing an appropriate exception.
53
+ * @param error - The assertion issue to handle
54
+ * @throws AssertionError
55
+ */
28
56
  handle(error: AssertionIssue): void;
57
+ /**
58
+ * Builds an AssertionError from an AssertionIssue.
59
+ * @param error - The assertion issue to build an exception from
60
+ * @returns A new AssertionError instance
61
+ */
29
62
  buildException(error: AssertionIssue): AssertionError;
63
+ /**
64
+ * Builds an error message string from an AssertionIssue.
65
+ * Uses the custom message if provided, otherwise creates a default message.
66
+ * @param error - The assertion issue to build a message for
67
+ * @returns The error message string
68
+ */
30
69
  protected buildExceptionString(error: AssertionIssue): string;
31
70
  }
71
+ /**
72
+ * Default instance of AssertionIssueHandler used for handling assertion issues.
73
+ * TODO: Allow changing, if needed.
74
+ */
32
75
  export declare const ASSERTION_HANDLER: AssertionIssueHandler;
@@ -27,4 +27,11 @@ export declare const AUTH_ADMIN_ROLE = "admin";
27
27
  * Auth role for a general user. Is allowed into the app and is logged in.
28
28
  */
29
29
  export declare const AUTH_USER_ROLE = "user";
30
+ /**
31
+ * Checks if an AuthRoleSet contains all of the specified roles.
32
+ *
33
+ * @param authRolesSet - The set of auth roles to check against
34
+ * @param roles - An iterable of roles to check for, or null/undefined
35
+ * @returns True if the authRolesSet contains all the specified roles, or if roles is empty/null
36
+ */
30
37
  export declare function authRolesSetHasRoles(authRolesSet: AuthRoleSet, roles: Maybe<Iterable<AuthRole>>): boolean;
@@ -1,8 +1,53 @@
1
1
  import { type Factory } from './getter/getter';
2
+ /**
3
+ * Type representing whether something is valid.
4
+ */
5
+ export type IsValid = boolean;
6
+ /**
7
+ * Type representing whether something is equal to something else.
8
+ */
9
+ export type IsEqual = boolean;
10
+ /**
11
+ * Type representing whether something has been modified.
12
+ */
13
+ export type IsModified = boolean;
14
+ /**
15
+ * Reduces an array of booleans with the logical AND operation.
16
+ *
17
+ * @param array - Array of boolean values to reduce
18
+ * @param emptyArrayValue - Value to return if the array is empty (default: undefined which becomes false)
19
+ * @returns The result of ANDing all boolean values in the array
20
+ */
2
21
  export declare function reduceBooleansWithAnd(array: boolean[], emptyArrayValue?: boolean): boolean;
22
+ /**
23
+ * Reduces an array of booleans with the logical OR operation.
24
+ *
25
+ * @param array - Array of boolean values to reduce
26
+ * @param emptyArrayValue - Value to return if the array is empty (default: undefined which becomes false)
27
+ * @returns The result of ORing all boolean values in the array
28
+ */
3
29
  export declare function reduceBooleansWithOr(array: boolean[], emptyArrayValue?: boolean): boolean;
30
+ /**
31
+ * Creates a function that reduces an array of booleans with the logical AND operation.
32
+ *
33
+ * @param emptyArrayValue - Value to return if the array is empty (default: undefined which becomes false)
34
+ * @returns A function that takes an array of booleans and returns the result of ANDing them
35
+ */
4
36
  export declare function reduceBooleansWithAndFn(emptyArrayValue?: boolean): (array: boolean[]) => boolean;
37
+ /**
38
+ * Creates a function that reduces an array of booleans with the logical OR operation.
39
+ *
40
+ * @param emptyArrayValue - Value to return if the array is empty (default: undefined which becomes false)
41
+ * @returns A function that takes an array of booleans and returns the result of ORing them
42
+ */
5
43
  export declare function reduceBooleansWithOrFn(emptyArrayValue?: boolean): (array: boolean[]) => boolean;
44
+ /**
45
+ * Creates a function that reduces an array of booleans using a custom reduce function.
46
+ *
47
+ * @param reduceFn - Function that takes two boolean values and returns a single boolean
48
+ * @param emptyArrayValue - Value to return if the array is empty (default: undefined which uses the standard reduce behavior)
49
+ * @returns A function that takes an array of booleans and returns the result of reducing them
50
+ */
6
51
  export declare function reduceBooleansFn(reduceFn: (a: boolean, b: boolean) => boolean, emptyArrayValue?: boolean): (array: boolean[]) => boolean;
7
52
  /**
8
53
  * Factory that generates boolean values.
@@ -19,16 +64,16 @@ export interface BooleanFactoryConfig {
19
64
  chance: BooleanChance;
20
65
  }
21
66
  /**
22
- * Creates a new BooleanFactory.
67
+ * Creates a new BooleanFactory that generates random boolean values based on chance.
23
68
  *
24
- * @param config
25
- * @returns
69
+ * @param config - Configuration for the boolean factory, including the chance of returning true
70
+ * @returns A factory function that generates random boolean values
26
71
  */
27
72
  export declare function booleanFactory(config: BooleanFactoryConfig): () => boolean;
28
73
  /**
29
- * Returns a random boolean.
74
+ * Returns a random boolean based on the specified chance.
30
75
  *
31
- * @param chance Number between 0 and 100
32
- * @returns
76
+ * @param chance - Number between 0 and 100 representing the percentage chance of returning true (default: 50)
77
+ * @returns A random boolean value with the specified probability of being true
33
78
  */
34
79
  export declare function randomBoolean(chance?: BooleanChance): boolean;
@@ -1,15 +1,48 @@
1
+ /**
2
+ * Type representing an email address as a string.
3
+ */
1
4
  export type EmailAddress = string;
5
+ /**
6
+ * Interface representing a pair of a name and an email address.
7
+ */
2
8
  export interface NameEmailPair {
3
9
  name?: string;
4
10
  email: EmailAddress;
5
11
  }
12
+ /**
13
+ * Type representing an email participant with a name and email address.
14
+ * Alias for NameEmailPair for semantic clarity in email-related contexts.
15
+ */
6
16
  export type EmailParticipant = NameEmailPair;
7
17
  /**
8
18
  * Email participant string. Starts with the email, followed by the name if available.
9
19
  */
10
20
  export type EmailParticipantString = string;
21
+ /**
22
+ * Converts an EmailParticipant object to a formatted string representation.
23
+ * The format is: "name<email>" or "<email>" if no name is provided.
24
+ *
25
+ * @param participant - The email participant to convert
26
+ * @returns A formatted string representation of the participant
27
+ */
11
28
  export declare function convertParticipantToEmailParticipantString(participant: EmailParticipant): EmailParticipantString;
29
+ /**
30
+ * Converts a formatted participant string into an EmailParticipant object.
31
+ * Parses strings in the format "name<email>" or "<email>".
32
+ *
33
+ * @param participantString - The string to parse
34
+ * @returns An EmailParticipant object with the extracted name and email
35
+ */
12
36
  export declare function convertEmailParticipantStringToParticipant(participantString: EmailParticipantString): EmailParticipant;
37
+ /**
38
+ * Combines an array of EmailParticipants with an array of email addresses.
39
+ * Email addresses that don't already exist in the participants array are converted to EmailParticipant objects.
40
+ *
41
+ * @param options - Object containing participants and/or emails arrays
42
+ * @param options.participants - Array of existing EmailParticipant objects
43
+ * @param options.emails - Array of email addresses to include
44
+ * @returns A combined array of EmailParticipant objects
45
+ */
13
46
  export declare function coerceToEmailParticipants({ participants, emails }: {
14
47
  participants?: EmailParticipant[];
15
48
  emails?: EmailAddress[];