@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
package/src/lib/model/model.d.ts
CHANGED
|
@@ -5,6 +5,10 @@ import { type MapFunction } from '../value/map';
|
|
|
5
5
|
* A string model key
|
|
6
6
|
*/
|
|
7
7
|
export type ModelKey = string;
|
|
8
|
+
/**
|
|
9
|
+
* A string model identifier (typically the document/record ID segment, not the full path).
|
|
10
|
+
*/
|
|
11
|
+
export type ModelId = string;
|
|
8
12
|
/**
|
|
9
13
|
* Arbitrary model type.
|
|
10
14
|
*/
|
|
@@ -30,6 +34,9 @@ export interface NamedUniqueModel extends UniqueModel {
|
|
|
30
34
|
export interface ModelKeyRef {
|
|
31
35
|
key: ModelKey;
|
|
32
36
|
}
|
|
37
|
+
export interface ModelIdRef {
|
|
38
|
+
id: ModelId;
|
|
39
|
+
}
|
|
33
40
|
export type ModelOrKey<T> = T | ModelKey;
|
|
34
41
|
/**
|
|
35
42
|
* ModelOrKey where the model extends UniqueModel
|
|
@@ -54,39 +61,196 @@ export type ReadModelKeyFunction<T> = ReadKeyFunction<T, ModelKey>;
|
|
|
54
61
|
export type ReadModelTypeFunction<T, M extends ModelTypeString = ModelTypeString> = ReadKeyFunction<T, M>;
|
|
55
62
|
export type ReadRelationKeysFunction<T> = ReadMultipleKeysFunction<T, ModelKey>;
|
|
56
63
|
export type MultiModelKeyMap<T> = Map<string, T>;
|
|
64
|
+
/**
|
|
65
|
+
* Reads the `id` property from a {@link UniqueModel}.
|
|
66
|
+
*
|
|
67
|
+
* @param model - Model to read the key from
|
|
68
|
+
* @returns The model's `id` value
|
|
69
|
+
*/
|
|
57
70
|
export declare const readUniqueModelKey: (model: UniqueModel) => string | undefined;
|
|
71
|
+
/**
|
|
72
|
+
* Abstract base class for models identified by a unique {@link ModelKey}.
|
|
73
|
+
*
|
|
74
|
+
* Copies the `id` from the provided template during construction.
|
|
75
|
+
*/
|
|
58
76
|
export declare abstract class AbstractUniqueModel {
|
|
59
77
|
id?: ModelKey;
|
|
60
78
|
constructor(template: Partial<AbstractUniqueModel>);
|
|
61
79
|
}
|
|
80
|
+
/**
|
|
81
|
+
* Deduplicates an array of model keys using a Set.
|
|
82
|
+
*
|
|
83
|
+
* @param keys - Array of model keys that may contain duplicates
|
|
84
|
+
* @returns Array containing only unique keys
|
|
85
|
+
*
|
|
86
|
+
* @example
|
|
87
|
+
* ```ts
|
|
88
|
+
* const result = uniqueKeys(['a', 'b', 'a', 'c']);
|
|
89
|
+
* // result: ['a', 'b', 'c']
|
|
90
|
+
* ```
|
|
91
|
+
*/
|
|
62
92
|
export declare function uniqueKeys(keys: ModelKey[]): ModelKey[];
|
|
93
|
+
/**
|
|
94
|
+
* Deduplicates models by their key, keeping the first occurrence of each unique key.
|
|
95
|
+
*
|
|
96
|
+
* @param models - Array of models that may contain duplicates
|
|
97
|
+
* @param readKey - Function to extract the key from each model; defaults to reading the `id` property
|
|
98
|
+
* @returns Array containing only the first model for each unique key
|
|
99
|
+
*/
|
|
63
100
|
export declare function uniqueModels<T extends UniqueModel>(models: T[], readKey?: ReadModelKeyFunction<T>): T[];
|
|
64
101
|
export declare function uniqueModels<T>(models: T[], readKey: ReadModelKeyFunction<T>): T[];
|
|
102
|
+
/**
|
|
103
|
+
* Extracts model keys from an array of model objects.
|
|
104
|
+
*
|
|
105
|
+
* @param input - Array of model objects to read keys from
|
|
106
|
+
* @param required - Whether keys are required; throws if a key is missing and this is `true`
|
|
107
|
+
* @param read - Function to extract the key from each model; defaults to reading the `id` property
|
|
108
|
+
* @returns Array of model keys (may contain undefined values if `required` is false)
|
|
109
|
+
* @throws Error if `required` is true and any model lacks a key
|
|
110
|
+
*/
|
|
65
111
|
export declare function readModelKeysFromObjects<T extends UniqueModel>(input: T[], required?: boolean, read?: ReadModelKeyFunction<T>): Maybe<ModelKey>[];
|
|
66
112
|
export declare function readModelKeysFromObjects<T extends UniqueModel>(input: T[], required: true, read?: ReadModelKeyFunction<T>): ModelKey[];
|
|
113
|
+
/**
|
|
114
|
+
* Computes the symmetric difference (elements in either array but not both) between two arrays of models or keys.
|
|
115
|
+
*
|
|
116
|
+
* @param a - First array of models or keys
|
|
117
|
+
* @param b - Second array of models or keys
|
|
118
|
+
* @param required - Whether keys are required
|
|
119
|
+
* @param read - Function to extract keys from models
|
|
120
|
+
* @returns Keys that appear in one array but not the other
|
|
121
|
+
*/
|
|
67
122
|
export declare function symmetricDifferenceWithModels<T extends UniqueModel>(a: ModelOrKey<T>[], b: ModelOrKey<T>[], required?: boolean, read?: ReadModelKeyFunction<T>): Maybe<ModelKey>[];
|
|
123
|
+
/**
|
|
124
|
+
* Removes all models from the array that share the same key as the given model.
|
|
125
|
+
*
|
|
126
|
+
* @param input - Array of models to filter
|
|
127
|
+
* @param model - Reference model whose key should be excluded
|
|
128
|
+
* @param read - Function to extract the key from each model
|
|
129
|
+
* @returns Filtered array excluding models with the same key as the reference model
|
|
130
|
+
*/
|
|
68
131
|
export declare function removeModelsWithSameKey<T>(input: T[], model: T, read: ReadModelKeyFunction<T>): T[];
|
|
132
|
+
/**
|
|
133
|
+
* Removes all models from the array that have the specified key.
|
|
134
|
+
*
|
|
135
|
+
* @param input - Array of models to filter
|
|
136
|
+
* @param key - Key value to exclude
|
|
137
|
+
* @param read - Function to extract the key from each model; defaults to reading the `id` property
|
|
138
|
+
* @returns Filtered array excluding models with the matching key
|
|
139
|
+
*/
|
|
69
140
|
export declare function removeModelsWithKey<T extends UniqueModel>(input: T[], key: Maybe<ModelKey>, read?: ReadModelKeyFunction<T>): T[];
|
|
70
141
|
export declare function removeModelsWithKey<T>(input: T[], key: Maybe<ModelKey>, read: ReadModelKeyFunction<T>): T[];
|
|
142
|
+
/**
|
|
143
|
+
* Creates a Map from model key to model, indexing each model by its key.
|
|
144
|
+
*
|
|
145
|
+
* If multiple models share the same key, the last one wins.
|
|
146
|
+
*
|
|
147
|
+
* @param input - Array of models to index
|
|
148
|
+
* @param read - Function to extract the key from each model; defaults to reading the `id` property
|
|
149
|
+
* @returns Map from model key to model
|
|
150
|
+
*/
|
|
71
151
|
export declare function makeModelMap<T extends UniqueModel>(input: T[], read?: ReadModelKeyFunction<T>): Map<Maybe<ModelKey>, T>;
|
|
72
152
|
export declare function makeModelMap<T>(input: T[], read: ReadModelKeyFunction<T>): Map<Maybe<ModelKey>, T>;
|
|
73
153
|
/**
|
|
74
|
-
* Creates a
|
|
154
|
+
* Creates a Map that indexes each model by multiple keys, allowing lookup of a model by any of its relation keys.
|
|
155
|
+
*
|
|
156
|
+
* If multiple models share the same relation key, the last one wins for that key.
|
|
157
|
+
*
|
|
158
|
+
* @param input - Array of models to index
|
|
159
|
+
* @param read - Function that returns an array of relation keys for each model
|
|
160
|
+
* @returns Map from relation key to model
|
|
75
161
|
*/
|
|
76
162
|
export declare function makeMultiModelKeyMap<T>(input: T[], read: ReadRelationKeysFunction<T>): MultiModelKeyMap<T>;
|
|
163
|
+
/**
|
|
164
|
+
* Dispatches to either `useModel` or `useKey` depending on whether the input is a model object or a key string.
|
|
165
|
+
*
|
|
166
|
+
* If the input is null/undefined and `required` is true, throws an error.
|
|
167
|
+
*
|
|
168
|
+
* @param input - A model object or a model key string
|
|
169
|
+
* @param config - Handlers for model and key cases, plus whether input is required
|
|
170
|
+
* @returns The result of the matched handler, or undefined if input is nullish and not required
|
|
171
|
+
* @throws Error if `required` is true and input is nullish
|
|
172
|
+
*/
|
|
77
173
|
export declare function useModelOrKey<O, T extends UniqueModel>(input: ModelOrKey<T>, { useModel, useKey, required }: {
|
|
78
174
|
useModel?: (model: T) => O;
|
|
79
175
|
useKey: (key: Maybe<ModelKey>) => O;
|
|
80
176
|
required?: boolean;
|
|
81
177
|
}): Maybe<O>;
|
|
178
|
+
/**
|
|
179
|
+
* Extracts model keys from an array of models or key strings.
|
|
180
|
+
*
|
|
181
|
+
* @param input - Array of models, key strings, or undefined values
|
|
182
|
+
* @param required - Whether keys are required
|
|
183
|
+
* @param read - Function to extract the key from model objects
|
|
184
|
+
* @returns Array of model keys
|
|
185
|
+
*/
|
|
82
186
|
export declare function readModelKeys<T extends UniqueModel>(input: (ModelOrKey<T> | undefined)[], required?: boolean, read?: ReadModelKeyFunction<T>): Maybe<ModelKey>[];
|
|
187
|
+
/**
|
|
188
|
+
* Reads a model key from a model or key string. Convenience wrapper around {@link readModelKey} with default params.
|
|
189
|
+
*
|
|
190
|
+
* @param input - A model object or a key string
|
|
191
|
+
* @returns The extracted model key, or undefined if input is undefined
|
|
192
|
+
*/
|
|
83
193
|
export declare function requireModelKey<T extends UniqueModel>(input: ModelOrKey<T> | undefined): Maybe<ModelKey>;
|
|
194
|
+
/**
|
|
195
|
+
* Reads a model key from a value that may be a model object, a key string, or undefined.
|
|
196
|
+
*
|
|
197
|
+
* Strings are returned as-is. Objects are passed through the `read` function to extract the key.
|
|
198
|
+
*
|
|
199
|
+
* @param input - A model object, key string, or undefined
|
|
200
|
+
* @param params - Configuration for reading, including whether the key is required and the read function
|
|
201
|
+
* @returns The extracted model key, or undefined
|
|
202
|
+
* @throws Error if `required` is true and no key can be extracted
|
|
203
|
+
*/
|
|
84
204
|
export declare function readModelKey<T>(input: ModelOrKey<T> | undefined, params: ReadModelKeyParams<T>): Maybe<ModelKey>;
|
|
85
205
|
export declare function readModelKey<T extends UniqueModel>(input: ModelOrKey<T> | undefined, params?: Partial<ReadModelKeyParams<T>>): Maybe<ModelKey>;
|
|
206
|
+
/**
|
|
207
|
+
* Reads a model key directly from a model object using the provided read function.
|
|
208
|
+
*
|
|
209
|
+
* @param input - Model object to read the key from
|
|
210
|
+
* @param required - Whether the key is required; throws if missing when true
|
|
211
|
+
* @param read - Function to extract the key; defaults to reading the `id` property
|
|
212
|
+
* @returns The extracted model key, or undefined
|
|
213
|
+
* @throws Error if `required` is true and the key is missing
|
|
214
|
+
*/
|
|
86
215
|
export declare function readModelKeyFromObject<T extends UniqueModel>(input: T, required?: boolean, read?: ReadModelKeyFunction<T>): Maybe<ModelKey>;
|
|
216
|
+
/**
|
|
217
|
+
* Type guard that checks whether the input is a string model key rather than a model object.
|
|
218
|
+
*
|
|
219
|
+
* @param input - A model object or a key string
|
|
220
|
+
* @returns `true` if the input is a string key
|
|
221
|
+
*/
|
|
87
222
|
export declare function isModelKey<T extends UniqueModel>(input: ModelOrKey<T>): input is ModelKey;
|
|
223
|
+
/**
|
|
224
|
+
* Throws an error indicating a model key was required but not provided.
|
|
225
|
+
*
|
|
226
|
+
* @throws Error always
|
|
227
|
+
*/
|
|
88
228
|
export declare function throwKeyIsRequired(): void;
|
|
229
|
+
/**
|
|
230
|
+
* Encodes a {@link ModelKeyTypePair} into a single string in the format `type_key`.
|
|
231
|
+
*
|
|
232
|
+
* @param pair - The type/key pair to encode
|
|
233
|
+
* @returns Encoded string representation
|
|
234
|
+
*
|
|
235
|
+
* @example
|
|
236
|
+
* ```ts
|
|
237
|
+
* const encoded = encodeModelKeyTypePair({ type: 'user', key: '123' });
|
|
238
|
+
* // encoded: 'user_123'
|
|
239
|
+
* ```
|
|
240
|
+
*/
|
|
89
241
|
export declare function encodeModelKeyTypePair(pair: ModelKeyTypePair): ModelKey;
|
|
242
|
+
/**
|
|
243
|
+
* Decodes a string in the format `type_key` back into a {@link ModelKeyTypePair}.
|
|
244
|
+
*
|
|
245
|
+
* @param linkKey - Encoded string to decode
|
|
246
|
+
* @returns The decoded type/key pair
|
|
247
|
+
*
|
|
248
|
+
* @example
|
|
249
|
+
* ```ts
|
|
250
|
+
* const pair = decodeModelKeyTypePair('user_123');
|
|
251
|
+
* // pair: { type: 'user', key: '123' }
|
|
252
|
+
* ```
|
|
253
|
+
*/
|
|
90
254
|
export declare function decodeModelKeyTypePair<M extends ModelTypeString = ModelTypeString>(linkKey: ModelKey): ModelKeyTypePair<M>;
|
|
91
255
|
/**
|
|
92
256
|
* A type and data pair.
|
|
@@ -98,4 +262,13 @@ export interface ModelTypeDataPair<T = unknown, M extends ModelTypeString = Mode
|
|
|
98
262
|
* Used for converting the input data into a ModelTypeDataPair value.
|
|
99
263
|
*/
|
|
100
264
|
export type ModelTypeDataPairFactory<T, M extends ModelTypeString = ModelTypeString> = MapFunction<T, ModelTypeDataPair<T, M>>;
|
|
265
|
+
/**
|
|
266
|
+
* Creates a factory function that wraps input data into a {@link ModelTypeDataPair} by reading the type from the data.
|
|
267
|
+
*
|
|
268
|
+
* Falls back to the provided default type if the type reader returns a nullish value.
|
|
269
|
+
*
|
|
270
|
+
* @param typeReader - Function to extract the model type from input data
|
|
271
|
+
* @param defaultType - Fallback type string when the reader returns nullish
|
|
272
|
+
* @returns Factory function that produces ModelTypeDataPair values
|
|
273
|
+
*/
|
|
101
274
|
export declare function modelTypeDataPairFactory<T, M extends ModelTypeString = ModelTypeString>(typeReader: ReadModelTypeFunction<T, M>, defaultType?: string): ModelTypeDataPairFactory<T, M>;
|
|
@@ -10,6 +10,14 @@ export type ModelInputModelModifier<V extends object> = {
|
|
|
10
10
|
};
|
|
11
11
|
export type ModelModifier<V extends object, D extends object> = ModelInputModelModifier<V> & ModelInputDataModifier<D>;
|
|
12
12
|
export type PartialModelModifier<V extends object, D extends object> = Partial<MaybeMap<ModelModifier<V, D>>>;
|
|
13
|
+
/**
|
|
14
|
+
* Merges one or more partial model modifiers into a single {@link PartialModelModifier}.
|
|
15
|
+
*
|
|
16
|
+
* Combines all `modifyData` and `modifyModel` functions from the input modifiers into unified modifier functions.
|
|
17
|
+
*
|
|
18
|
+
* @param input - One or more partial model modifiers to merge
|
|
19
|
+
* @returns A single merged modifier with combined `modifyData` and `modifyModel` functions
|
|
20
|
+
*/
|
|
13
21
|
export declare function maybeMergeModelModifiers<V extends object, D extends object>(input: ArrayOrValue<PartialModelModifier<V, D>>): PartialModelModifier<V, D>;
|
|
14
22
|
export interface ModifyModelMapFunctionsConfig<V extends object, D extends object> {
|
|
15
23
|
readonly mapFunctions: ModelMapFunctions<V, D>;
|
|
@@ -34,13 +42,24 @@ export interface ModifyModelMapFunctionsConfig<V extends object, D extends objec
|
|
|
34
42
|
*/
|
|
35
43
|
readonly copyData?: boolean;
|
|
36
44
|
}
|
|
45
|
+
/**
|
|
46
|
+
* Wraps existing {@link ModelMapFunctions} with modifier functions that are applied to the input before conversion.
|
|
47
|
+
*
|
|
48
|
+
* Optionally copies the input object before modification to avoid mutating the original.
|
|
49
|
+
*
|
|
50
|
+
* @param config - Configuration with the base map functions, modifiers, and copy options
|
|
51
|
+
* @returns New model map functions with modifiers applied before each conversion
|
|
52
|
+
*/
|
|
37
53
|
export declare function modifyModelMapFunctions<V extends object, D extends object>(config: ModifyModelMapFunctionsConfig<V, D>): ModelMapFunctions<V, D>;
|
|
38
54
|
/**
|
|
39
|
-
*
|
|
55
|
+
* Wraps a single {@link ModelMapFunction} with a modifier that is applied to the input before the map function runs.
|
|
56
|
+
*
|
|
57
|
+
* When `copy` is true (default), the input is shallow-copied before modification to avoid mutating the original.
|
|
58
|
+
* If no modifier is provided, the original map function is returned unchanged.
|
|
40
59
|
*
|
|
41
|
-
* @param mapFn
|
|
42
|
-
* @param modifyModel
|
|
43
|
-
* @param copy
|
|
44
|
-
* @returns
|
|
60
|
+
* @param mapFn - The base map function to wrap
|
|
61
|
+
* @param modifyModel - Optional modifier to apply before mapping
|
|
62
|
+
* @param copy - Whether to shallow-copy the input before modifying; defaults to true
|
|
63
|
+
* @returns The wrapped map function, or the original if no modifier is provided
|
|
45
64
|
*/
|
|
46
65
|
export declare function modifyModelMapFunction<I extends object, O extends object>(mapFn: ModelMapFunction<I, O>, modifyModel: Maybe<ModifierFunction<I>>, copy?: boolean): ModelMapFunction<I, O>;
|
|
@@ -3,9 +3,10 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export type ReadableStreamToStringFunction = (stream: NodeJS.ReadableStream) => Promise<string>;
|
|
5
5
|
/**
|
|
6
|
-
* Creates a
|
|
7
|
-
*
|
|
8
|
-
* @
|
|
6
|
+
* Creates a function that reads a Node.js ReadableStream and converts its contents to a string using the specified encoding.
|
|
7
|
+
*
|
|
8
|
+
* @param encoding - The buffer encoding to use (e.g., 'utf-8', 'base64')
|
|
9
|
+
* @returns A function that consumes a ReadableStream and resolves to its string content
|
|
9
10
|
*/
|
|
10
11
|
export declare function readableStreamToStringFunction(encoding: BufferEncoding): ReadableStreamToStringFunction;
|
|
11
12
|
/**
|
|
@@ -13,9 +14,10 @@ export declare function readableStreamToStringFunction(encoding: BufferEncoding)
|
|
|
13
14
|
*/
|
|
14
15
|
export declare const readableStreamToBase64: ReadableStreamToStringFunction;
|
|
15
16
|
/**
|
|
16
|
-
*
|
|
17
|
+
* Reads all data from a Node.js ReadableStream and concatenates it into a single Buffer.
|
|
17
18
|
*
|
|
18
|
-
* @param
|
|
19
|
-
* @returns
|
|
19
|
+
* @param stream - The readable stream to consume
|
|
20
|
+
* @returns Promise resolving to a Buffer containing all stream data
|
|
21
|
+
* @throws Rejects if the stream emits an error event
|
|
20
22
|
*/
|
|
21
23
|
export declare function readableStreamToBuffer(stream: NodeJS.ReadableStream): Promise<Buffer>;
|
|
@@ -19,17 +19,40 @@ export type BitwiseEncodedSet = number;
|
|
|
19
19
|
* Encodes a BitwiseEncodedSet from a set of values.
|
|
20
20
|
*/
|
|
21
21
|
export type BitwiseSetEncoder<D extends BitwiseEncodedSetIndex> = (set: Set<D>) => BitwiseEncodedSet;
|
|
22
|
+
/**
|
|
23
|
+
* Encodes a Set of bit indices into a single {@link BitwiseEncodedSet} number using bitwise OR.
|
|
24
|
+
*
|
|
25
|
+
* @param input - Set of indices (0-31) to encode
|
|
26
|
+
* @returns A number with bits set at each index position
|
|
27
|
+
*/
|
|
22
28
|
export declare function encodeBitwiseSet<D extends BitwiseEncodedSetIndex>(input: Set<D>): BitwiseEncodedSet;
|
|
23
29
|
/**
|
|
24
30
|
* Decodes an BitwiseEncodedSet to a Set of values.
|
|
25
31
|
*/
|
|
26
32
|
export type BitwiseSetDecoder<D extends BitwiseEncodedSetIndex> = (set: BitwiseEncodedSet) => Set<D>;
|
|
33
|
+
/**
|
|
34
|
+
* Creates a decoder that converts a {@link BitwiseEncodedSet} number back into a Set of indices by checking each bit position up to `maxIndex`.
|
|
35
|
+
*
|
|
36
|
+
* @param maxIndex - The exclusive upper bound of indices to check
|
|
37
|
+
* @returns A function that decodes an encoded number into a Set of active indices
|
|
38
|
+
*/
|
|
27
39
|
export declare function bitwiseSetDecoder<D extends BitwiseEncodedSetIndex>(maxIndex: number): BitwiseSetDecoder<D>;
|
|
40
|
+
/**
|
|
41
|
+
* Default decoder that checks all 32 bit positions.
|
|
42
|
+
*/
|
|
28
43
|
export declare const dencodeBitwiseSet: BitwiseSetDecoder<number>;
|
|
29
44
|
/**
|
|
30
45
|
* Encodes and Decodes a BitwiseEncodedSet, depending on the input.
|
|
31
46
|
*/
|
|
32
47
|
export type BitwiseSetDencoder<D extends BitwiseEncodedSetIndex> = BitwiseSetEncoder<D> & BitwiseSetDecoder<D>;
|
|
48
|
+
/**
|
|
49
|
+
* Creates a bidirectional encoder/decoder for {@link BitwiseEncodedSet}.
|
|
50
|
+
*
|
|
51
|
+
* Accepts either a Set (encodes to number) or a number (decodes to Set).
|
|
52
|
+
*
|
|
53
|
+
* @param maxIndex - Optional exclusive upper bound of indices for decoding; defaults to 32
|
|
54
|
+
* @returns A function that encodes Sets to numbers and decodes numbers to Sets
|
|
55
|
+
*/
|
|
33
56
|
export declare function bitwiseSetDencoder<D extends BitwiseEncodedSetIndex>(maxIndex?: number): BitwiseSetDencoder<D>;
|
|
34
57
|
/**
|
|
35
58
|
* Maps the input object to a set of index values.
|
|
@@ -44,16 +67,25 @@ export type BitwiseObjectFromSetFunction<T extends object, D extends BitwiseEnco
|
|
|
44
67
|
*/
|
|
45
68
|
export type BitwiseObjectEncoder<T extends object> = (object: T) => BitwiseEncodedSet;
|
|
46
69
|
/**
|
|
47
|
-
* Creates a BitwiseObjectEncoder
|
|
70
|
+
* Creates a {@link BitwiseObjectEncoder} that converts an object to a {@link BitwiseEncodedSet} number.
|
|
71
|
+
*
|
|
72
|
+
* Uses the provided `toSetFunction` to first map the object to a Set of indices, then encodes it.
|
|
48
73
|
*
|
|
49
|
-
* @param toSetFunction
|
|
50
|
-
* @returns
|
|
74
|
+
* @param toSetFunction - Function that maps an object to a Set of bit indices
|
|
75
|
+
* @returns An encoder function that produces a bitwise-encoded number from the object
|
|
51
76
|
*/
|
|
52
77
|
export declare function bitwiseObjectEncoder<T extends object, D extends BitwiseEncodedSetIndex>(toSetFunction: BitwiseObjectToSetFunction<T, D>): BitwiseObjectEncoder<T>;
|
|
53
78
|
/**
|
|
54
79
|
* Decodes an object from the input BitwiseEncodedSet.
|
|
55
80
|
*/
|
|
56
81
|
export type BitwiseObjectDecoder<T extends object> = (set: BitwiseEncodedSet) => T;
|
|
82
|
+
/**
|
|
83
|
+
* Creates a {@link BitwiseObjectDecoder} that converts a {@link BitwiseEncodedSet} number back into an object.
|
|
84
|
+
*
|
|
85
|
+
* @param fromSetFunction - Function that maps a Set of bit indices back to an object
|
|
86
|
+
* @param maxIndex - Optional exclusive upper bound of indices for decoding; defaults to 32
|
|
87
|
+
* @returns A decoder function that produces an object from a bitwise-encoded number
|
|
88
|
+
*/
|
|
57
89
|
export declare function bitwiseObjectdecoder<T extends object, D extends BitwiseEncodedSetIndex>(fromSetFunction: BitwiseObjectFromSetFunction<T, D>, maxIndex?: number): BitwiseObjectDecoder<T>;
|
|
58
90
|
/**
|
|
59
91
|
* Encodes/Decodes an object.
|
|
@@ -67,4 +99,12 @@ export interface BitwiseObjectDencoderConfig<T extends object, D extends Bitwise
|
|
|
67
99
|
*/
|
|
68
100
|
readonly maxIndex?: number;
|
|
69
101
|
}
|
|
102
|
+
/**
|
|
103
|
+
* Creates a bidirectional {@link BitwiseObjectDencoder} that encodes objects to numbers and decodes numbers back to objects.
|
|
104
|
+
*
|
|
105
|
+
* Accepts either a number (decodes to object) or an object (encodes to number). Returns 0 for null/undefined input.
|
|
106
|
+
*
|
|
107
|
+
* @param config - Configuration with `toSetFunction`, `fromSetFunction`, and optional `maxIndex`
|
|
108
|
+
* @returns A function that encodes objects to numbers and decodes numbers to objects
|
|
109
|
+
*/
|
|
70
110
|
export declare function bitwiseObjectDencoder<T extends object, D extends BitwiseEncodedSetIndex = BitwiseEncodedSetIndex>(config: BitwiseObjectDencoderConfig<T, D>): BitwiseObjectDencoder<T>;
|
|
@@ -9,8 +9,21 @@ export interface NumberBound<T extends number = number> {
|
|
|
9
9
|
*/
|
|
10
10
|
readonly max: T;
|
|
11
11
|
}
|
|
12
|
+
/**
|
|
13
|
+
* Checks whether a {@link NumberBound} is valid (min is less than or equal to max).
|
|
14
|
+
*
|
|
15
|
+
* @param bounds - The bounds to validate
|
|
16
|
+
* @returns `true` if `min <= max`
|
|
17
|
+
*/
|
|
12
18
|
export declare function isValidNumberBound(bounds: NumberBound): boolean;
|
|
13
19
|
export type IsInNumberBoundFunction = (number: number) => boolean;
|
|
20
|
+
/**
|
|
21
|
+
* Creates a function that checks whether a number falls within the specified inclusive bounds.
|
|
22
|
+
*
|
|
23
|
+
* @param bounds - The min/max bounds to test against
|
|
24
|
+
* @returns A function that returns `true` if the input number is within bounds
|
|
25
|
+
* @throws Error if the bounds are invalid (min > max)
|
|
26
|
+
*/
|
|
14
27
|
export declare function isInNumberBoundFunction(bounds: NumberBound): IsInNumberBoundFunction;
|
|
15
28
|
export interface WrapNumberFunctionConfig<T extends number = number> extends NumberBound<T> {
|
|
16
29
|
/**
|
|
@@ -23,6 +36,14 @@ export interface WrapNumberFunctionConfig<T extends number = number> extends Num
|
|
|
23
36
|
export type WrapNumberFunction<T extends number = number> = MapFunction<number, T> & {
|
|
24
37
|
readonly _wrap: WrapNumberFunctionConfig;
|
|
25
38
|
};
|
|
39
|
+
/**
|
|
40
|
+
* Creates a function that wraps numbers around within the specified bounds, like modular arithmetic.
|
|
41
|
+
*
|
|
42
|
+
* When `fencePosts` is true, wraps to the nearest "fence post" value, extending the wrap range by one in each direction.
|
|
43
|
+
*
|
|
44
|
+
* @param wrapNumberFunctionConfig - Configuration with min, max, and optional fence post behavior
|
|
45
|
+
* @returns A function that wraps input numbers into the bounded range
|
|
46
|
+
*/
|
|
26
47
|
export declare function wrapNumberFunction<T extends number = number>(wrapNumberFunctionConfig: WrapNumberFunctionConfig<T>): WrapNumberFunction<T>;
|
|
27
48
|
export interface BoundNumberFunctionConfig<T extends number = number> extends NumberBound<T> {
|
|
28
49
|
/**
|
|
@@ -33,13 +54,21 @@ export interface BoundNumberFunctionConfig<T extends number = number> extends Nu
|
|
|
33
54
|
readonly wrap?: boolean;
|
|
34
55
|
}
|
|
35
56
|
export type BoundNumberFunction<T extends number = number> = MapFunction<number, T>;
|
|
57
|
+
/**
|
|
58
|
+
* Creates a function that constrains numbers within bounds, either by clamping or wrapping.
|
|
59
|
+
*
|
|
60
|
+
* When `wrap` is true, uses modular wrapping. Otherwise, clamps values to the min/max range.
|
|
61
|
+
*
|
|
62
|
+
* @param boundNumberFunctionConfig - Configuration with min, max, and optional wrap behavior
|
|
63
|
+
* @returns A function that bounds input numbers into the configured range
|
|
64
|
+
*/
|
|
36
65
|
export declare function boundNumberFunction<T extends number = number>(boundNumberFunctionConfig: BoundNumberFunctionConfig<T>): BoundNumberFunction<T>;
|
|
37
66
|
/**
|
|
38
|
-
*
|
|
67
|
+
* Clamps the input number between the min and max values (inclusive).
|
|
39
68
|
*
|
|
40
|
-
* @param input
|
|
41
|
-
* @param min
|
|
42
|
-
* @param max
|
|
43
|
-
* @returns
|
|
69
|
+
* @param input - Number to clamp
|
|
70
|
+
* @param min - Minimum allowed value
|
|
71
|
+
* @param max - Maximum allowed value
|
|
72
|
+
* @returns The clamped value
|
|
44
73
|
*/
|
|
45
74
|
export declare function boundNumber<T extends number = number>(input: number, min: T, max: T): T;
|
|
@@ -32,18 +32,19 @@ export declare const DOLLAR_AMOUNT_STRING_REGEX: RegExp;
|
|
|
32
32
|
*/
|
|
33
33
|
export declare const DOLLAR_AMOUNT_PRECISION = 2;
|
|
34
34
|
/**
|
|
35
|
-
*
|
|
35
|
+
* Checks whether the input string matches the expected dollar amount format (e.g., "12.50" or "$12.50").
|
|
36
36
|
*
|
|
37
|
-
* @param value
|
|
38
|
-
* @returns
|
|
37
|
+
* @param value - String to test
|
|
38
|
+
* @returns `true` if the string matches the dollar amount regex
|
|
39
39
|
*/
|
|
40
40
|
export declare function isDollarAmountString(value: string): boolean;
|
|
41
41
|
/**
|
|
42
|
-
*
|
|
42
|
+
* Formats a number as a dollar amount string with exactly two decimal places.
|
|
43
43
|
*
|
|
44
|
-
*
|
|
44
|
+
* Truncates (does not round) excess precision: e.g., 1.115 becomes "1.11". Returns "0.00" for null/undefined.
|
|
45
45
|
*
|
|
46
|
-
* @param number
|
|
46
|
+
* @param number - The dollar amount to format
|
|
47
|
+
* @returns Formatted string with two decimal places (e.g., "12.50")
|
|
47
48
|
*/
|
|
48
49
|
export declare function dollarAmountString(number: Maybe<number>): string;
|
|
49
50
|
/**
|
|
@@ -55,4 +56,10 @@ export declare function dollarAmountString(number: Maybe<number>): string;
|
|
|
55
56
|
export type DollarAmountStringWithUnitFunction<U extends DollarAmountUnit> = ((amount: DollarAmount) => DollarAmountStringWithUnit<U>) & {
|
|
56
57
|
readonly unit: U;
|
|
57
58
|
};
|
|
59
|
+
/**
|
|
60
|
+
* Creates a function that formats dollar amounts as strings with a unit prefix (e.g., "$12.50").
|
|
61
|
+
*
|
|
62
|
+
* @param unit - The unit prefix to prepend; defaults to "$"
|
|
63
|
+
* @returns A function that formats dollar amounts with the configured unit
|
|
64
|
+
*/
|
|
58
65
|
export declare function dollarAmountStringWithUnitFunction<U extends DollarAmountUnit>(unit?: U): DollarAmountStringWithUnitFunction<U>;
|
|
@@ -14,9 +14,17 @@ export interface IncrementingNumberFactoryConfig {
|
|
|
14
14
|
increaseBy?: GetterOrValue<number>;
|
|
15
15
|
}
|
|
16
16
|
/**
|
|
17
|
-
* Creates a factory that returns increasing numbers.
|
|
17
|
+
* Creates a factory that returns sequentially increasing numbers, starting from a configurable value and incrementing by a configurable step.
|
|
18
18
|
*
|
|
19
|
-
* @param config
|
|
20
|
-
* @returns
|
|
19
|
+
* @param config - Configuration with optional `startAt` (default 0) and `increaseBy` (default 1)
|
|
20
|
+
* @returns A factory function that returns the next number in the sequence on each call
|
|
21
|
+
*
|
|
22
|
+
* @example
|
|
23
|
+
* ```ts
|
|
24
|
+
* const factory = incrementingNumberFactory({ startAt: 10, increaseBy: 5 });
|
|
25
|
+
* factory(); // 10
|
|
26
|
+
* factory(); // 15
|
|
27
|
+
* factory(); // 20
|
|
28
|
+
* ```
|
|
21
29
|
*/
|
|
22
30
|
export declare function incrementingNumberFactory(config?: IncrementingNumberFactoryConfig): NumberFactory;
|
|
@@ -18,12 +18,22 @@ export type PercentNumber = number;
|
|
|
18
18
|
*/
|
|
19
19
|
export type PercentDecimal = number;
|
|
20
20
|
/**
|
|
21
|
-
* Converts
|
|
21
|
+
* Converts a {@link PercentNumber} (e.g., 5 for 5%) to its decimal equivalent (e.g., 0.05).
|
|
22
22
|
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
23
|
+
* Returns 0 for null/undefined input.
|
|
24
|
+
*
|
|
25
|
+
* @param input - A percent number value (e.g., 5 means 5%)
|
|
26
|
+
* @returns The decimal equivalent
|
|
25
27
|
*/
|
|
26
28
|
export declare function percentNumberToDecimal(input: Maybe<number>): number;
|
|
29
|
+
/**
|
|
30
|
+
* Converts a {@link PercentDecimal} (e.g., 0.05 for 5%) to its {@link PercentNumber} equivalent (e.g., 5).
|
|
31
|
+
*
|
|
32
|
+
* Returns 0 for null/undefined input.
|
|
33
|
+
*
|
|
34
|
+
* @param input - A decimal percent value (e.g., 0.05 means 5%)
|
|
35
|
+
* @returns The percent number equivalent
|
|
36
|
+
*/
|
|
27
37
|
export declare function percentNumberFromDecimal(input: Maybe<number>): PercentNumber;
|
|
28
38
|
export type NumberOrNumberString = number | NumberString;
|
|
29
39
|
/**
|
|
@@ -35,17 +45,22 @@ export type ReadNumberFunction<T, N extends number = number> = MapFunction<T, N>
|
|
|
35
45
|
*/
|
|
36
46
|
export type AsNumberInput = Maybe<NumberOrNumberString>;
|
|
37
47
|
/**
|
|
38
|
-
* Converts
|
|
48
|
+
* Converts a number, string, or null/undefined value to a number.
|
|
39
49
|
*
|
|
40
|
-
*
|
|
50
|
+
* Strings are parsed via `Number()`. Null/undefined returns 0.
|
|
51
|
+
*
|
|
52
|
+
* @param input - A number, number string, or null/undefined
|
|
53
|
+
* @returns The numeric value, or 0 for null/undefined
|
|
41
54
|
*/
|
|
42
55
|
export declare function asNumber(input: AsNumberInput): number;
|
|
43
56
|
/**
|
|
44
|
-
*
|
|
57
|
+
* Checks whether the input value is evenly divisible by the divisor.
|
|
58
|
+
*
|
|
59
|
+
* Treats null/undefined as 0.
|
|
45
60
|
*
|
|
46
|
-
* @param value
|
|
47
|
-
* @param divisor
|
|
48
|
-
* @returns
|
|
61
|
+
* @param value - The number to check
|
|
62
|
+
* @param divisor - The divisor to test against
|
|
63
|
+
* @returns `true` if the remainder is zero
|
|
49
64
|
*/
|
|
50
65
|
export declare function isNumberDivisibleBy(value: Maybe<number>, divisor: number): boolean;
|
|
51
66
|
export interface NearestDivisibleValues {
|
|
@@ -55,51 +70,59 @@ export interface NearestDivisibleValues {
|
|
|
55
70
|
nearestFloor: number;
|
|
56
71
|
}
|
|
57
72
|
/**
|
|
58
|
-
*
|
|
73
|
+
* Finds the nearest values that are evenly divisible by the divisor, both above (ceil) and below (floor) the input value.
|
|
59
74
|
*
|
|
60
|
-
* @param value
|
|
61
|
-
* @param divisor
|
|
62
|
-
* @returns
|
|
75
|
+
* @param value - The value to find divisible neighbors for
|
|
76
|
+
* @param divisor - The divisor to align to
|
|
77
|
+
* @returns Object with the input value, divisor, and the nearest ceil/floor divisible values
|
|
63
78
|
*/
|
|
64
79
|
export declare function nearestDivisibleValues(value: number, divisor: number): NearestDivisibleValues;
|
|
65
80
|
/**
|
|
66
|
-
*
|
|
81
|
+
* Checks whether the input is an even number.
|
|
67
82
|
*
|
|
68
|
-
* @param value
|
|
69
|
-
* @returns
|
|
83
|
+
* @param value - Number to test
|
|
84
|
+
* @returns `true` if even
|
|
70
85
|
*/
|
|
71
86
|
export declare function isEvenNumber(value: number): boolean;
|
|
72
87
|
/**
|
|
73
|
-
*
|
|
88
|
+
* Checks whether the input is an odd number.
|
|
74
89
|
*
|
|
75
|
-
* @param value
|
|
76
|
-
* @returns
|
|
90
|
+
* @param value - Number to test
|
|
91
|
+
* @returns `true` if odd
|
|
77
92
|
*/
|
|
78
93
|
export declare function isOddNumber(value: number): boolean;
|
|
79
94
|
/**
|
|
80
|
-
*
|
|
95
|
+
* Computes the sum of all integers between two values, inclusive, using Gauss's formula.
|
|
96
|
+
*
|
|
97
|
+
* The `from` value is floored and the `to` value is ceiled before computation.
|
|
81
98
|
*
|
|
82
|
-
* @param from
|
|
83
|
-
* @param to
|
|
99
|
+
* @param from - The starting value (floored to nearest integer)
|
|
100
|
+
* @param to - The ending value (ceiled to nearest integer)
|
|
101
|
+
* @returns Sum of all integers in the range
|
|
84
102
|
*/
|
|
85
103
|
export declare function sumOfIntegersBetween(from: number, to: number): number;
|
|
104
|
+
/**
|
|
105
|
+
* A {@link SortCompareFunction} for numbers that sorts in ascending order.
|
|
106
|
+
*/
|
|
86
107
|
export declare const sortCompareNumberFunction: SortCompareFunction<number>;
|
|
87
108
|
/**
|
|
88
|
-
*
|
|
109
|
+
* Finds the minimum and maximum values from an iterable of numbers.
|
|
89
110
|
*
|
|
90
|
-
* @param values
|
|
91
|
-
* @returns
|
|
111
|
+
* @param values - Iterable of numbers to examine
|
|
112
|
+
* @returns Object with `min` and `max` values
|
|
92
113
|
*/
|
|
93
114
|
export declare function minAndMaxNumber(values: Iterable<number>): MinAndMaxFunctionResult<number>;
|
|
94
115
|
/**
|
|
95
|
-
*
|
|
116
|
+
* Computes the logarithm of `y` with base `x`.
|
|
96
117
|
*
|
|
97
|
-
*
|
|
98
|
-
*
|
|
99
|
-
*
|
|
118
|
+
* @param x - The base of the logarithm
|
|
119
|
+
* @param y - The value to compute the logarithm of
|
|
120
|
+
* @returns The base-x logarithm of y
|
|
100
121
|
*
|
|
101
|
-
* @
|
|
102
|
-
*
|
|
103
|
-
*
|
|
122
|
+
* @example
|
|
123
|
+
* ```ts
|
|
124
|
+
* getBaseLog(2, 16); // 4 (2^4 = 16)
|
|
125
|
+
* getBaseLog(10, 100); // 2 (10^2 = 100)
|
|
126
|
+
* ```
|
|
104
127
|
*/
|
|
105
128
|
export declare function getBaseLog(x: number, y: number): number;
|