@danielsimonjr/mathts-functions 0.42.0 → 0.43.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.
@@ -1 +1 @@
1
- {"version":3,"file":"arithmetic.d.ts","sourceRoot":"","sources":["../../src/typed/arithmetic.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AAeH,OAAO,EAAe,WAAW,EAAE,MAAM,gCAAgC,CAAC;AAU1E,4BAA4B;AAC5B,KAAK,GAAG,GAAG,MAAM,CAAC;AAkIlB;;;;;;;;;;;;;GAaG;AACH,eAAO,MAAM,GAAG,wCAgEd,CAAC;AAMH;;GAEG;AACH,eAAO,MAAM,QAAQ,wCAiCnB,CAAC;AAMH;;GAEG;AACH,eAAO,MAAM,QAAQ,wCA8FnB,CAAC;AAMH;;GAEG;AACH,eAAO,MAAM,MAAM,wCAkCjB,CAAC;AAMH;;GAEG;AACH,eAAO,MAAM,UAAU,wCAYrB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,SAAS,wCAOpB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,GAAG,wCAgBd,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,IAAI,wCAqBf,CAAC;AAMH;;GAEG;AACH,eAAO,MAAM,GAAG,wCA2Cd,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,IAAI,wCAgBf,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,MAAM,wCAajB,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,IAAI,wCAkBf,CAAC;AAaH;;GAEG;AACH,eAAO,MAAM,IAAI,wCA4Bf,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,OAAO,wCAIlB,CAAC;AAMH;;GAEG;AACH,eAAO,MAAM,GAAG,wCAad,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,GAAG,wCAcd,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,KAAK,wCAiBhB,CAAC;AAEH;;GAEG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-8,7 +8,7 @@
8
8
  * - Use the `ComputePool` for ALL `Int32Array` transformations.
9
9
  * - Use native ops on scalar inputs (no worker dispatch overhead).
10
10
  *
11
- * BigNumber bitwise semantics: the mathjs-synced helpers in
11
+ * BigNumber bitwise semantics: the mathjs-derived helpers in
12
12
  * `functions/src/utils/bignumber/bitwise.ts` operate on the
13
13
  * `decimal.js`-internal coefficient layout (`x.d` / `x.e` / `x.s`),
14
14
  * which `@danielsimonjr/mathts-core`'s `BigNumber` does not expose.
@@ -1,13 +1,13 @@
1
1
  /**
2
2
  * Typed Probability & Combinatorics Functions
3
3
  *
4
- * Promotes genuinely-missing exports from the synced `probability/` layer that
4
+ * Promotes genuinely-missing exports from the activated `probability/` layer that
5
5
  * are not already surfaced by `typed/distributions.ts` (PDF/PMF/CDF/entropy) or
6
6
  * `typed/special.ts` (erf, beta, bessel, …).
7
7
  *
8
8
  * After dedup audit (2026-05-24):
9
9
  *
10
- * | Synced name | Promote? | Existing surface (if any) | Rationale |
10
+ * | mathjs name | Promote? | Existing surface (if any) | Rationale |
11
11
  * | ------------------ | -------- | ---------------------------------------------- | ------------------------------------------------ |
12
12
  * | bernoulli | YES | — | genuinely missing (bernoulliPMF ≠ Bernoulli number) |
13
13
  * | combinations | YES | — | genuinely missing |
@@ -4,9 +4,9 @@
4
4
  * Polymorphic relational operations using typed-function for runtime dispatch.
5
5
  * Supports number, BigNumber, Fraction, Complex, bigint, boolean, string, and Array types.
6
6
  *
7
- * These are clean implementations using mathTyped dispatch — the dormant synced
8
- * layer under functions/src/relational/ is left untouched and used only as an
9
- * algorithm reference.
7
+ * These are clean implementations using mathTyped dispatch — the activated
8
+ * mathjs-derived layer under functions/src/relational/ is left untouched here
9
+ * and used only as an algorithm reference.
10
10
  *
11
11
  * Semantics follow the mathjs convention:
12
12
  * - nearlyEqual tolerance uses DEFAULT_CONFIG.relTol / absTol.
@@ -4,9 +4,9 @@
4
4
  * Polymorphic string-formatting operations using typed-function for runtime dispatch.
5
5
  * Supports `number`, `BigNumber`, and `string` types as appropriate for each op.
6
6
  *
7
- * These are clean implementations using mathTyped dispatch — the dormant synced
8
- * layer under functions/src/string/ is left untouched and used only as an
9
- * algorithm reference.
7
+ * These are clean implementations using mathTyped dispatch — the activated
8
+ * mathjs-derived layer under functions/src/string/ is left untouched here
9
+ * and used only as an algorithm reference.
10
10
  *
11
11
  * Semantics follow the mathjs convention:
12
12
  * - bin/hex/oct: sign-magnitude representation for negative numbers (NOT two's-complement),
@@ -1,6 +1,6 @@
1
1
  /**
2
2
  * Initialize the type bridge for mathjs factory compatibility.
3
- * Call once before using any synced mathjs factories.
3
+ * Call once before using any activated mathjs-derived factories.
4
4
  */
5
5
  export declare function initTypeBridge(): void;
6
6
  //# sourceMappingURL=typed-bridge.d.ts.map
@@ -1,242 +1,25 @@
1
- import { Index, Matrix } from './is.js';
2
- export type NestedArray<T> = T | NestedArray<T>[];
3
- export interface IdentifiedValue<T> {
4
- value: T;
5
- identifier: number;
6
- }
7
1
  /**
8
- * Calculate the size of a multi dimensional array.
9
- * This function checks the size of the first entry, it does not validate
10
- * whether all dimensions match. (use function `validate` for that)
11
- * @param {Array} x
12
- * @return {number[]} size
13
- */
14
- export declare function arraySize<T>(x: NestedArray<T>): number[];
15
- /**
16
- * Validate whether each element in a multi dimensional array has
17
- * a size corresponding to the provided size array.
18
- * @param {Array} array Array to be validated
19
- * @param {number[]} size Array with the size of each dimension
20
- * @throws DimensionError
21
- */
22
- export declare function validate<T>(array: NestedArray<T>, size: number[]): void;
23
- /**
24
- * Validate whether the source of the index matches the size of the Array
25
- * @param {Array | Matrix} value Array to be validated
26
- * @param {Index} index Index with the source information to validate
27
- * @throws DimensionError
28
- */
29
- export declare function validateIndexSourceSize(value: unknown[] | Matrix, index: Index): void;
30
- /**
31
- * Test whether index is an integer number with index >= 0 and index < length
32
- * when length is provided
33
- * @param {number} index Zero-based index
34
- * @param {number} [length] Length of the array
35
- */
36
- export declare function validateIndex(index: number | undefined, length?: number): void;
37
- /**
38
- * Test if an index has empty values
39
- * @param {Index} index Zero-based index
40
- */
41
- export declare function isEmptyIndex(index: Index): boolean;
42
- /**
43
- * Resize a multi dimensional array. The resized array is returned.
44
- * @param {Array | number} array Array to be resized
45
- * @param {number[]} size Array with the size of each dimension
46
- * @param {*} [defaultValue=0] Value to be filled in new entries,
47
- * zero by default. Specify for example `null`,
48
- * to clearly see entries that are not explicitly
49
- * set.
50
- * @return {Array} array The resized array
51
- */
52
- export declare function resize<T = unknown>(array: T | T[] | NestedArray<T>, size: number[], defaultValue?: T): NestedArray<T>;
53
- /**
54
- * Re-shape a multi dimensional array to fit the specified dimensions
55
- * @param {Array} array Array to be reshaped
56
- * @param {number[]} sizes List of sizes for each dimension
57
- * @returns {Array} Array whose data has been formatted to fit the
58
- * specified dimensions
2
+ * Cold array utilities (size/validate/reshape/resize/squeeze/broadcast/deepMap/
3
+ * deepForEach/clone/...).
59
4
  *
60
- * @throws {DimensionError} If the product of the new dimension sizes does
61
- * not equal that of the old ones
62
- */
63
- export declare function reshape<T = unknown>(array: NestedArray<T>, sizes: number[]): NestedArray<T>;
64
- /**
65
- * Replaces the wildcard -1 in the sizes array.
66
- * @param {number[]} sizes List of sizes for each dimension. At most one wildcard.
67
- * @param {number} currentLength Number of elements in the array.
68
- * @throws {Error} If more than one wildcard or unable to replace it.
69
- * @returns {number[]} The sizes array with wildcard replaced.
70
- */
71
- export declare function processSizesWildcard(sizes: number[], currentLength: number): number[];
72
- /**
73
- * Squeeze a multi dimensional array
74
- * @param {Array} array
75
- * @param {Array} [size]
76
- * @returns {Array} returns the array itself
77
- */
78
- export declare function squeeze<T>(array: NestedArray<T>, size?: number[]): T | NestedArray<T>;
79
- /**
80
- * Unsqueeze a multi dimensional array: add dimensions when missing
5
+ * Consolidated onto core: the implementation lives once in
6
+ * `@danielsimonjr/mathts-core/internal` (see `core/src/array.ts` and the
7
+ * `project-all-libraries-build-on-core` principle). Thin re-export so existing
8
+ * `../utils/array.js` imports keep working while the single source of truth lives
9
+ * in core. Proven equivalent to the prior local copy (and to `expression`'s copy)
10
+ * via a fast-check property harness before the redirect — see
11
+ * `functions/tests/dedup-bucketB-equivalence.test.ts`.
81
12
  *
82
- * Parameter `size` will be mutated to match the new, unsqueezed matrix size.
13
+ * This package never had `initial` (unlike `expression`'s prior copy, where it was
14
+ * dead code even there), so it is intentionally not re-exported here — this shim
15
+ * preserves exactly the original export surface.
83
16
  *
84
- * @param {Array} array
85
- * @param {number} dims Desired number of dimensions of the array
86
- * @param {number} [outer] Number of outer dimensions to be added
87
- * @param {Array} [size] Current size of array.
88
- * @returns {Array} returns the array itself
89
- * @private
90
- */
91
- export declare function unsqueeze<T>(array: NestedArray<T>, dims: number, outer?: number, size?: number[]): NestedArray<T>;
92
- /**
93
- * Flatten a multi dimensional array, put all elements in a one dimensional
94
- * array
95
- * @param {Array} array A multi dimensional array
96
- * @param {boolean} isRectangular Optional. If the array is rectangular (not jagged)
97
- * @return {Array} The flattened array (1 dimensional)
98
- */
99
- export declare function flatten<T>(array: NestedArray<T>, isRectangular?: boolean): T[];
100
- /**
101
- * A safe map
102
- * @param {Array} array
103
- * @param {function} callback
104
- */
105
- export declare function map<T, U>(array: T[], callback: (value: T, index: number, array: T[]) => U): U[];
106
- /**
107
- * A safe forEach
108
- * @param {Array} array
109
- * @param {function} callback
110
- */
111
- export declare function forEach<T>(array: T[], callback: (value: T, index: number, array: T[]) => void): void;
112
- /**
113
- * A safe filter
114
- * @param {Array} array
115
- * @param {function} callback
116
- */
117
- export declare function filter<T>(array: T[], callback: (value: T, index: number, array: T[]) => boolean): T[];
118
- /**
119
- * Filter values in an array given a regular expression
120
- * @param {Array} array
121
- * @param {RegExp} regexp
122
- * @return {Array} Returns the filtered array
123
- * @private
124
- */
125
- export declare function filterRegExp(array: string[], regexp: RegExp): string[];
126
- /**
127
- * A safe join
128
- * @param {Array} array
129
- * @param {string} separator
130
- */
131
- export declare function join<T>(array: T[], separator: string): string;
132
- /**
133
- * Assign a numeric identifier to every element of a sorted array
134
- * @param {Array} a An array
135
- * @return {Array} An array of objects containing the original value and its identifier
136
- */
137
- export declare function identify<T>(a: T[]): IdentifiedValue<T>[];
138
- /**
139
- * Remove the numeric identifier from the elements
140
- * @param {array} a An array
141
- * @return {array} An array of values without identifiers
142
- */
143
- export declare function generalize<T>(a: IdentifiedValue<T>[]): T[];
144
- /**
145
- * Check the datatype of a given object
146
- * This is a low level implementation that should only be used by
147
- * parent Matrix classes such as SparseMatrix or DenseMatrix
148
- * This method does not validate Array Matrix shape
149
- * @param {Array} array
150
- * @param {function} typeOf Callback function to use to determine the type of a value
151
- * @return {string}
152
- */
153
- export declare function getArrayDataType(array: unknown[], typeOf: (value: unknown) => string): string | undefined;
154
- /**
155
- * Return the last item from an array
156
- * @param {Array} array
157
- * @returns {*}
158
- */
159
- export declare function last<T>(array: T[]): T;
160
- /**
161
- * Concatenates many arrays in the specified direction
162
- * @param {...Array} arrays All the arrays to concatenate
163
- * @param {number} concatDim The dimension on which to concatenate (zero-based)
164
- * @returns {Array}
165
- */
166
- export declare function concat<T>(...args: [...NestedArray<T>[], number]): NestedArray<T>[];
167
- /**
168
- * Receives two or more sizes and gets the broadcasted size for both.
169
- * @param {...number[]} sizes Sizes to broadcast together
170
- * @returns {number[]} The broadcasted size
171
- */
172
- export declare function broadcastSizes(...sizes: number[][]): number[];
173
- /**
174
- * Checks if it's possible to broadcast a size to another size
175
- * @param {number[]} size The size of the array to check
176
- * @param {number[]} toSize The size of the array to validate if it can be broadcasted to
177
- */
178
- export declare function checkBroadcastingRules(size: number[], toSize: number[]): void;
179
- /**
180
- * Broadcasts a single array to a certain size
181
- * @param {Array} array Array to be broadcasted
182
- * @param {number[]} toSize Size to broadcast the array
183
- * @returns {Array} The broadcasted array
184
- */
185
- export declare function broadcastTo<T>(array: NestedArray<T>, toSize: number[]): NestedArray<T>;
186
- /**
187
- * Broadcasts arrays and returns the broadcasted arrays in an array
188
- * @param {...Array | any} arrays
189
- * @returns {Array[]} The broadcasted arrays
190
- */
191
- export declare function broadcastArrays<T>(...arrays: NestedArray<T>[]): NestedArray<T>[];
192
- /**
193
- * Stretches a matrix up to a certain size in a certain dimension
194
- * @param {Array} arrayToStretch
195
- * @param {number[]} sizeToStretch
196
- * @param {number} dimToStretch
197
- * @returns {Array} The stretched array
198
- */
199
- export declare function stretch<T>(arrayToStretch: NestedArray<T>, sizeToStretch: number, dimToStretch: number): NestedArray<T>;
200
- /**
201
- * Retrieves a single element from an array given an index.
202
- *
203
- * @param {Array} array - The array from which to retrieve the value.
204
- * @param {Array<number>} index - An array of indices specifying the position of the desired element in each dimension.
205
- * @returns {*} - The value at the specified position in the array.
206
- *
207
- * @example
208
- * const arr = [[[1, 2], [3, 4]], [[5, 6], [7, 8]]];
209
- * const index = [1, 0, 1];
210
- * console.log(get(arr, index)); // 6
211
- */
212
- export declare function get<T>(array: NestedArray<T>, index: number[]): T;
213
- /**
214
- * Recursively maps over each element of nested array using a provided callback function.
215
- *
216
- * @param {Array} array - The array to be mapped.
217
- * @param {Function} callback - The function to execute on each element, taking three arguments:
218
- * - `value` (any): The current element being processed in the array.
219
- * - `index` (Array<number>): The index of the current element being processed in the array.
220
- * - `array` (Array): The array `deepMap` was called upon.
221
- * @param {boolean} [skipIndex=false] - If true, the callback function is called with only the value.
222
- * @returns {Array} A new array with each element being the result of the callback function.
223
- */
224
- export declare function deepMap<T, U>(array: NestedArray<T>, callback: ((value: T, index: number[], array: NestedArray<T>) => U) | ((value: T) => U), skipIndex?: boolean): NestedArray<U>;
225
- /**
226
- * Recursively iterates over each element in a multi-dimensional array and applies a callback function.
227
- *
228
- * @param {Array} array - The multi-dimensional array to iterate over.
229
- * @param {Function} callback - The function to execute for each element. It receives three arguments:
230
- * - {any} value: The current element being processed in the array.
231
- * - {Array<number>} index: The index of the current element in each dimension.
232
- * - {Array} array: The original array being processed.
233
- * @param {boolean} [skipIndex=false] - If true, the callback function is called with only the value.
234
- */
235
- export declare function deepForEach<T>(array: NestedArray<T>, callback: ((value: T, index: number[], array: NestedArray<T>) => void) | ((value: T) => void), skipIndex?: boolean): void;
236
- /**
237
- * Deep clones a multidimensional array
238
- * @param {Array} array
239
- * @returns {Array} cloned array
240
- */
241
- export declare function clone<T>(array: T[]): T[];
17
+ * core re-exports this file's `clone`/`get`/`deepMap`/`deepForEach` under aliased
18
+ * names (`cloneArray`/`getArrayElement`/`deepMapArray`/`deepForEachArray`) to avoid
19
+ * collisions with `object.ts`'s generic `clone`/`get` and `collection.ts`'s
20
+ * Matrix-aware `deepMap`/`deepForEach` in its own barrel — re-imported here under
21
+ * THIS file's original local names.
22
+ */
23
+ export type { NestedArray, IdentifiedValue } from '@danielsimonjr/mathts-core/internal';
24
+ export { arraySize, validate, validateIndexSourceSize, validateIndex, isEmptyIndex, resize, reshape, processSizesWildcard, squeeze, unsqueeze, flatten, map, forEach, filter, filterRegExp, join, identify, generalize, getArrayDataType, last, concat, broadcastSizes, checkBroadcastingRules, broadcastTo, broadcastArrays, stretch, getArrayElement as get, deepMapArray as deepMap, deepForEachArray as deepForEach, cloneArray as clone, } from '@danielsimonjr/mathts-core/internal';
242
25
  //# sourceMappingURL=array.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"array.d.ts","sourceRoot":"","sources":["../../src/utils/array.ts"],"names":[],"mappings":"AACA,OAAO,EAA4C,KAAK,EAAE,MAAM,EAAkB,MAAM,SAAS,CAAC;AAOlG,MAAM,MAAM,WAAW,CAAC,CAAC,IAAI,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,EAAE,CAAC;AAGlD,MAAM,WAAW,eAAe,CAAC,CAAC;IAChC,KAAK,EAAE,CAAC,CAAC;IACT,UAAU,EAAE,MAAM,CAAC;CACpB;AAED;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,CAAC,EAAE,CAAC,EAAE,WAAW,CAAC,CAAC,CAAC,GAAG,MAAM,EAAE,CAUxD;AAuCD;;;;;;GAMG;AACH,wBAAgB,QAAQ,CAAC,CAAC,EAAE,K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ACpB,OAAO,EACP,SAAS,EACT,OAAO,EACP,GAAG,EACH,OAAO,EACP,MAAM,EACN,YAAY,EACZ,IAAI,EACJ,QAAQ,EACR,UAAU,EACV,gBAAgB,EAChB,IAAI,EACJ,MAAM,EACN,cAAc,EACd,sBAAsB,EACtB,WAAW,EACX,eAAe,EACf,OAAO,EACP,eAAe,IAAI,GAAG,EACtB,YAAY,IAAI,OAAO,EACvB,gBAAgB,IAAI,WAAW,EAC/B,UAAU,IAAI,KAAK,GACpB,MAAM,qCAAqC,CAAC"}
@@ -1,67 +1,15 @@
1
- interface Matrix<T = unknown> {
2
- forEach(callback: (value: T) => void, skipZeros: boolean, recurse: boolean): void;
3
- map<U>(callback: (value: T) => U, skipZeros: boolean, recurse: boolean): Matrix<U>;
4
- size(): number[];
5
- valueOf(): T[];
6
- create(data: T[], datatype?: string): Matrix<T>;
7
- datatype(): string | undefined;
8
- }
9
- interface SparseMatrix<T = unknown> {
10
- _values: T[];
11
- _index: number[];
12
- _ptr: number[];
13
- }
14
1
  /**
15
- * Test whether an array contains collections
16
- * @param array - Array to test
17
- * @returns Returns true when the array contains one or multiple
18
- * collections (Arrays or Matrices). Returns false otherwise.
19
- */
20
- export declare function containsCollections(array: unknown[]): boolean;
21
- /**
22
- * Recursively loop over all elements in a given multi dimensional array
23
- * and invoke the callback on each of the elements.
24
- * @param array - Array or Matrix to iterate over
25
- * @param callback - The callback method is invoked with one parameter: the current element in the array
26
- */
27
- export declare function deepForEach<T>(array: T[] | Matrix<T>, callback: (value: T) => void): void;
28
- /**
29
- * Execute the callback function element wise for each element in array and any
30
- * nested array
31
- * Returns an array with the results
32
- * @param array - Array or Matrix to map over
33
- * @param callback - The callback is called with two parameters:
34
- * value1 and value2, which contain the current
35
- * element of both arrays.
36
- * @param skipZeros - Invoke callback function for non-zero values only.
2
+ * Cold array/Matrix-aware collection utilities (`deepMap`/`deepForEach` with
3
+ * Matrix-or-array dispatch, dimensional `reduce`, sparse-matrix `scatter`).
37
4
  *
38
- * @return Mapped result
39
- */
40
- export declare function deepMap<T, U>(array: T[] | Matrix<T>, callback: (value: T) => U, skipZeros?: boolean): U[] | Matrix<U>;
41
- /**
42
- * Reduce a given matrix or array to a new matrix or
43
- * array with one less dimension, applying the given
44
- * callback in the selected dimension.
45
- * @param mat - Array or Matrix to reduce
46
- * @param dim - Dimension to reduce
47
- * @param callback - Callback function
48
- * @return Reduced result
49
- */
50
- export declare function reduce<T, U>(mat: T[] | Matrix<T>, dim: number, callback: (acc: U | T, val: T) => U): U[] | Matrix<U>;
51
- /**
52
- * Scatter function for sparse matrix operations
53
- * @param a - Sparse matrix
54
- * @param j - Column index
55
- * @param w - Work array for marking visited rows
56
- * @param x - Work array for storing values
57
- * @param u - Work array for marking updated rows
58
- * @param mark - Current mark value
59
- * @param cindex - Column index array to update
60
- * @param f - Binary function to apply
61
- * @param inverse - Whether to inverse the function arguments
62
- * @param update - Whether to update existing values
63
- * @param value - Value to use in binary function
64
- */
65
- export declare function scatter<T>(a: SparseMatrix<T>, j: number, w: number[], x: T[] | null, u: number[], mark: number, cindex: number[], f?: (a: T, b: T) => T, inverse?: boolean, update?: boolean, value?: T): void;
66
- export {};
5
+ * Consolidated onto core: the implementation lives once in
6
+ * `@danielsimonjr/mathts-core/internal` (see `core/src/collection.ts` and the
7
+ * `project-all-libraries-build-on-core` principle). Thin re-export so existing
8
+ * `../utils/collection.js` imports keep working while the single source of truth
9
+ * lives in core. Proven equivalent to the prior local copy (and to `expression`'s
10
+ * copy the two were already functionally IDENTICAL, differing only in comments
11
+ * and one redundant cast) via a fast-check property harness before the redirect
12
+ * see `functions/tests/dedup-bucketB-equivalence.test.ts`.
13
+ */
14
+ export { containsCollections, deepForEach, deepMap, reduce, scatter, } from '@danielsimonjr/mathts-core/internal';
67
15
  //# sourceMappingURL=collection.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../../src/utils/collection.ts"],"names":[],"mappings":"AAMA,UAAU,MAAM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AAC,CAcjB;AAED;;;;;;;;GAQG;AACH,wBAAgB,MAAM,CAAC,CAAC,EAAE,CAAC,EACzB,GAAG,EAAE,CAAC,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,EACpB,GAAG,EAAE,MAAM,EACX,QAAQ,EAAE,CAAC,GAAG,EAAE,CAAC,GAAG,CAAC,EAAE,GAAG,EAAE,CAAC,KAAK,CAAC,GAClC,CAAC,EAAE,GAAG,MAAM,CAAC,CAAC,CAAC,CAgBjB;AAwCD;;;;;;;;;;;;;GAaG;AACH,wBAAgB,OAAO,CAAC,CAAC,EACvB,CAAC,EAAE,YAAY,CAAC,CAAC,CAAC,EAClB,CAAC,EAAE,MAAM,EACT,CAAC,EAAE,MAAM,EAAE,EACX,CAAC,EAAE,CAAC,EAAE,GAAG,IAAI,EACb,CAAC,EAAE,MAAM,EAAE,EACX,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,MAAM,EAAE,EAChB,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,CAAC,EAAE,CAAC,EAAE,CAAC,KAAK,CAAC,EACrB,OAAO,CAAC,EAAE,OAAO,EACjB,MAAM,CAAC,EAAE,OAAO,EAChB,KAAK,CAAC,EAAE,CAAC,GACR,IAAI,CA2DN"}
1
+ {"version":3,"file":"collection.d.ts","sourceRoot":"","sources":["../../src/utils/collection.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;GAYG;AACH,OAAO,EACL,mBAAmB,EACnB,WAAW,EACX,OAAO,EACP,MAAM,EACN,OAAO,GACR,MAAM,qCAAqC,CAAC"}
@@ -1,3 +1,42 @@
1
+ import { type LegacyFactory, type DependencyName, isFactory, assertDependencies, isOptionalDependency, stripOptionalNotation, sortFactories as coreSortFactories, create as coreCreate } from '@danielsimonjr/mathts-core/internal';
2
+ /**
3
+ * Some of this file's helpers are consolidated onto core (see the re-exports at
4
+ * the bottom): `isFactory`, `assertDependencies`, `isOptionalDependency`,
5
+ * `stripOptionalNotation`, and the plain-data types `LegacyFactory`/`FactoryMeta`/
6
+ * `DependencyName` are byte-for-byte equivalent to
7
+ * `@danielsimonjr/mathts-core/internal`'s copies (proven via a fast-check property
8
+ * harness — see `functions/tests/dedup-bucketB-equivalence.test.ts`) and are
9
+ * re-exported from there.
10
+ *
11
+ * `factory`/`FactoryFunction`/`CreateFunction` remain DELIBERATELY KEPT LOCAL — NOT
12
+ * safe to redirect: `factory()`'s generic `CreateFunction<TDeps extends
13
+ * Record<string, unknown>, ...>` constraint (core's copy) rejects real call sites
14
+ * across this package (259+ activated mathjs-factory call sites in
15
+ * `functions/src/{arithmetic,algebra,...}`) whose destructured dependency objects
16
+ * are typed as plain interfaces without an index signature — confirmed
17
+ * empirically: redirecting it broke `tsc --noEmit` (the same failure mode
18
+ * reproduced first in `expression`, which has 46 call sites). This is exactly the
19
+ * constraint mismatch this package's own pre-existing
20
+ * `@typescript-eslint/no-explicit-any` comment on `CreateFunction`/`factory`
21
+ * documents — this package already worked around it with `any`; core's copy uses
22
+ * the stricter `Record<string, unknown>` and cannot be swapped in as-is.
23
+ *
24
+ * `sortFactories`/`create` are now ADOPTED from core (Bucket B, commit 2): they
25
+ * don't depend on `factory()`'s generic constraint (they only operate on already-
26
+ * constructed `FactoryFunction`/`LegacyFactory` values), so they aren't blocked by
27
+ * the divergence above. Core's `sortFactories` throws on ANY circular dependency —
28
+ * direct or indirect (see `core/tests/factory-sort.test.ts`) — which is a
29
+ * deliberate fix over this file's FORMER local copy, which only special-cased
30
+ * direct 2-cycles and otherwise silently broke longer cycles via a visited-set
31
+ * guard without throwing (see `functions/tests/dedup-bucketB-equivalence.test.ts`'s
32
+ * former "PROVEN DIVERGENCE" block, now updated to reflect the adoption). Verified
33
+ * this package's real `factory()` call sites (all 251 of them) are never fed
34
+ * through `sortFactories`/`create` in production (both are otherwise-unused mathjs
35
+ * legacy machinery here — every real activated factory is wired by hand via
36
+ * `functions/src/factories/scope.ts` + `functions/src/factories/index.ts`, not a
37
+ * name-sorted DAG load), so there is no live dependency graph that could hit the
38
+ * stricter throw.
39
+ */
1
40
  /**
2
41
  * Type for a factory function that creates instances
3
42
  */
@@ -8,17 +47,6 @@ export interface FactoryFunction<_TDeps = unknown, TResult = unknown> {
8
47
  dependencies: string[];
9
48
  meta?: FactoryMeta;
10
49
  }
11
- /**
12
- * Type for legacy factory objects (old-style factories)
13
- */
14
- export interface LegacyFactory {
15
- type?: string;
16
- name: string;
17
- factory: (...args: unknown[]) => unknown;
18
- math?: boolean;
19
- dependencies?: string[];
20
- meta?: FactoryMeta;
21
- }
22
50
  /**
23
51
  * Meta information that can be attached to a factory
24
52
  */
@@ -36,10 +64,6 @@ export interface FactoryMeta {
36
64
  */
37
65
  [key: string]: unknown;
38
66
  }
39
- /**
40
- * Type for dependency names, which can be optional (prefixed with '?')
41
- */
42
- export type DependencyName = string;
43
67
  /**
44
68
  * Type for the create callback function
45
69
  */
@@ -71,42 +95,7 @@ export type CreateFunction<TDeps extends Record<string, any>, TResult> = (depend
71
95
  * @returns The factory function
72
96
  */
73
97
  export declare function factory<TDeps extends Record<string, any> = any, TResult = any>(name: string, dependencies: DependencyName[], create: CreateFunction<TDeps, TResult>, meta?: FactoryMeta): FactoryFunction<TDeps, TResult>;
74
- /**
75
- * Sort all factories such that when loading in order, the dependencies are resolved.
76
- *
77
- * @param factories Array of factory functions or legacy factories
78
- * @returns Returns a new array with the sorted factories
79
- */
80
- export declare function sortFactories(factories: Array<FactoryFunction | LegacyFactory>): Array<FactoryFunction | LegacyFactory>;
81
- export declare function create(factories: Array<FactoryFunction | LegacyFactory>, scope?: Record<string, unknown>): Record<string, unknown>;
82
- /**
83
- * Test whether an object is a factory. This is the case when it has
84
- * properties name, dependencies, and a function create.
85
- * @param obj Any value to test
86
- * @returns true if obj is a factory function
87
- */
88
- export declare function isFactory(obj: unknown): obj is FactoryFunction;
89
- /**
90
- * Assert that all dependencies of a list with dependencies are available in the provided scope.
91
- *
92
- * Will throw an exception when there are dependencies missing.
93
- *
94
- * @param name Name for the function to be created. Used to generate a useful error message
95
- * @param dependencies Array of dependency names
96
- * @param scope Object containing the available dependencies
97
- * @throws Error if required dependencies are missing
98
- */
99
- export declare function assertDependencies(name: string, dependencies: DependencyName[], scope: Record<string, unknown>): void;
100
- /**
101
- * Check if a dependency is optional (starts with '?')
102
- * @param dependency The dependency name to check
103
- * @returns true if the dependency is optional
104
- */
105
- export declare function isOptionalDependency(dependency: DependencyName): boolean;
106
- /**
107
- * Remove the optional notation '?' from a dependency name
108
- * @param dependency The dependency name
109
- * @returns The dependency name without optional notation
110
- */
111
- export declare function stripOptionalNotation(dependency: DependencyName): string;
98
+ export { isFactory, assertDependencies, isOptionalDependency, stripOptionalNotation };
99
+ export { coreSortFactories as sortFactories, coreCreate as create };
100
+ export type { LegacyFactory, DependencyName };
112
101
  //# sourceMappingURL=factory.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../../src/utils/factory.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,eAAe,CAAC,MAAM,GAAG,OAAO,EAAE,OAAO,GAAG,OAAO;IAClE,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC;IAC1C,SAAS,EAAE,IAAI,CAAC;IAChB,EAAE,EAAE,MAAM,CAAC;IACX,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,CAAC,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,OAAO,CAAC;IACzC,IAAI,CAAC,EAAE,OAAO,CAAC;IACf,YAAY,CAAC,EAAE,MAAM,EAAE,CAAC;IACxB,IAAI,CAAC,EAAE,WAAW,CAAC;CACpB;AAED;;GAEG;AACH,MAAM,WAAW,WAAW;IAC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