@danielsimonjr/mathts-functions 0.41.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.
Files changed (37) hide show
  1. package/dist/error/DimensionError.d.ts +11 -12
  2. package/dist/error/DimensionError.d.ts.map +1 -1
  3. package/dist/error/IndexError.d.ts +13 -19
  4. package/dist/error/IndexError.d.ts.map +1 -1
  5. package/dist/factories/index.d.ts.map +1 -1
  6. package/dist/factories/matrix-bridge.d.ts +1 -1
  7. package/dist/factories/scope.d.ts +1 -1
  8. package/dist/index.d.ts +5 -0
  9. package/dist/index.d.ts.map +1 -1
  10. package/dist/index.js +736 -1341
  11. package/dist/numeric/bspline.d.ts +47 -0
  12. package/dist/numeric/bspline.d.ts.map +1 -0
  13. package/dist/numeric/monte-carlo.d.ts +40 -0
  14. package/dist/numeric/monte-carlo.d.ts.map +1 -0
  15. package/dist/special/niche.d.ts +139 -0
  16. package/dist/special/niche.d.ts.map +1 -0
  17. package/dist/typed/arithmetic.d.ts.map +1 -1
  18. package/dist/typed/bitwise.d.ts +1 -1
  19. package/dist/typed/probability.d.ts +2 -2
  20. package/dist/typed/relational.d.ts +3 -3
  21. package/dist/typed/string.d.ts +3 -3
  22. package/dist/typed/typed-bridge.d.ts +1 -1
  23. package/dist/utils/array.d.ts +20 -237
  24. package/dist/utils/array.d.ts.map +1 -1
  25. package/dist/utils/collection.d.ts +12 -64
  26. package/dist/utils/collection.d.ts.map +1 -1
  27. package/dist/utils/factory.d.ts +42 -53
  28. package/dist/utils/factory.d.ts.map +1 -1
  29. package/dist/utils/map.d.ts +30 -103
  30. package/dist/utils/map.d.ts.map +1 -1
  31. package/dist/utils/string.d.ts +15 -59
  32. package/dist/utils/string.d.ts.map +1 -1
  33. package/package.json +5 -5
  34. package/dist/error/MathjsError.d.ts +0 -13
  35. package/dist/error/MathjsError.d.ts.map +0 -1
  36. package/dist/utils/bignumber/formatter.d.ts +0 -136
  37. package/dist/utils/bignumber/formatter.d.ts.map +0 -1
@@ -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,CAAC,CAAC,GAAG,OAAO;IAC1B,OAAO,CAAC,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,IAAI,CAAC;IAClF,GAAG,CAAC,CAAC,EAAE,QAAQ,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,CAAC,EAAE,SAAS,EAAE,OAAO,EAAE,OAAO,EAAE,OAAO,GAAG,MAAM,CAAC,CAAC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D;;;;;;;;;;;;;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;IAC1B;;OAEG;IACH,sBAAsB,CAAC,EAAE,OAAO,CAAC;IACjC;;OAEG;IACH,IAAI,CAAC,EAAE,OAAO,CAAC;IACf;;OAEG;IACH,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC;CACxB;AAED;;GAEG;AACH,MAAM,MAAM,cAAc,GAAG,MAAM,CAAC;AAEpC;;GAEG;AAEH,MAAM,MAAM,cAAc,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAA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EAAE,kBAAkB,EAAE,oBAAoB,EAAE,qBAAqB,EAAE,CAAC;AACtF,OAAO,EAAE,iBAAiB,IAAI,aAAa,EAAE,UAAU,IAAI,MAAM,EAAE,CAAC;AACpE,YAAY,EAAE,aAAa,EAAE,cAAc,EAAE,CAAC"}
@@ -1,106 +1,33 @@
1
1
  /**
2
- * A map facade on a bare object.
3
- *
4
- * The small number of methods needed to implement a scope,
5
- * forwarding on to the SafeProperty functions. Over time, the codebase
6
- * will stop using this method, as all objects will be Maps, rather than
7
- * more security prone objects.
8
- */
9
- /**
10
- * The iterator type `Map` itself declares, derived from the installed TS lib
11
- * rather than hard-coded: older libs say `IterableIterator<[K, V]>`, TS >= 5.6
12
- * says `MapIterator<[K, V]>` (which additionally requires `[Symbol.dispose]`).
13
- * Deriving it keeps `implements Map<K, V>` honest on every TS version.
14
- */
15
- type MapEntryIterator<K, V> = ReturnType<Map<K, V>[typeof Symbol.iterator]>;
16
- export declare class ObjectWrappingMap<K = string, V = unknown> implements Map<K, V> {
17
- wrappedObject: Record<string, V>;
18
- readonly [Symbol.toStringTag]: string;
19
- constructor(object: Record<string, V>);
20
- /**
21
- * Declared as a real method rather than assigned in the constructor through a
22
- * cast. The old form satisfied the runtime but never appeared in the emitted
23
- * type, so `implements Map<K, V>` was a lie that only surfaced downstream:
24
- * consumers compiling with `skipLibCheck: false` got TS2420 ("incorrectly
25
- * implements interface 'Map'... '[Symbol.iterator]' is missing").
26
- */
27
- [Symbol.iterator](): MapEntryIterator<K, V>;
28
- keys(): IterableIterator<K>;
29
- get(key: K): V | undefined;
30
- set(key: K, value: V): this;
31
- has(key: K): boolean;
32
- entries(): IterableIterator<[K, V]>;
33
- values(): IterableIterator<V>;
34
- forEach(callback: (value: V, key: K, map: Map<K, V>) => void): void;
35
- delete(key: K): boolean;
36
- clear(): void;
37
- get size(): number;
38
- }
39
- /**
40
- * Create a map with two partitions: a and b.
41
- * The set with bKeys determines which keys/values are read/written to map b,
42
- * all other values are read/written to map a
43
- *
44
- * For example:
45
- *
46
- * const a = new Map()
47
- * const b = new Map()
48
- * const p = new PartitionedMap(a, b, new Set(['x', 'y']))
49
- *
50
- * In this case, values `x` and `y` are read/written to map `b`,
51
- * all other values are read/written to map `a`.
52
- */
53
- export declare class PartitionedMap<K = unknown, V = unknown> implements Map<K, V> {
54
- a: Map<K, V>;
55
- b: Map<K, V>;
56
- bKeys: Set<K>;
57
- readonly [Symbol.toStringTag]: string;
58
- /**
59
- * @param a - Primary map
60
- * @param b - Secondary map
61
- * @param bKeys - Set of keys that should be read/written to map b
62
- */
63
- constructor(a: Map<K, V>, b: Map<K, V>, bKeys: Set<K>);
64
- /** See the note on `ObjectWrappingMap[Symbol.iterator]` — same fix. */
65
- [Symbol.iterator](): MapEntryIterator<K, V>;
66
- get(key: K): V | undefined;
67
- set(key: K, value: V): this;
68
- has(key: K): boolean;
69
- keys(): IterableIterator<K>;
70
- values(): IterableIterator<V>;
71
- entries(): IterableIterator<[K, V]>;
72
- forEach(callback: (value: V, key: K, map: Map<K, V>) => void): void;
73
- delete(key: K): boolean;
74
- clear(): void;
75
- get size(): number;
76
- }
77
- /**
78
- * Creates an empty map, or whatever your platform's polyfill is.
79
- *
80
- * @returns an empty Map or Map like object.
81
- */
82
- export declare function createEmptyMap<K = unknown, V = unknown>(): Map<K, V>;
83
- /**
84
- * Creates a Map from the given object.
85
- *
86
- * @param mapOrObject - Map or object to convert
87
- * @returns Map instance
88
- */
89
- export declare function createMap<K = unknown, V = unknown>(mapOrObject?: Map<K, V> | Record<string, V> | null): Map<K, V>;
90
- /**
91
- * Copies the contents of key-value pairs from each `objects` in to `map`.
92
- *
93
- * Object is `objects` can be a `Map` or object.
94
- *
95
- * This is the `Map` analog to `Object.assign`.
96
- */
97
- export declare function assign<K = unknown, V = unknown>(map: Map<K, V>, ...objects: (Map<K, V> | Record<string, V> | null | undefined)[]): Map<K, V>;
98
- /**
99
- * Returns `true` if `object` is an {@link ObjectWrappingMap}.
100
- *
101
- * Defined here, next to the class it guards, so `is.ts` need not import
102
- * `map.ts` — that import was the sole edge closing the `is`/`map` cycle.
2
+ * A `Map`-facade over a bare object (`ObjectWrappingMap`), a two-partition
3
+ * `Map` (`PartitionedMap`), and small `Map`/object interop helpers
4
+ * (`createMap`/`createEmptyMap`/`assign`).
5
+ *
6
+ * Consolidated onto core: the implementation lives once in
7
+ * `@danielsimonjr/mathts-core/internal` (see `core/src/map.ts` and the
8
+ * `project-all-libraries-build-on-core` principle). Thin re-export so existing
9
+ * `../utils/map.js` imports keep working while the single source of truth lives
10
+ * in core. Proven equivalent to the prior local copy (and to `expression`'s copy)
11
+ * via a fast-check property harness before the redirect see
12
+ * `functions/tests/dedup-bucketB-equivalence.test.ts`.
13
+ *
14
+ * TWO divergences were found and reconciled onto core (see `core/src/map.ts`'s
15
+ * header for the full writeup):
16
+ * 1. `[Symbol.iterator]` THIS package's prior copy already declared it as a
17
+ * real, correctly-typed class method (the fix `expression`'s copy was
18
+ * missing); core's canonical adopts this package's version unchanged.
19
+ * 2. `createEmptyMap`/`createMap`'s generic default (`K = unknown` here vs.
20
+ * `K = string` in `expression`) — a compile-time-only inference default with
21
+ * no behavioral difference; reconciled to core's `K = string` (matching
22
+ * `ObjectWrappingMap`/`PartitionedMap`'s own `K = string` default already
23
+ * shared by both packages). No call site in this package relies on the
24
+ * `K = unknown` default (checked: `functions/src/algebra/simplify.ts`'s
25
+ * `createEmptyMap()` call is assigned to an explicitly `Map<string, unknown>`-
26
+ * typed parameter default, which `Map<string, unknown>` satisfies directly).
27
+ *
28
+ * This package never had `toObject` (unlike `expression`'s prior copy, consumed
29
+ * by its `Parser.ts`), so it is intentionally not re-exported here — this shim
30
+ * preserves exactly the original export surface.
103
31
  */
104
- export declare function isObjectWrappingMap(object: unknown): object is ObjectWrappingMap;
105
- export {};
32
+ export { ObjectWrappingMap, PartitionedMap, createEmptyMap, createMap, assignMap as assign, isObjectWrappingMap, } from '@danielsimonjr/mathts-core/internal';
106
33
  //# sourceMappingURL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AAG,EAAE,CAAC,GAAG,OAAO;IAIvB,KAAK,IAAI,IAAI;IAKb,IAAI,IAAI,IAAI,MAAM,CAEjB;CACF;AAmBD;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAEpE;AAED;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO,EAChD,WAAW,CAAC,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,IAAI,GACjD,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAYX;AAED;;;;;;GAMG;AACH,wBAAgB,MAAM,CAAC,CAAC,GAAG,OAAO,EAAE,CAAC,GAAG,OAAO,EAC7C,GAAG,EAAE,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,EACd,GAAG,OAAO,EAAE,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,GAAG,IAAI,GAAG,SAAS,CAAC,EAAE,GAC/D,GAAG,CAAC,CAAC,EAAE,CAAC,CAAC,CAgBX;AAED;;;;;GAKG;AACH,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,OAAO,GAAG,MAAM,IAAI,iBAAiB,CAIhF"}
1
+ {"version":3,"file":"map.d.ts","sourceRoot":"","sources":["../../src/utils/map.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AACH,OAAO,EACL,iBAAiB,EACjB,cAAc,EACd,cAAc,EACd,SAAS,EACT,SAAS,IAAI,MAAM,EACnB,mBAAmB,GACpB,MAAM,qCAAqC,CAAC"}
@@ -1,64 +1,20 @@
1
- import { type FormatOptions } from './number.js';
2
1
  /**
3
- * Formatting options accepted by the generic `format` helper. Extends the
4
- * numeric {@link FormatOptions} with the string-level `truncate` and the
5
- * fraction rendering mode, or is a precision number, or a custom formatter.
6
- */
7
- export type GeneralFormatOptions = number | ((value: unknown) => string) | (FormatOptions & {
8
- truncate?: number;
9
- fraction?: 'ratio' | 'decimal';
10
- });
11
- /**
12
- * Format a value of any type into a string.
13
- *
14
- * Usage:
15
- * math.format(value)
16
- * math.format(value, precision)
17
- * math.format(value, options)
18
- *
19
- * When value is a function:
20
- *
21
- * - When the function has a property `syntax`, it returns this
22
- * syntax description.
23
- * - In other cases, a string `'function'` is returned.
24
- *
25
- * When `value` is an Object:
2
+ * Generic-value string formatting (`format`, `stringify`, `compareText`).
26
3
  *
27
- * - When the object contains a property `format` being a function, this
28
- * function is invoked as `value.format(options)` and the result is returned.
29
- * - When the object has its own `toString` method, this method is invoked
30
- * and the result is returned.
31
- * - In other cases the function will loop over all object properties and
32
- * return JSON object notation like '{"a": 2, "b": 3}'.
4
+ * Consolidated onto core: the implementations live once in
5
+ * `@danielsimonjr/mathts-core/internal` (see `number.ts`/`object.ts` and the
6
+ * `project-all-libraries-build-on-core` principle). Thin re-export so existing
7
+ * `../utils/string.js` imports keep working while the single source of truth
8
+ * lives in core. Proven equivalent to the prior local copy (and to `expression`'s
9
+ * copy) via a fast-check property harness before the redirect — see
10
+ * `functions/tests/dedup-bucketB-equivalence.test.ts`.
33
11
  *
34
- * Example usage:
35
- * math.format(2/7) // '0.2857142857142857'
36
- * math.format(math.pi, 3) // '3.14'
37
- * math.format(new Complex(2, 3)) // '2 + 3i'
38
- * math.format('hello') // '"hello"'
39
- *
40
- * @param {*} value Value to be stringified
41
- * @param {Object | number | Function} [options]
42
- * Formatting options. See src/utils/number.js:format for a
43
- * description of the available options controlling number output.
44
- * This generic "format" also supports the option property `truncate: NN`
45
- * giving the maximum number NN of characters to return (if there would
46
- * have been more, they are deleted and replaced by an ellipsis).
47
- * @return {string} str
48
- */
49
- export declare function format(value: unknown, options?: unknown): string;
50
- /**
51
- * Stringify a value into a string enclosed in double quotes.
52
- * Unescaped double quotes and backslashes inside the value are escaped.
53
- * @param {*} value
54
- * @return {string}
55
- */
56
- export declare function stringify(value: unknown): string;
57
- /**
58
- * Compare two strings
59
- * @param {string} x
60
- * @param {string} y
61
- * @returns {number}
12
+ * NOTE: core exports the generic `format` here as `formatGeneric` (its `number.ts`
13
+ * already exports a `format` for plain numbers from the same `internal.ts` barrel,
14
+ * so an unaliased re-export would collide); re-exported here under the original
15
+ * local name `format`. This package never had `escape`/`endsWith` in this file
16
+ * (unlike `expression`'s prior copy), so they are intentionally not re-exported
17
+ * here — this shim preserves exactly the original export surface.
62
18
  */
63
- export declare function compareText(x: unknown, y: unknown): number;
19
+ export { formatGeneric as format, stringify, compareText, type GeneralFormatOptions, } from '@danielsimonjr/mathts-core/internal';
64
20
  //# sourceMappingURL=string.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../src/utils/string.ts"],"names":[],"mappings":"AACA,OAAO,EAA0B,KAAK,aAAa,EAAE,MAAM,aAAa,CAAC;AAGzE;;;;GAIG;AACH,MAAM,MAAM,oBAAoB,GAC5B,MAAM,GACN,CAAC,CAAC,KAAK,EAAE,OAAO,KAAK,MAAM,CAAC,GAC5B,CAAC,aAAa,GAAG;IACf,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,OAAO,GAAG,SAAS,CAAC;CAChC,CAAC,CAAC;AASP;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG;AACH,wBAAgB,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,MAAM,CAShE;AA2DD;;;;;GAKG;AACH,wBAAgB,SAAS,CAAC,KAAK,EAAE,OAAO,GAAG,MAAM,CAWhD;AAwDD;;;;;GAKG;AACH,wBAAgB,WAAW,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,MAAM,CAoB1D"}
1
+ {"version":3,"file":"string.d.ts","sourceRoot":"","sources":["../../src/utils/string.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;GAiBG;AACH,OAAO,EACL,aAAa,IAAI,MAAM,EACvB,SAAS,EACT,WAAW,EACX,KAAK,oBAAoB,GAC1B,MAAM,qCAAqC,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danielsimonjr/mathts-functions",
3
- "version": "0.41.0",
3
+ "version": "0.43.0",
4
4
  "description": "Mathematical functions for MathTS - arithmetic, algebra, trigonometry, statistics, and more",
5
5
  "author": "Daniel Simon Jr.",
6
6
  "license": "MIT",
@@ -34,11 +34,11 @@
34
34
  "build:prod": "tsup src/index.ts --format esm --clean --minify --treeshake"
35
35
  },
36
36
  "dependencies": {
37
- "@danielsimonjr/mathts-core": "^0.10.0",
38
- "@danielsimonjr/mathts-expression": "^0.6.4",
37
+ "@danielsimonjr/mathts-core": "^0.11.0",
38
+ "@danielsimonjr/mathts-expression": "^0.6.5",
39
39
  "@danielsimonjr/mathts-gpu": "^0.2.0",
40
- "@danielsimonjr/mathts-matrix": "^0.6.0",
41
- "@danielsimonjr/mathts-parallel": "^0.6.0",
40
+ "@danielsimonjr/mathts-matrix": "^0.6.1",
41
+ "@danielsimonjr/mathts-parallel": "^0.6.1",
42
42
  "bignumber.js": "^9.1.2",
43
43
  "complex.js": "^2.2.5",
44
44
  "decimal.js": "^10.4.3",
@@ -1,13 +0,0 @@
1
- /**
2
- * Custom error type for Mathjs errors
3
- * @extends Error
4
- */
5
- export declare class MathjsError extends Error {
6
- isMathjsError: true;
7
- /**
8
- * Create a MathjsError
9
- * @param message Error message
10
- */
11
- constructor(message: string);
12
- }
13
- //# sourceMappingURL=MathjsError.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"MathjsError.d.ts","sourceRoot":"","sources":["../../src/error/MathjsError.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,qBAAa,WAAY,SAAQ,KAAK;IACpC,aAAa,EAAG,IAAI,CAAU;IAE9B;;;OAGG;gBACS,OAAO,EAAE,MAAM;CAY5B"}
@@ -1,136 +0,0 @@
1
- /**
2
- * Structural contract for the BigNumber values handled by this formatter.
3
- * Captures exactly the methods/properties used here. The configured BigNumber
4
- * implementation (e.g. decimal.js) provides these; the project's `BigNumber`
5
- * type alias points at a minimal local Decimal that does not declare them all,
6
- * so we model the runtime contract explicitly.
7
- */
8
- interface BigNumberValue {
9
- e: number;
10
- constructor: new (value: number | string) => BigNumberValue;
11
- isFinite(): boolean;
12
- isNaN(): boolean;
13
- isZero(): boolean;
14
- isInteger(): boolean;
15
- gt(other: number | BigNumberValue): boolean;
16
- greaterThan(other: number | BigNumberValue): boolean;
17
- lessThan(other: number | BigNumberValue): boolean;
18
- add(other: number | BigNumberValue): BigNumberValue;
19
- sub(other: number | BigNumberValue): BigNumberValue;
20
- mul(other: number | BigNumberValue): BigNumberValue;
21
- pow(exp: number | BigNumberValue): BigNumberValue;
22
- toNumber(): number;
23
- toFixed(places?: number): string;
24
- toExponential(places?: number): string;
25
- toPrecision(sd?: number): string;
26
- toSignificantDigits(sd?: number): BigNumberValue;
27
- toBinary(): string;
28
- toOctal(): string;
29
- toHexadecimal(): string;
30
- }
31
- /**
32
- * Convert a BigNumber to a formatted string representation.
33
- *
34
- * Syntax:
35
- *
36
- * format(value)
37
- * format(value, options)
38
- * format(value, precision)
39
- * format(value, fn)
40
- *
41
- * Where:
42
- *
43
- * {number} value The value to be formatted
44
- * {Object} options An object with formatting options. Available options:
45
- * {string} notation
46
- * Number notation. Choose from:
47
- * 'fixed' Always use regular number notation.
48
- * For example '123.40' and '14000000'
49
- * 'exponential' Always use exponential notation.
50
- * For example '1.234e+2' and '1.4e+7'
51
- * 'auto' (default) Regular number notation for numbers
52
- * having an absolute value between
53
- * `lower` and `upper` bounds, and uses
54
- * exponential notation elsewhere.
55
- * Lower bound is included, upper bound
56
- * is excluded.
57
- * For example '123.4' and '1.4e7'.
58
- * 'bin', 'oct, or
59
- * 'hex' Format the number using binary, octal,
60
- * or hexadecimal notation.
61
- * For example '0b1101' and '0x10fe'.
62
- * {number} wordSize The word size in bits to use for formatting
63
- * in binary, octal, or hexadecimal notation.
64
- * To be used only with 'bin', 'oct', or 'hex'
65
- * values for 'notation' option. When this option
66
- * is defined the value is formatted as a signed
67
- * twos complement integer of the given word size
68
- * and the size suffix is appended to the output.
69
- * For example
70
- * format(-1, {notation: 'hex', wordSize: 8}) === '0xffi8'.
71
- * Default value is undefined.
72
- * {number} precision A number between 0 and 16 to round
73
- * the digits of the number.
74
- * In case of notations 'exponential',
75
- * 'engineering', and 'auto',
76
- * `precision` defines the total
77
- * number of significant digits returned.
78
- * In case of notation 'fixed',
79
- * `precision` defines the number of
80
- * significant digits after the decimal
81
- * point.
82
- * `precision` is undefined by default.
83
- * {number} lowerExp Exponent determining the lower boundary
84
- * for formatting a value with an exponent
85
- * when `notation='auto`.
86
- * Default value is `-3`.
87
- * {number} upperExp Exponent determining the upper boundary
88
- * for formatting a value with an exponent
89
- * when `notation='auto`.
90
- * Default value is `5`.
91
- * {Function} fn A custom formatting function. Can be used to override the
92
- * built-in notations. Function `fn` is called with `value` as
93
- * parameter and must return a string. Is useful for example to
94
- * format all values inside a matrix in a particular way.
95
- *
96
- * Examples:
97
- *
98
- * format(6.4) // '6.4'
99
- * format(1240000) // '1.24e6'
100
- * format(1/3) // '0.3333333333333333'
101
- * format(1/3, 3) // '0.333'
102
- * format(21385, 2) // '21000'
103
- * format(12e8, {notation: 'fixed'}) // returns '1200000000'
104
- * format(2.3, {notation: 'fixed', precision: 4}) // returns '2.3000'
105
- * format(52.8, {notation: 'exponential'}) // returns '5.28e+1'
106
- * format(12400, {notation: 'engineering'}) // returns '12.400e+3'
107
- *
108
- * @param {BigNumber} value
109
- * @param {Object | Function | number | BigNumber} [options]
110
- * @return {string} str The formatted value
111
- */
112
- export declare function format(value: unknown, options?: unknown): string;
113
- /**
114
- * Format a BigNumber in engineering notation. Like '1.23e+6', '2.3e+0', '3.500e-3'
115
- * @param {BigNumber} value
116
- * @param {number} [precision] Optional number of significant figures to return.
117
- */
118
- export declare function toEngineering(value: BigNumberValue, precision?: number): string;
119
- /**
120
- * Format a number in exponential notation. Like '1.23e+5', '2.3e+0', '3.500e-3'
121
- * @param {BigNumber} value
122
- * @param {number} [precision] Number of digits in formatted output.
123
- * If not provided, the maximum available digits
124
- * is used.
125
- * @returns {string} str
126
- */
127
- export declare function toExponential(value: BigNumberValue, precision?: number): string;
128
- /**
129
- * Format a number with fixed notation.
130
- * @param {BigNumber} value
131
- * @param {number} [precision=undefined] Optional number of decimals after the
132
- * decimal point. Undefined by default.
133
- */
134
- export declare function toFixed(value: BigNumberValue, precision?: number): string;
135
- export {};
136
- //# sourceMappingURL=formatter.d.ts.map