@danielsimonjr/mathts-core 0.14.1 → 0.15.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/dist/arithmetic/scalar.d.ts +56 -0
- package/dist/arithmetic/scalar.d.ts.map +1 -0
- package/dist/array.d.ts +253 -0
- package/dist/array.d.ts.map +1 -0
- package/dist/bignumber-formatter.d.ts +135 -0
- package/dist/bignumber-formatter.d.ts.map +1 -0
- package/dist/{chunk-VPK5YTKG.js → chunk-L5MWGOLB.js} +111 -29
- package/dist/collection.d.ts +67 -0
- package/dist/collection.d.ts.map +1 -0
- package/dist/config.d.ts +17 -0
- package/dist/config.d.ts.map +1 -0
- package/dist/constants.d.ts +30 -0
- package/dist/constants.d.ts.map +1 -0
- package/dist/customs.d.ts +44 -0
- package/dist/customs.d.ts.map +1 -0
- package/dist/error/DimensionError.d.ts +26 -0
- package/dist/error/DimensionError.d.ts.map +1 -0
- package/dist/error/IndexError.d.ts +33 -0
- package/dist/error/IndexError.d.ts.map +1 -0
- package/dist/error/MathjsError.d.ts +13 -0
- package/dist/error/MathjsError.d.ts.map +1 -0
- package/dist/factory/factory.d.ts +154 -0
- package/dist/factory/factory.d.ts.map +1 -0
- package/dist/factory/index.d.ts +6 -0
- package/dist/factory/index.d.ts.map +1 -0
- package/dist/factory.d.ts +112 -0
- package/dist/factory.d.ts.map +1 -0
- package/dist/index.d.ts +24 -2585
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +74 -18
- package/dist/internal.d.ts +33 -1344
- package/dist/internal.d.ts.map +1 -0
- package/dist/internal.js +5 -3
- package/dist/is.d.ts +102 -0
- package/dist/is.d.ts.map +1 -0
- package/dist/map.d.ts +113 -0
- package/dist/map.d.ts.map +1 -0
- package/dist/number.d.ts +314 -0
- package/dist/number.d.ts.map +1 -0
- package/dist/numeric/stable.d.ts +130 -0
- package/dist/numeric/stable.d.ts.map +1 -0
- package/dist/object.d.ts +119 -0
- package/dist/object.d.ts.map +1 -0
- package/dist/shared.d.ts +41 -0
- package/dist/shared.d.ts.map +1 -0
- package/dist/string.d.ts +70 -0
- package/dist/string.d.ts.map +1 -0
- package/dist/switch.d.ts +9 -0
- package/dist/switch.d.ts.map +1 -0
- package/dist/typed/index.d.ts +7 -0
- package/dist/typed/index.d.ts.map +1 -0
- package/dist/typed/mathts-typed.d.ts +246 -0
- package/dist/typed/mathts-typed.d.ts.map +1 -0
- package/dist/typed/type-bridge.d.ts +2 -0
- package/dist/typed/type-bridge.d.ts.map +1 -0
- package/dist/types/bignumber.d.ts +367 -0
- package/dist/types/bignumber.d.ts.map +1 -0
- package/dist/types/complex.d.ts +284 -0
- package/dist/types/complex.d.ts.map +1 -0
- package/dist/types/dual-rules.d.ts +129 -0
- package/dist/types/dual-rules.d.ts.map +1 -0
- package/dist/types/dual.d.ts +36 -0
- package/dist/types/dual.d.ts.map +1 -0
- package/dist/types/fraction.d.ts +215 -0
- package/dist/types/fraction.d.ts.map +1 -0
- package/dist/types/interfaces.d.ts +143 -0
- package/dist/types/interfaces.d.ts.map +1 -0
- package/dist/types/matrix/Range.d.ts +767 -0
- package/dist/types/matrix/Range.d.ts.map +1 -0
- package/dist/types/unit/Unit.d.ts +3 -0
- package/dist/types/unit/Unit.d.ts.map +1 -0
- package/dist/types/unit/dependencies.d.ts +4 -0
- package/dist/types/unit/dependencies.d.ts.map +1 -0
- package/dist/types/unit/errors.d.ts +18 -0
- package/dist/types/unit/errors.d.ts.map +1 -0
- package/dist/types/unit/index.d.ts +7 -0
- package/dist/types/unit/index.d.ts.map +1 -0
- package/dist/types/unit/unit-types.d.ts +231 -0
- package/dist/types/unit/unit-types.d.ts.map +1 -0
- package/dist/types/unit-definitions.d.ts +79 -0
- package/dist/types/unit-definitions.d.ts.map +1 -0
- package/dist/types/unit-prefixes.d.ts +29 -0
- package/dist/types/unit-prefixes.d.ts.map +1 -0
- package/dist/types/unit.d.ts +28 -0
- package/dist/types/unit.d.ts.map +1 -0
- package/dist/types/wasm-loader.d.ts +35 -0
- package/dist/types/wasm-loader.d.ts.map +1 -0
- package/dist/wasm-loader.d.ts +97 -0
- package/dist/wasm-loader.d.ts.map +1 -0
- package/package.json +9 -9
- package/dist/index-B4LIOfHN.d.ts +0 -449
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Factory pattern exports
|
|
3
|
+
*/
|
|
4
|
+
export { FunctionRegistry, createFactory, createTypedFunction, registry, math, DEFAULT_CONFIG, } from './factory.js';
|
|
5
|
+
export type { MathTSConfig, FactoryFunction, FactoryDependencies, FactoryImport, } from './factory.js';
|
|
6
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/factory/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,OAAO,EACL,gBAAgB,EAChB,aAAa,EACb,mBAAmB,EACnB,QAAQ,EACR,IAAI,EACJ,cAAc,GACf,MAAM,cAAc,CAAC;AAEtB,YAAY,EACV,YAAY,EACZ,eAAe,EACf,mBAAmB,EACnB,aAAa,GACd,MAAM,cAAc,CAAC"}
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Type for a factory function that creates instances
|
|
3
|
+
*/
|
|
4
|
+
export interface FactoryFunction<TResult = unknown> {
|
|
5
|
+
(scope: Record<string, unknown>): TResult;
|
|
6
|
+
isFactory: true;
|
|
7
|
+
fn: string;
|
|
8
|
+
dependencies: string[];
|
|
9
|
+
meta?: FactoryMeta;
|
|
10
|
+
}
|
|
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
|
+
/**
|
|
23
|
+
* Meta information that can be attached to a factory
|
|
24
|
+
*/
|
|
25
|
+
export interface FactoryMeta {
|
|
26
|
+
/**
|
|
27
|
+
* If true, the factory will be recreated when config changes
|
|
28
|
+
*/
|
|
29
|
+
recreateOnConfigChange?: boolean;
|
|
30
|
+
/**
|
|
31
|
+
* If true, this is a lazy factory that should only be created when needed
|
|
32
|
+
*/
|
|
33
|
+
lazy?: boolean;
|
|
34
|
+
/**
|
|
35
|
+
* Additional custom metadata
|
|
36
|
+
*/
|
|
37
|
+
[key: string]: unknown;
|
|
38
|
+
}
|
|
39
|
+
/**
|
|
40
|
+
* Type for dependency names, which can be optional (prefixed with '?')
|
|
41
|
+
*/
|
|
42
|
+
export type DependencyName = string;
|
|
43
|
+
/**
|
|
44
|
+
* Type for the create callback function
|
|
45
|
+
*/
|
|
46
|
+
export type CreateFunction<TDeps extends Record<string, unknown>, TResult> = (dependencies: TDeps) => TResult;
|
|
47
|
+
/**
|
|
48
|
+
* Create a factory function, which can be used to inject dependencies.
|
|
49
|
+
*
|
|
50
|
+
* The created functions are memoized, a consecutive call of the factory
|
|
51
|
+
* with the exact same inputs will return the same function instance.
|
|
52
|
+
* The memoized cache is exposed on `factory.cache` and can be cleared
|
|
53
|
+
* if needed.
|
|
54
|
+
*
|
|
55
|
+
* Example:
|
|
56
|
+
*
|
|
57
|
+
* const name = 'log'
|
|
58
|
+
* const dependencies = ['config', 'typed', 'divideScalar', 'Complex']
|
|
59
|
+
*
|
|
60
|
+
* export const createLog = factory(name, dependencies, ({ typed, config, divideScalar, Complex }) => {
|
|
61
|
+
* // ... create the function log here and return it
|
|
62
|
+
* }
|
|
63
|
+
*
|
|
64
|
+
* @param name Name of the function to be created
|
|
65
|
+
* @param dependencies The names of all required dependencies
|
|
66
|
+
* @param create Callback function called with an object with all dependencies
|
|
67
|
+
* @param meta Optional object with meta information that will be attached
|
|
68
|
+
* to the created factory function as property `meta`. For explanation
|
|
69
|
+
* of what meta properties can be specified and what they mean, see
|
|
70
|
+
* docs/core/extension.md.
|
|
71
|
+
* @returns The factory function
|
|
72
|
+
*/
|
|
73
|
+
export declare function factory<TDeps extends Record<string, unknown> = Record<string, unknown>, TResult = unknown>(name: string, dependencies: DependencyName[], create: CreateFunction<TDeps, TResult>, meta?: FactoryMeta): FactoryFunction<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;
|
|
112
|
+
//# sourceMappingURL=factory.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,WAAW,eAAe,CAAC,OAAO,GAAG,OAAO;IAChD,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;AACH,MAAM,MAAM,cAAc,CAAC,KAAK,SAAS,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO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