@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.
- package/fetch/package.json +2 -2
- package/index.cjs.js +4107 -1516
- package/index.esm.js +4107 -1516
- package/package.json +1 -2
- package/src/lib/array/array.d.ts +92 -47
- package/src/lib/array/array.find.d.ts +14 -18
- package/src/lib/array/array.index.d.ts +43 -14
- package/src/lib/array/array.indexed.d.ts +66 -17
- package/src/lib/array/array.limit.d.ts +11 -0
- package/src/lib/array/array.make.d.ts +9 -3
- package/src/lib/array/array.map.d.ts +20 -8
- package/src/lib/array/array.number.d.ts +63 -5
- package/src/lib/array/array.random.d.ts +12 -9
- package/src/lib/array/array.set.d.ts +24 -1
- package/src/lib/array/array.string.d.ts +104 -0
- package/src/lib/array/array.unique.d.ts +60 -8
- package/src/lib/array/array.value.d.ts +20 -11
- package/src/lib/assertion/assertion.d.ts +30 -2
- package/src/lib/assertion/assertion.generic.d.ts +8 -0
- package/src/lib/assertion/assertion.number.d.ts +16 -0
- package/src/lib/auth/auth.role.claims.d.ts +14 -8
- package/src/lib/boolean.d.ts +54 -1
- package/src/lib/contact/domain.d.ts +22 -4
- package/src/lib/contact/random.d.ts +24 -0
- package/src/lib/date/date.d.ts +8 -13
- package/src/lib/date/hour.d.ts +51 -32
- package/src/lib/date/minute.d.ts +4 -4
- package/src/lib/date/time.d.ts +12 -3
- package/src/lib/date/week.d.ts +77 -10
- package/src/lib/error/error.d.ts +54 -3
- package/src/lib/error/error.server.d.ts +25 -2
- package/src/lib/filter/filter.d.ts +12 -7
- package/src/lib/function/function.boolean.d.ts +4 -4
- package/src/lib/function/function.d.ts +2 -5
- package/src/lib/function/function.forward.d.ts +19 -3
- package/src/lib/getter/getter.cache.d.ts +9 -5
- package/src/lib/getter/getter.d.ts +39 -22
- package/src/lib/getter/getter.map.d.ts +10 -4
- package/src/lib/getter/getter.util.d.ts +3 -3
- package/src/lib/grouping.d.ts +98 -31
- package/src/lib/hash.d.ts +15 -8
- package/src/lib/iterable/iterable.d.ts +62 -50
- package/src/lib/iterable/iterable.map.d.ts +4 -4
- package/src/lib/iterate.d.ts +17 -1
- package/src/lib/key.d.ts +32 -10
- package/src/lib/lifecycle.d.ts +10 -1
- package/src/lib/map/map.d.ts +17 -16
- package/src/lib/map/map.intersection.d.ts +5 -4
- package/src/lib/map/map.key.d.ts +16 -15
- package/src/lib/misc/host.d.ts +6 -3
- package/src/lib/model/id.batch.d.ts +7 -3
- package/src/lib/model/id.factory.d.ts +16 -1
- package/src/lib/model/model.conversion.d.ts +49 -6
- package/src/lib/model/model.conversion.field.d.ts +13 -3
- package/src/lib/model/model.copy.d.ts +11 -0
- package/src/lib/model/model.d.ts +174 -1
- package/src/lib/model/model.modify.d.ts +24 -5
- package/src/lib/nodejs/stream.d.ts +8 -6
- package/src/lib/number/bitwise.dencoder.d.ts +43 -3
- package/src/lib/number/bound.d.ts +34 -5
- package/src/lib/number/dollar.d.ts +13 -6
- package/src/lib/number/factory.d.ts +11 -3
- package/src/lib/number/number.d.ts +55 -32
- package/src/lib/number/random.d.ts +13 -3
- package/src/lib/number/round.d.ts +47 -26
- package/src/lib/number/sort.d.ts +7 -1
- package/src/lib/number/transform.d.ts +16 -0
- package/src/lib/object/object.array.d.ts +16 -2
- package/src/lib/object/object.array.delta.d.ts +6 -2
- package/src/lib/object/object.d.ts +33 -5
- package/src/lib/object/object.empty.d.ts +4 -2
- package/src/lib/object/object.equal.d.ts +21 -4
- package/src/lib/object/object.filter.tuple.d.ts +105 -3
- package/src/lib/object/object.key.d.ts +13 -6
- package/src/lib/object/object.map.d.ts +30 -19
- package/src/lib/page/page.d.ts +21 -0
- package/src/lib/page/page.filter.d.ts +16 -9
- package/src/lib/path/path.d.ts +101 -14
- package/src/lib/path/path.tree.d.ts +16 -0
- package/src/lib/promise/callback.d.ts +18 -0
- package/src/lib/promise/is.d.ts +10 -3
- package/src/lib/promise/map.d.ts +5 -3
- package/src/lib/promise/poll.d.ts +14 -4
- package/src/lib/promise/promise.d.ts +84 -18
- package/src/lib/promise/promise.factory.d.ts +18 -2
- package/src/lib/promise/promise.limit.d.ts +22 -2
- package/src/lib/promise/promise.loop.d.ts +69 -1
- package/src/lib/promise/promise.ref.d.ts +14 -2
- package/src/lib/promise/promise.task.d.ts +8 -4
- package/src/lib/promise/promise.type.d.ts +4 -4
- package/src/lib/promise/use.d.ts +6 -4
- package/src/lib/promise/wait.d.ts +5 -2
- package/src/lib/relation/relation.d.ts +98 -0
- package/src/lib/service/handler.config.d.ts +47 -9
- package/src/lib/service/handler.d.ts +43 -1
- package/src/lib/service/typed.service.d.ts +21 -2
- package/src/lib/set/set.allowed.d.ts +6 -4
- package/src/lib/set/set.d.ts +174 -46
- package/src/lib/set/set.decision.d.ts +4 -2
- package/src/lib/set/set.delta.d.ts +16 -3
- package/src/lib/set/set.hashset.d.ts +43 -0
- package/src/lib/set/set.selection.d.ts +7 -3
- package/src/lib/sort.d.ts +36 -16
- package/src/lib/string/char.d.ts +48 -34
- package/src/lib/string/dencoder.d.ts +84 -13
- package/src/lib/string/factory.d.ts +13 -4
- package/src/lib/string/html.d.ts +7 -6
- package/src/lib/string/mimetype.d.ts +65 -1
- package/src/lib/string/prefix.d.ts +21 -7
- package/src/lib/string/record.d.ts +7 -4
- package/src/lib/string/replace.d.ts +77 -33
- package/src/lib/string/search.d.ts +19 -9
- package/src/lib/string/sort.d.ts +10 -1
- package/src/lib/string/string.d.ts +74 -21
- package/src/lib/string/transform.d.ts +7 -0
- package/src/lib/string/tree.d.ts +91 -29
- package/src/lib/string/url.d.ts +148 -63
- package/src/lib/tree/tree.explore.d.ts +84 -17
- package/src/lib/tree/tree.flatten.d.ts +44 -7
- package/src/lib/type.d.ts +15 -12
- package/src/lib/value/address.d.ts +66 -17
- package/src/lib/value/bound.d.ts +253 -17
- package/src/lib/value/build.d.ts +30 -5
- package/src/lib/value/comparator.d.ts +53 -25
- package/src/lib/value/cron.d.ts +14 -6
- package/src/lib/value/decision.d.ts +57 -13
- package/src/lib/value/equal.d.ts +44 -13
- package/src/lib/value/indexed.d.ts +253 -82
- package/src/lib/value/label.d.ts +16 -5
- package/src/lib/value/map.d.ts +77 -20
- package/src/lib/value/maybe.d.ts +47 -49
- package/src/lib/value/modifier.d.ts +82 -27
- package/src/lib/value/point.d.ts +248 -54
- package/src/lib/value/url.d.ts +10 -3
- package/src/lib/value/use.d.ts +99 -8
- package/src/lib/value/vector.d.ts +71 -9
- package/test/index.cjs.js +86 -23
- package/test/index.esm.js +86 -23
- package/test/package.json +2 -2
- package/test/src/lib/shared/shared.d.ts +31 -5
- package/test/src/lib/shared/shared.fail.d.ts +72 -9
- package/test/src/lib/shared/shared.function.d.ts +40 -2
- package/test/src/lib/shared/shared.wrap.d.ts +20 -1
|
@@ -25,10 +25,20 @@ export interface RandomNumberFactoryConfig {
|
|
|
25
25
|
}
|
|
26
26
|
export type RandomNumberFactoryInput = number | RandomNumberFactoryConfig;
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
28
|
+
* Creates a factory that generates random numbers within a configured range.
|
|
29
29
|
*
|
|
30
|
-
*
|
|
31
|
-
*
|
|
30
|
+
* Accepts either a simple max number or a full config object with min, max, and rounding options.
|
|
31
|
+
*
|
|
32
|
+
* @param maxOrArgs - Maximum value (exclusive) or full configuration object
|
|
33
|
+
* @param roundingInput - Optional rounding mode override
|
|
34
|
+
* @returns A factory function that produces random numbers within the range
|
|
32
35
|
*/
|
|
33
36
|
export declare function randomNumberFactory(maxOrArgs: RandomNumberFactoryInput, roundingInput?: RoundingInput): RandomNumberFactory;
|
|
37
|
+
/**
|
|
38
|
+
* Generates a single random number using {@link randomNumberFactory}. Convenience function for one-off usage.
|
|
39
|
+
*
|
|
40
|
+
* @param maxOrArgs - Maximum value (exclusive) or full configuration object
|
|
41
|
+
* @param roundingInput - Optional rounding mode
|
|
42
|
+
* @returns A single random number
|
|
43
|
+
*/
|
|
34
44
|
export declare function randomNumber(maxOrArgs: RandomNumberFactoryInput, roundingInput?: RoundingInput): number;
|
|
@@ -4,6 +4,12 @@ import { type AsNumberInput } from './number';
|
|
|
4
4
|
export type FloorOrCeilRounding = 'floor' | 'ceil';
|
|
5
5
|
export type NumberRounding = 'none' | FloorOrCeilRounding | 'round';
|
|
6
6
|
export type RoundingFunction = MapFunction<number, number>;
|
|
7
|
+
/**
|
|
8
|
+
* Returns a rounding function for the specified rounding type.
|
|
9
|
+
*
|
|
10
|
+
* @param type - The rounding strategy: 'floor', 'ceil', 'round', or 'none'
|
|
11
|
+
* @returns The corresponding Math function, or an identity function for 'none'
|
|
12
|
+
*/
|
|
7
13
|
export declare function roundingFunction(type: NumberRounding): RoundingFunction;
|
|
8
14
|
export type RoundingInput = NumberRounding | RoundingFunction;
|
|
9
15
|
/**
|
|
@@ -11,11 +17,13 @@ export type RoundingInput = NumberRounding | RoundingFunction;
|
|
|
11
17
|
*/
|
|
12
18
|
export type NumberPrecision = number;
|
|
13
19
|
/**
|
|
14
|
-
*
|
|
20
|
+
* Truncates a number (or number string) to the specified decimal precision without rounding.
|
|
15
21
|
*
|
|
16
|
-
* @
|
|
17
|
-
*
|
|
18
|
-
* @
|
|
22
|
+
* Accepts strings and null/undefined via {@link asNumber}.
|
|
23
|
+
*
|
|
24
|
+
* @param input - Number, number string, or null/undefined
|
|
25
|
+
* @param precision - Number of decimal places to retain
|
|
26
|
+
* @returns The truncated number value
|
|
19
27
|
*/
|
|
20
28
|
export declare function cutValueToPrecision(input: AsNumberInput, precision: NumberPrecision): number;
|
|
21
29
|
/**
|
|
@@ -23,8 +31,10 @@ export declare function cutValueToPrecision(input: AsNumberInput, precision: Num
|
|
|
23
31
|
*/
|
|
24
32
|
export declare const CUT_VALUE_TO_ZERO_PRECISION: CutValueToPrecisionFunction;
|
|
25
33
|
/**
|
|
34
|
+
* Truncates a value to an integer by cutting to zero decimal precision.
|
|
26
35
|
*
|
|
27
|
-
* @
|
|
36
|
+
* @param input - Number, number string, or null/undefined
|
|
37
|
+
* @returns The truncated integer value
|
|
28
38
|
*/
|
|
29
39
|
export declare function cutValueToInteger(input: AsNumberInput): number;
|
|
30
40
|
/**
|
|
@@ -34,10 +44,11 @@ export type CutValueToPrecisionFunction = ((input: AsNumberInput) => number) & {
|
|
|
34
44
|
readonly _precision: number;
|
|
35
45
|
};
|
|
36
46
|
/**
|
|
37
|
-
* Creates a CutValueToPrecisionFunction
|
|
47
|
+
* Creates a {@link CutValueToPrecisionFunction} that truncates values to the configured precision.
|
|
38
48
|
*
|
|
39
|
-
* @param precision
|
|
40
|
-
* @
|
|
49
|
+
* @param precision - Number of decimal places to retain
|
|
50
|
+
* @param roundingType - Rounding strategy; defaults to 'cut' (truncation)
|
|
51
|
+
* @returns A function that accepts a number or string and returns the truncated number
|
|
41
52
|
*/
|
|
42
53
|
export declare function cutValueToPrecisionFunction(precision: NumberPrecision, roundingType?: RoundToPrecisionFunctionType): CutValueToPrecisionFunction;
|
|
43
54
|
/**
|
|
@@ -50,27 +61,30 @@ export declare function cutValueToPrecisionFunction(precision: NumberPrecision,
|
|
|
50
61
|
export type RoundToPrecisionFunction = MapFunction<number, number>;
|
|
51
62
|
export type RoundToPrecisionFunctionType = NumberRounding | 'cut';
|
|
52
63
|
/**
|
|
53
|
-
* Creates a
|
|
64
|
+
* Creates a function that rounds numbers to the specified precision using a configurable rounding strategy.
|
|
54
65
|
*
|
|
55
|
-
* @param precision
|
|
56
|
-
* @param roundFn
|
|
57
|
-
* @returns
|
|
66
|
+
* @param precision - Number of decimal places
|
|
67
|
+
* @param roundFn - Rounding strategy; defaults to 'round'. Use 'cut' for truncation.
|
|
68
|
+
* @returns A function that rounds numbers to the configured precision
|
|
58
69
|
*/
|
|
59
70
|
export declare function roundToPrecisionFunction(precision: NumberPrecision, roundFn?: RoundToPrecisionFunctionType): RoundToPrecisionFunction;
|
|
60
71
|
/**
|
|
61
|
-
* Rounds
|
|
72
|
+
* Rounds a number to the specified decimal precision using `Math.round`.
|
|
62
73
|
*
|
|
63
|
-
* @param value
|
|
64
|
-
* @param precision
|
|
65
|
-
* @returns
|
|
74
|
+
* @param value - Number to round
|
|
75
|
+
* @param precision - Number of decimal places to retain
|
|
76
|
+
* @returns The rounded number
|
|
66
77
|
*/
|
|
67
78
|
export declare function roundToPrecision(value: number, precision: NumberPrecision): number;
|
|
68
79
|
/**
|
|
69
|
-
*
|
|
80
|
+
* Truncates a number to the specified decimal precision without rounding.
|
|
70
81
|
*
|
|
71
|
-
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
82
|
+
* Uses `Math.floor` for positive numbers and `Math.ceil` for negative numbers to truncate toward zero.
|
|
83
|
+
* For example, 1.25 with precision 1 becomes 1.2 (not 1.3).
|
|
84
|
+
*
|
|
85
|
+
* @param value - Number to truncate
|
|
86
|
+
* @param precision - Number of decimal places to retain
|
|
87
|
+
* @returns The truncated number
|
|
74
88
|
*/
|
|
75
89
|
export declare function cutToPrecision(value: number, precision: NumberPrecision): number;
|
|
76
90
|
/**
|
|
@@ -82,13 +96,11 @@ export type StepNumber = number;
|
|
|
82
96
|
*/
|
|
83
97
|
export type StepOrigin = number;
|
|
84
98
|
/**
|
|
85
|
-
* Rounds
|
|
86
|
-
*
|
|
87
|
-
* For example, with the value of 2, and a step size of 5, the value will be rounded up to 1.
|
|
99
|
+
* Rounds a number up to the nearest multiple of the step size using `Math.ceil`.
|
|
88
100
|
*
|
|
89
|
-
* @param value Input value
|
|
90
|
-
* @param step Step size
|
|
91
|
-
* @returns
|
|
101
|
+
* @param value - Input value
|
|
102
|
+
* @param step - Step size to round up to
|
|
103
|
+
* @returns The nearest multiple of step that is >= value
|
|
92
104
|
*/
|
|
93
105
|
export declare function roundNumberUpToStep(value: number, step: number): number;
|
|
94
106
|
/**
|
|
@@ -117,4 +129,13 @@ export type RoundNumberToStepFunctionInput = RoundNumberToStepFunctionConfig | S
|
|
|
117
129
|
export type RoundNumberToStepFunction = ((input: Maybe<number>) => number) & {
|
|
118
130
|
readonly _round: RoundNumberToStepFunctionConfig;
|
|
119
131
|
};
|
|
132
|
+
/**
|
|
133
|
+
* Creates a function that rounds numbers to the nearest step multiple using a configurable rounding strategy.
|
|
134
|
+
*
|
|
135
|
+
* Accepts either a step number (uses 'ceil' rounding) or a full config with step, rounding type, and origin.
|
|
136
|
+
*
|
|
137
|
+
* @param input - Step size or full configuration
|
|
138
|
+
* @returns A function that rounds input numbers to the nearest step
|
|
139
|
+
* @throws Error if step is 0 or undefined
|
|
140
|
+
*/
|
|
120
141
|
export declare function roundNumberToStepFunction(input: RoundNumberToStepFunctionInput): RoundNumberToStepFunction;
|
package/src/lib/number/sort.d.ts
CHANGED
|
@@ -5,7 +5,13 @@ import { type ReadNumberFunction } from './number';
|
|
|
5
5
|
*/
|
|
6
6
|
export type SortByNumberFunction<T> = SortCompareFunction<T>;
|
|
7
7
|
/**
|
|
8
|
-
* Creates a
|
|
8
|
+
* Creates a {@link SortCompareFunction} that sorts values in ascending order by a numeric property.
|
|
9
|
+
*
|
|
10
|
+
* @param readNumberFn - Function that extracts the numeric value from each item
|
|
11
|
+
* @returns A sort comparator function for ascending numeric order
|
|
9
12
|
*/
|
|
10
13
|
export declare function sortByNumberFunction<T>(readNumberFn: ReadNumberFunction<T>): SortByNumberFunction<T>;
|
|
14
|
+
/**
|
|
15
|
+
* Pre-built sort comparator for sorting plain numbers in ascending order.
|
|
16
|
+
*/
|
|
11
17
|
export declare const sortNumbersAscendingFunction: SortByNumberFunction<number>;
|
|
@@ -25,5 +25,21 @@ export interface TransformNumberFunctionConfigRef<N extends number = number> {
|
|
|
25
25
|
}
|
|
26
26
|
export type TransformNumberFunction<N extends number = number> = MapFunction<N, N>;
|
|
27
27
|
export type TransformNumberFunctionConfigInput<S extends number = number> = TransformNumberFunctionConfig<S> | TransformNumberFunction<S>;
|
|
28
|
+
/**
|
|
29
|
+
* Normalizes a {@link TransformNumberFunctionConfigInput} to a {@link TransformNumberFunctionConfig}.
|
|
30
|
+
*
|
|
31
|
+
* If a function is provided, wraps it as the `transform` field. Returns undefined for undefined input.
|
|
32
|
+
*
|
|
33
|
+
* @param config - A config object, a transform function, or undefined
|
|
34
|
+
* @returns The normalized config, or undefined
|
|
35
|
+
*/
|
|
28
36
|
export declare function transformNumberFunctionConfig<S extends number = number>(config?: TransformNumberFunctionConfigInput<S>): Maybe<TransformNumberFunctionConfig<S>>;
|
|
37
|
+
/**
|
|
38
|
+
* Creates a composite number transform function from a {@link TransformNumberFunctionConfig}.
|
|
39
|
+
*
|
|
40
|
+
* Chains the configured operations in order: custom transform, step rounding, precision cut, then bounds clamping.
|
|
41
|
+
*
|
|
42
|
+
* @param config - Configuration with optional transform, roundToStep, precision, and bounds
|
|
43
|
+
* @returns A single function that applies all configured transformations in sequence
|
|
44
|
+
*/
|
|
29
45
|
export declare function transformNumberFunction<N extends number = number>(config: TransformNumberFunctionConfig<N>): TransformNumberFunction<N>;
|
|
@@ -1,9 +1,23 @@
|
|
|
1
1
|
import { type ArrayOrValue } from '../array';
|
|
2
2
|
/**
|
|
3
|
-
*
|
|
3
|
+
* Creates a flattened array of merged objects by computing the cross-product of arrays a and b,
|
|
4
|
+
* merging each pair with spread syntax.
|
|
5
|
+
*
|
|
6
|
+
* Convenience wrapper around {@link objectMergeMatrix} that flattens the result.
|
|
7
|
+
*
|
|
8
|
+
* @param a - First array (or single value) of partial objects
|
|
9
|
+
* @param b - Second array (or single value) of partial objects
|
|
10
|
+
* @returns Flat array of merged objects
|
|
4
11
|
*/
|
|
5
12
|
export declare function objectFlatMergeMatrix<A extends object = object, B extends object = object>(a: ArrayOrValue<Partial<A>>, b: ArrayOrValue<Partial<B>>): (Partial<A> & Partial<B>)[];
|
|
6
13
|
/**
|
|
7
|
-
* Creates a matrix of
|
|
14
|
+
* Creates a 2D matrix of merged objects from the cross-product of arrays a and b.
|
|
15
|
+
*
|
|
16
|
+
* Each element in the matrix is the spread merge of one item from a with one item from b.
|
|
17
|
+
* If either input is null/undefined, returns the other as a single-row matrix.
|
|
18
|
+
*
|
|
19
|
+
* @param a - First array (or single value) of partial objects
|
|
20
|
+
* @param b - Second array (or single value) of partial objects
|
|
21
|
+
* @returns 2D array where result[i][j] is `{ ...a[i], ...b[j] }`
|
|
8
22
|
*/
|
|
9
23
|
export declare function objectMergeMatrix<A extends object = object, B extends object = object>(a: ArrayOrValue<Partial<A>>, b: ArrayOrValue<Partial<B>>): (Partial<A> & Partial<B>)[][];
|
|
@@ -40,8 +40,12 @@ export interface ObjectDeltaArrayCompressor<T extends object> {
|
|
|
40
40
|
readonly expand: ObjectDeltaArrayCompressorExpandFunction<T>;
|
|
41
41
|
}
|
|
42
42
|
/**
|
|
43
|
-
* Creates an
|
|
43
|
+
* Creates an {@link ObjectDeltaArrayCompressor} that can compress and expand arrays of objects using delta encoding.
|
|
44
44
|
*
|
|
45
|
-
*
|
|
45
|
+
* The first object is stored fully. Subsequent objects store only fields that changed from the previous entry.
|
|
46
|
+
* Null in a delta entry means the field was cleared. Undefined (missing key) means no change.
|
|
47
|
+
*
|
|
48
|
+
* @param config - Configuration with the equality checker that defines which fields to track
|
|
49
|
+
* @returns A compressor with `compress` and `expand` methods
|
|
46
50
|
*/
|
|
47
51
|
export declare function objectDeltaArrayCompressor<T extends object>(config: ObjectDeltaArrayCompressorConfig<T>): ObjectDeltaArrayCompressor<T>;
|
|
@@ -10,22 +10,50 @@ export type POJOKey = PrimativeKey | symbol;
|
|
|
10
10
|
*/
|
|
11
11
|
export type ObjectKey = string;
|
|
12
12
|
export type EmptyObject = Record<string, never>;
|
|
13
|
+
/**
|
|
14
|
+
* Checks whether the object has no own enumerable keys.
|
|
15
|
+
*
|
|
16
|
+
* @param obj - Object to check
|
|
17
|
+
* @returns `true` if the object has zero keys
|
|
18
|
+
*/
|
|
13
19
|
export declare function objectHasNoKeys(obj: object): obj is EmptyObject;
|
|
20
|
+
/**
|
|
21
|
+
* Checks whether the object has the specified own property using `Object.prototype.hasOwnProperty`.
|
|
22
|
+
*
|
|
23
|
+
* @param obj - Object to check
|
|
24
|
+
* @param key - Property key to test for
|
|
25
|
+
* @returns `true` if the object has the key as an own property
|
|
26
|
+
*/
|
|
14
27
|
export declare function objectHasKey<T>(obj: T, key: KeyAsString<keyof T>): boolean;
|
|
15
28
|
export declare function objectHasKey(obj: unknown, key: string): boolean;
|
|
16
29
|
export declare function objectHasKey<T, K extends keyof T>(obj: T, key: K): boolean;
|
|
17
30
|
/**
|
|
18
|
-
*
|
|
31
|
+
* Checks whether the object has all or any of the specified keys, based on the mode.
|
|
19
32
|
*
|
|
20
|
-
* @param obj
|
|
21
|
-
* @param keys
|
|
33
|
+
* @param obj - Object to check
|
|
34
|
+
* @param keys - Keys to test for
|
|
35
|
+
* @param mode - Whether to require 'all' keys or just 'any'; defaults to 'all'
|
|
36
|
+
* @returns `true` if the keys match the mode criteria
|
|
22
37
|
*/
|
|
23
38
|
export declare function objectHasKeys<T>(obj: T, keys: KeyAsString<keyof T>[], mode?: SetIncludesMode): boolean;
|
|
24
39
|
export declare function objectHasKeys(obj: unknown, keys: ObjectKey[], mode?: SetIncludesMode): boolean;
|
|
25
40
|
export declare function objectHasKeys<T, K extends keyof T>(obj: T, keys: K[], mode?: SetIncludesMode): boolean;
|
|
41
|
+
/**
|
|
42
|
+
* Creates a partial object with the same value assigned to each of the specified fields.
|
|
43
|
+
*
|
|
44
|
+
* @param value - The value to assign to each field
|
|
45
|
+
* @param fields - Array of field names to set
|
|
46
|
+
* @returns A partial object with the value set on each specified field
|
|
47
|
+
*/
|
|
26
48
|
export declare function applyToMultipleFields<T extends object, X = unknown>(value: X, fields: FieldOfType<T>[]): Partial<{
|
|
27
49
|
[K in keyof T]: X;
|
|
28
50
|
}>;
|
|
51
|
+
/**
|
|
52
|
+
* Converts a Map to a plain object by iterating entries and assigning key-value pairs.
|
|
53
|
+
*
|
|
54
|
+
* @param map - Map to convert
|
|
55
|
+
* @returns A plain object with the same key-value pairs
|
|
56
|
+
*/
|
|
29
57
|
export declare function mapToObject<T, K extends PropertyKey>(map: Map<K, T>): {
|
|
30
58
|
[key: PropertyKey]: T;
|
|
31
59
|
};
|
|
@@ -36,7 +64,7 @@ export type CopyObjectFunction<T> = (input: T) => T;
|
|
|
36
64
|
/**
|
|
37
65
|
* Creates a shallow copy of an object using the spread operator.
|
|
38
66
|
*
|
|
39
|
-
* @param input
|
|
40
|
-
* @returns
|
|
67
|
+
* @param input - Object to copy
|
|
68
|
+
* @returns A new object with the same properties
|
|
41
69
|
*/
|
|
42
70
|
export declare function copyObject<T extends object>(input: T): T;
|
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
import { type Maybe } from '../value/maybe.type';
|
|
2
2
|
/**
|
|
3
|
-
* Recursively
|
|
3
|
+
* Recursively checks whether an object is "empty" — meaning it is null/undefined, has no keys,
|
|
4
|
+
* or all of its values are themselves empty (recursively for nested objects, or falsy for primitives).
|
|
4
5
|
*
|
|
5
|
-
* @param obj
|
|
6
|
+
* @param obj - Object to check
|
|
7
|
+
* @returns `true` if the object is considered empty
|
|
6
8
|
*/
|
|
7
9
|
export declare function objectIsEmpty<T extends object>(obj: Maybe<T>): boolean;
|
|
@@ -2,15 +2,24 @@ import { type FieldOfType } from '../key';
|
|
|
2
2
|
import { type EqualityComparatorFunction } from '../value/comparator';
|
|
3
3
|
import { type FilterFromPOJOFunction } from './object.filter.pojo';
|
|
4
4
|
/**
|
|
5
|
-
* Performs a deep comparison
|
|
5
|
+
* Performs a deep equality comparison between two values.
|
|
6
6
|
*
|
|
7
|
-
* Recursively compares
|
|
7
|
+
* Recursively compares arrays, objects, Maps, Sets, primitives, and Dates.
|
|
8
|
+
*
|
|
9
|
+
* @param a - First value to compare
|
|
10
|
+
* @param b - Second value to compare
|
|
11
|
+
* @returns `true` if the values are deeply equal
|
|
8
12
|
*/
|
|
9
13
|
export declare function areEqualPOJOValues<F>(a: F, b: F): boolean;
|
|
10
14
|
/**
|
|
11
|
-
* Performs a deep comparison
|
|
15
|
+
* Performs a deep equality comparison with a POJO filter applied to each value before comparison.
|
|
16
|
+
*
|
|
17
|
+
* Recursively compares arrays, objects, Maps, Sets, primitives, and Dates.
|
|
12
18
|
*
|
|
13
|
-
*
|
|
19
|
+
* @param a - First value to compare
|
|
20
|
+
* @param b - Second value to compare
|
|
21
|
+
* @param pojoFilter - Filter function applied to each value before comparison
|
|
22
|
+
* @returns `true` if the filtered values are deeply equal
|
|
14
23
|
*/
|
|
15
24
|
export declare function areEqualPOJOValuesUsingPojoFilter<F>(a: F, b: F, pojoFilter: FilterFromPOJOFunction<F>): boolean;
|
|
16
25
|
/**
|
|
@@ -70,4 +79,12 @@ export interface ObjectFieldEqualityCheckResults<T extends object> {
|
|
|
70
79
|
export type ObjectFieldEqualityChecker<T extends object> = ((a: Partial<T>, b: Partial<T>) => ObjectFieldEqualityCheckResults<T>) & {
|
|
71
80
|
readonly _fields: Map<keyof T, ObjectFieldEqualityCheckerFieldConfig<T, any>>;
|
|
72
81
|
};
|
|
82
|
+
/**
|
|
83
|
+
* Creates an {@link ObjectFieldEqualityChecker} that compares two objects field-by-field using configured equality functions.
|
|
84
|
+
*
|
|
85
|
+
* Fields can be specified as simple field names (using the default `===` comparator) or as config objects with custom comparators.
|
|
86
|
+
*
|
|
87
|
+
* @param config - Configuration with the fields to compare and an optional default equality function
|
|
88
|
+
* @returns A function that compares two objects and reports which fields are equal/unequal
|
|
89
|
+
*/
|
|
73
90
|
export declare function objectFieldEqualityChecker<T extends object>(config: ObjectFieldEqualityCheckerConfig<T>): ObjectFieldEqualityChecker<T>;
|
|
@@ -1,19 +1,88 @@
|
|
|
1
1
|
import { type FilterFunction } from '../filter/filter';
|
|
2
2
|
import { type KeyAsString } from '../type';
|
|
3
|
+
/**
|
|
4
|
+
* Callback invoked for each key/value tuple during iteration.
|
|
5
|
+
*/
|
|
3
6
|
export type ForEachKeyValueTupleFunction<T extends object = object, K extends keyof T = keyof T> = (tuple: KeyValueTuple<T, K>, index: number) => void;
|
|
7
|
+
/**
|
|
8
|
+
* Configuration for {@link forEachKeyValue} specifying a filter and a forEach callback.
|
|
9
|
+
*/
|
|
4
10
|
export interface ForEachKeyValue<T extends object = object, K extends keyof T = keyof T> {
|
|
5
11
|
readonly filter?: FilterKeyValueTuplesInput<T, K>;
|
|
6
12
|
readonly forEach: ForEachKeyValueTupleFunction<T, K>;
|
|
7
13
|
}
|
|
14
|
+
/**
|
|
15
|
+
* Iterates over filtered key/value tuples of an object and invokes a callback for each.
|
|
16
|
+
*
|
|
17
|
+
* @param obj - Object to iterate
|
|
18
|
+
* @param config - Configuration with a forEach callback and optional filter
|
|
19
|
+
*
|
|
20
|
+
* @example
|
|
21
|
+
* ```ts
|
|
22
|
+
* const keys: string[] = [];
|
|
23
|
+
* forEachKeyValue({ a: 1, b: undefined, c: 3 }, {
|
|
24
|
+
* filter: KeyValueTypleValueFilter.UNDEFINED,
|
|
25
|
+
* forEach: ([key]) => keys.push(key as string)
|
|
26
|
+
* });
|
|
27
|
+
* // keys: ['a', 'c']
|
|
28
|
+
* ```
|
|
29
|
+
*/
|
|
8
30
|
export declare function forEachKeyValue<T extends object = object, K extends keyof T = keyof T>(obj: T, { forEach, filter }: ForEachKeyValue<T, K>): void;
|
|
31
|
+
/**
|
|
32
|
+
* Extracts key/value tuples from an object, optionally filtering them.
|
|
33
|
+
*
|
|
34
|
+
* @param obj - Object to extract tuples from
|
|
35
|
+
* @param filter - Optional filter to apply to the tuples
|
|
36
|
+
* @returns Array of matching key/value tuples
|
|
37
|
+
*
|
|
38
|
+
* @example
|
|
39
|
+
* ```ts
|
|
40
|
+
* const tuples = filterKeyValueTuples({ a: 1, b: null, c: 3 }, KeyValueTypleValueFilter.NULL);
|
|
41
|
+
* // tuples: [['a', 1], ['c', 3]]
|
|
42
|
+
* ```
|
|
43
|
+
*/
|
|
9
44
|
export declare function filterKeyValueTuples<T extends object = object, K extends keyof T = keyof T>(obj: T, filter?: FilterKeyValueTuplesInput<T, K>): KeyValueTuple<T, K>[];
|
|
10
45
|
/**
|
|
11
46
|
* A Key-Value pair within an Tuple array value.
|
|
12
47
|
*/
|
|
13
48
|
export type KeyValueTuple<T extends object = object, K extends keyof T = keyof T> = [K, T[K]];
|
|
49
|
+
/**
|
|
50
|
+
* Function that extracts key/value tuples from an object, optionally filtering them based on a pre-configured filter.
|
|
51
|
+
*/
|
|
14
52
|
export type FilterKeyValueTuplesFunction<T extends object = object, K extends keyof T = keyof T> = (obj: T) => KeyValueTuple<T, K>[];
|
|
53
|
+
/**
|
|
54
|
+
* Creates a reusable function that extracts and filters key/value tuples from objects.
|
|
55
|
+
*
|
|
56
|
+
* When no filter is provided, returns all key/value tuples.
|
|
57
|
+
*
|
|
58
|
+
* @param filter - Optional filter configuration
|
|
59
|
+
* @returns A function that extracts filtered tuples from any input object
|
|
60
|
+
*
|
|
61
|
+
* @example
|
|
62
|
+
* ```ts
|
|
63
|
+
* const getDefinedTuples = filterKeyValueTuplesFunction(KeyValueTypleValueFilter.UNDEFINED);
|
|
64
|
+
* const tuples = getDefinedTuples({ a: 1, b: undefined, c: 'hello' });
|
|
65
|
+
* // tuples: [['a', 1], ['c', 'hello']]
|
|
66
|
+
* ```
|
|
67
|
+
*/
|
|
15
68
|
export declare function filterKeyValueTuplesFunction<T extends object = object, K extends keyof T = keyof T>(filter?: FilterKeyValueTuplesInput<T, K>): FilterKeyValueTuplesFunction<T, K>;
|
|
69
|
+
/**
|
|
70
|
+
* Returns all key/value pairs from the object as tuples using `Object.entries`.
|
|
71
|
+
*
|
|
72
|
+
* @param obj - Object to extract tuples from
|
|
73
|
+
* @returns Array of `[key, value]` tuples
|
|
74
|
+
*
|
|
75
|
+
* @example
|
|
76
|
+
* ```ts
|
|
77
|
+
* const tuples = allKeyValueTuples({ x: 10, y: 20 });
|
|
78
|
+
* // tuples: [['x', 10], ['y', 20]]
|
|
79
|
+
* ```
|
|
80
|
+
*/
|
|
16
81
|
export declare function allKeyValueTuples<T extends object = object, K extends keyof T = keyof T>(obj: T): KeyValueTuple<T, K>[];
|
|
82
|
+
/**
|
|
83
|
+
* Input for configuring key/value tuple filtering. Can be a {@link KeyValueTypleValueFilter} enum for simple cases
|
|
84
|
+
* or a {@link KeyValueTupleFilter} object for more complex filtering (value type + key restriction + inversion).
|
|
85
|
+
*/
|
|
17
86
|
export type FilterKeyValueTuplesInput<T extends object = object, K extends keyof T = keyof T> = KeyValueTypleValueFilter | KeyValueTupleFilter<T, K>;
|
|
18
87
|
/**
|
|
19
88
|
* Value filter options for filterKeyValueTupleFunction()
|
|
@@ -52,17 +121,50 @@ export declare enum KeyValueTypleValueFilter {
|
|
|
52
121
|
*/
|
|
53
122
|
FALSY_AND_EMPTY_STRICT = 7
|
|
54
123
|
}
|
|
124
|
+
/**
|
|
125
|
+
* Full configuration for filtering key/value tuples, supporting value type filtering, key restriction, and inversion.
|
|
126
|
+
*/
|
|
55
127
|
export interface KeyValueTupleFilter<T extends object = object, K extends keyof T = keyof T> {
|
|
128
|
+
/**
|
|
129
|
+
* Type of value filtering to apply.
|
|
130
|
+
*/
|
|
56
131
|
valueFilter?: KeyValueTypleValueFilter;
|
|
132
|
+
/**
|
|
133
|
+
* When `true`, inverts the filter so that only non-matching tuples are retained.
|
|
134
|
+
*/
|
|
57
135
|
invertFilter?: boolean;
|
|
136
|
+
/**
|
|
137
|
+
* Restricts filtering to only these keys. Other keys are excluded from the result.
|
|
138
|
+
*/
|
|
58
139
|
keysFilter?: (K | KeyAsString<K>)[];
|
|
59
140
|
}
|
|
60
141
|
/**
|
|
61
|
-
*
|
|
142
|
+
* Normalizes a {@link FilterKeyValueTuplesInput} to a {@link KeyValueTupleFilter} object.
|
|
143
|
+
*
|
|
144
|
+
* If the input is already an object, returns it as-is. If it's an enum value, wraps it in a filter object.
|
|
62
145
|
*
|
|
63
|
-
* @param input
|
|
64
|
-
* @returns
|
|
146
|
+
* @param input - Enum value or filter object
|
|
147
|
+
* @returns Normalized filter object
|
|
65
148
|
*/
|
|
66
149
|
export declare function filterKeyValueTuplesInputToFilter<T extends object = object, K extends keyof T = keyof T>(input: FilterKeyValueTuplesInput<T, K>): KeyValueTupleFilter<T, K>;
|
|
150
|
+
/**
|
|
151
|
+
* Predicate function that tests a single key/value tuple, returning `true` if it passes the filter.
|
|
152
|
+
*/
|
|
67
153
|
export type FilterKeyValueTupleFunction<T extends object = object, K extends keyof T = keyof T> = FilterFunction<KeyValueTuple<T, K>>;
|
|
154
|
+
/**
|
|
155
|
+
* Creates a filter predicate function for key/value tuples based on the provided filter configuration.
|
|
156
|
+
*
|
|
157
|
+
* The predicate returns `true` for tuples whose values pass the configured filter. Supports value type filtering
|
|
158
|
+
* (undefined, null, falsy, empty), key filtering, and inversion.
|
|
159
|
+
*
|
|
160
|
+
* @param inputFilter - Filter configuration (enum value or full config object)
|
|
161
|
+
* @returns A predicate function that tests individual key/value tuples
|
|
162
|
+
*
|
|
163
|
+
* @example
|
|
164
|
+
* ```ts
|
|
165
|
+
* const isNotNull = filterKeyValueTupleFunction(KeyValueTypleValueFilter.NULL);
|
|
166
|
+
* isNotNull(['a', 1], 0); // true
|
|
167
|
+
* isNotNull(['b', null], 0); // false
|
|
168
|
+
* ```
|
|
169
|
+
*/
|
|
68
170
|
export declare function filterKeyValueTupleFunction<T extends object = object, K extends keyof T = keyof T>(inputFilter: FilterKeyValueTuplesInput<T, K>): FilterKeyValueTupleFunction<T, K>;
|
|
@@ -2,16 +2,23 @@ import { type PrimativeKey, type ReadKeyFunction, type ReadMultipleKeysFunction
|
|
|
2
2
|
import { type Maybe } from '../value/maybe.type';
|
|
3
3
|
import { type EqualityComparatorFunction } from '../value/comparator';
|
|
4
4
|
/**
|
|
5
|
-
* Creates
|
|
5
|
+
* Creates an {@link EqualityComparatorFunction} that compares two arrays of objects by extracting keys
|
|
6
|
+
* and checking that both arrays contain the same set of keys (order-independent).
|
|
6
7
|
*
|
|
7
|
-
*
|
|
8
|
-
* @
|
|
8
|
+
* Returns `true` if both arrays have the same length and produce identical key sets.
|
|
9
|
+
* Handles `null`/`undefined` inputs via {@link safeEqualityComparatorFunction}.
|
|
10
|
+
*
|
|
11
|
+
* @param readKey - Function to extract one or more keys from each object
|
|
12
|
+
* @returns An equality comparator for arrays of keyed objects
|
|
9
13
|
*/
|
|
10
14
|
export declare function objectKeysEqualityComparatorFunction<T, K extends PrimativeKey = PrimativeKey>(readKey: ReadKeyFunction<T, K> | ReadMultipleKeysFunction<T, K>): EqualityComparatorFunction<Maybe<T[]>>;
|
|
11
15
|
/**
|
|
12
|
-
* Creates
|
|
16
|
+
* Creates an {@link EqualityComparatorFunction} that compares two objects by extracting a single key
|
|
17
|
+
* from each and checking strict equality.
|
|
18
|
+
*
|
|
19
|
+
* Handles `null`/`undefined` inputs via {@link safeEqualityComparatorFunction}.
|
|
13
20
|
*
|
|
14
|
-
* @param readKey
|
|
15
|
-
* @returns
|
|
21
|
+
* @param readKey - Function to extract the key from an object
|
|
22
|
+
* @returns An equality comparator for keyed objects
|
|
16
23
|
*/
|
|
17
24
|
export declare function objectKeyEqualityComparatorFunction<T, K extends PrimativeKey = PrimativeKey>(readKey: ReadKeyFunction<T, K>): EqualityComparatorFunction<Maybe<T>>;
|
|
@@ -12,14 +12,17 @@ export type StringObjectMap<T> = {
|
|
|
12
12
|
[key: number]: never;
|
|
13
13
|
[key: symbol]: never;
|
|
14
14
|
};
|
|
15
|
+
/**
|
|
16
|
+
* Mapped type that preserves the keys of `M` but replaces all value types with `O`.
|
|
17
|
+
*/
|
|
15
18
|
export type MappedObjectMap<M extends object, O> = {
|
|
16
19
|
[key in keyof M]: O;
|
|
17
20
|
};
|
|
18
21
|
/**
|
|
19
|
-
* Converts an ObjectMap into a Map.
|
|
22
|
+
* Converts an {@link ObjectMap} into a `Map` using `Object.entries`.
|
|
20
23
|
*
|
|
21
|
-
* @param object
|
|
22
|
-
* @returns
|
|
24
|
+
* @param object - The object map to convert
|
|
25
|
+
* @returns A `Map` with the same key-value pairs
|
|
23
26
|
*/
|
|
24
27
|
export declare function objectToMap<T>(object: ObjectMap<T>): Map<string, T>;
|
|
25
28
|
/**
|
|
@@ -27,26 +30,31 @@ export declare function objectToMap<T>(object: ObjectMap<T>): Map<string, T>;
|
|
|
27
30
|
*/
|
|
28
31
|
export type MapObjectMapFunction<M extends ObjectMap<I>, I = unknown, O = unknown> = MapFunction<M, MappedObjectMap<M, O>>;
|
|
29
32
|
/**
|
|
30
|
-
* Creates a MapObjectMapFunction that
|
|
33
|
+
* Creates a reusable {@link MapObjectMapFunction} that applies {@link mapObjectMap} with the given mapping function.
|
|
31
34
|
*
|
|
32
|
-
* @param mapFn
|
|
33
|
-
* @returns
|
|
35
|
+
* @param mapFn - Function that transforms each value (receives value and key)
|
|
36
|
+
* @returns A function that maps all values in an input object map
|
|
34
37
|
*/
|
|
35
38
|
export declare function mapObjectMapFunction<M extends ObjectMap<I>, I = unknown, O = unknown>(mapFn: MapObjectMapValueFunction<M, I, O>): MapObjectMapFunction<M, I, O>;
|
|
39
|
+
/**
|
|
40
|
+
* Mapping function that transforms a single value from an {@link ObjectMap}, receiving both the value and its key.
|
|
41
|
+
*/
|
|
36
42
|
export type MapObjectMapValueFunction<M extends ObjectMap<I>, I = unknown, O = unknown> = <K extends keyof M>(value: M[K], key: K) => O;
|
|
37
43
|
/**
|
|
38
|
-
* Maps
|
|
44
|
+
* Maps all values of an {@link ObjectMap} from one type to another, returning a new object with the same keys.
|
|
39
45
|
*
|
|
40
|
-
* @param object
|
|
46
|
+
* @param object - The source object map
|
|
47
|
+
* @param mapFn - Function that transforms each value
|
|
48
|
+
* @returns A new object with mapped values
|
|
41
49
|
*/
|
|
42
50
|
export declare function mapObjectMap<M extends ObjectMap<I>, I = unknown, O = unknown>(object: M, mapFn: MapObjectMapValueFunction<M, I, O>): MappedObjectMap<M, O>;
|
|
43
51
|
/**
|
|
44
|
-
* Maps the values of
|
|
52
|
+
* Maps the values of a source {@link ObjectMap} and assigns the results onto the target object, returning the target.
|
|
45
53
|
*
|
|
46
|
-
* @param object
|
|
47
|
-
* @param target
|
|
48
|
-
* @param mapFn
|
|
49
|
-
* @returns
|
|
54
|
+
* @param object - The source object map
|
|
55
|
+
* @param target - The target object to assign mapped values onto
|
|
56
|
+
* @param mapFn - Function that transforms each value
|
|
57
|
+
* @returns The target object with mapped values assigned
|
|
50
58
|
*/
|
|
51
59
|
export declare function mapObjectToTargetObject<M extends ObjectMap<I>, I = unknown, O = unknown>(object: M, target: MappedObjectMap<M, O>, mapFn: MapObjectMapValueFunction<M, I, O>): MappedObjectMap<M, O>;
|
|
52
60
|
/**
|
|
@@ -58,19 +66,22 @@ export type MapObjectKeysFunction<M> = (object: M) => any;
|
|
|
58
66
|
*/
|
|
59
67
|
export type MapObjectKeyFunction<M> = <K extends keyof M>(key: K, value: M[K]) => POJOKey;
|
|
60
68
|
/**
|
|
61
|
-
*
|
|
69
|
+
* Creates a reusable {@link MapObjectKeysFunction} that transforms the keys of an input object using the given mapping function.
|
|
62
70
|
*
|
|
63
|
-
* @param
|
|
71
|
+
* @param mapKeyFn - Function that computes the new key from the old key and its value
|
|
72
|
+
* @returns A function that remaps keys on any input object
|
|
64
73
|
*/
|
|
65
74
|
export declare function mapObjectKeysFunction<M extends object>(mapKeyFn: MapObjectKeyFunction<M>): MapObjectKeysFunction<M>;
|
|
75
|
+
/**
|
|
76
|
+
* Mapped type that converts all string keys of `M` to lowercase while preserving their value types.
|
|
77
|
+
*/
|
|
66
78
|
export type MappedKeysToLowercaseObjectMap<M extends object> = {
|
|
67
79
|
[K in keyof M as K extends string ? Lowercase<K> : K]: M[K];
|
|
68
80
|
};
|
|
69
81
|
/**
|
|
70
|
-
*
|
|
82
|
+
* Pre-built function that maps all string keys of an object to lowercase, returning a new object.
|
|
71
83
|
*
|
|
72
|
-
*
|
|
73
|
-
*
|
|
74
|
-
* @param mapFn
|
|
84
|
+
* Non-string keys (e.g., numbers) are passed through unchanged.
|
|
85
|
+
* When multiple keys map to the same lowercase key, the last one wins (order is undefined).
|
|
75
86
|
*/
|
|
76
87
|
export declare const mapObjectKeysToLowercase: <M extends object>(object: M) => MappedKeysToLowercaseObjectMap<M>;
|