@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.
Files changed (91) hide show
  1. package/dist/arithmetic/scalar.d.ts +56 -0
  2. package/dist/arithmetic/scalar.d.ts.map +1 -0
  3. package/dist/array.d.ts +253 -0
  4. package/dist/array.d.ts.map +1 -0
  5. package/dist/bignumber-formatter.d.ts +135 -0
  6. package/dist/bignumber-formatter.d.ts.map +1 -0
  7. package/dist/{chunk-VPK5YTKG.js → chunk-L5MWGOLB.js} +111 -29
  8. package/dist/collection.d.ts +67 -0
  9. package/dist/collection.d.ts.map +1 -0
  10. package/dist/config.d.ts +17 -0
  11. package/dist/config.d.ts.map +1 -0
  12. package/dist/constants.d.ts +30 -0
  13. package/dist/constants.d.ts.map +1 -0
  14. package/dist/customs.d.ts +44 -0
  15. package/dist/customs.d.ts.map +1 -0
  16. package/dist/error/DimensionError.d.ts +26 -0
  17. package/dist/error/DimensionError.d.ts.map +1 -0
  18. package/dist/error/IndexError.d.ts +33 -0
  19. package/dist/error/IndexError.d.ts.map +1 -0
  20. package/dist/error/MathjsError.d.ts +13 -0
  21. package/dist/error/MathjsError.d.ts.map +1 -0
  22. package/dist/factory/factory.d.ts +154 -0
  23. package/dist/factory/factory.d.ts.map +1 -0
  24. package/dist/factory/index.d.ts +6 -0
  25. package/dist/factory/index.d.ts.map +1 -0
  26. package/dist/factory.d.ts +112 -0
  27. package/dist/factory.d.ts.map +1 -0
  28. package/dist/index.d.ts +24 -2585
  29. package/dist/index.d.ts.map +1 -0
  30. package/dist/index.js +74 -18
  31. package/dist/internal.d.ts +33 -1344
  32. package/dist/internal.d.ts.map +1 -0
  33. package/dist/internal.js +5 -3
  34. package/dist/is.d.ts +102 -0
  35. package/dist/is.d.ts.map +1 -0
  36. package/dist/map.d.ts +113 -0
  37. package/dist/map.d.ts.map +1 -0
  38. package/dist/number.d.ts +314 -0
  39. package/dist/number.d.ts.map +1 -0
  40. package/dist/numeric/stable.d.ts +130 -0
  41. package/dist/numeric/stable.d.ts.map +1 -0
  42. package/dist/object.d.ts +119 -0
  43. package/dist/object.d.ts.map +1 -0
  44. package/dist/shared.d.ts +41 -0
  45. package/dist/shared.d.ts.map +1 -0
  46. package/dist/string.d.ts +70 -0
  47. package/dist/string.d.ts.map +1 -0
  48. package/dist/switch.d.ts +9 -0
  49. package/dist/switch.d.ts.map +1 -0
  50. package/dist/typed/index.d.ts +7 -0
  51. package/dist/typed/index.d.ts.map +1 -0
  52. package/dist/typed/mathts-typed.d.ts +246 -0
  53. package/dist/typed/mathts-typed.d.ts.map +1 -0
  54. package/dist/typed/type-bridge.d.ts +2 -0
  55. package/dist/typed/type-bridge.d.ts.map +1 -0
  56. package/dist/types/bignumber.d.ts +367 -0
  57. package/dist/types/bignumber.d.ts.map +1 -0
  58. package/dist/types/complex.d.ts +284 -0
  59. package/dist/types/complex.d.ts.map +1 -0
  60. package/dist/types/dual-rules.d.ts +129 -0
  61. package/dist/types/dual-rules.d.ts.map +1 -0
  62. package/dist/types/dual.d.ts +36 -0
  63. package/dist/types/dual.d.ts.map +1 -0
  64. package/dist/types/fraction.d.ts +215 -0
  65. package/dist/types/fraction.d.ts.map +1 -0
  66. package/dist/types/interfaces.d.ts +143 -0
  67. package/dist/types/interfaces.d.ts.map +1 -0
  68. package/dist/types/matrix/Range.d.ts +767 -0
  69. package/dist/types/matrix/Range.d.ts.map +1 -0
  70. package/dist/types/unit/Unit.d.ts +3 -0
  71. package/dist/types/unit/Unit.d.ts.map +1 -0
  72. package/dist/types/unit/dependencies.d.ts +4 -0
  73. package/dist/types/unit/dependencies.d.ts.map +1 -0
  74. package/dist/types/unit/errors.d.ts +18 -0
  75. package/dist/types/unit/errors.d.ts.map +1 -0
  76. package/dist/types/unit/index.d.ts +7 -0
  77. package/dist/types/unit/index.d.ts.map +1 -0
  78. package/dist/types/unit/unit-types.d.ts +231 -0
  79. package/dist/types/unit/unit-types.d.ts.map +1 -0
  80. package/dist/types/unit-definitions.d.ts +79 -0
  81. package/dist/types/unit-definitions.d.ts.map +1 -0
  82. package/dist/types/unit-prefixes.d.ts +29 -0
  83. package/dist/types/unit-prefixes.d.ts.map +1 -0
  84. package/dist/types/unit.d.ts +28 -0
  85. package/dist/types/unit.d.ts.map +1 -0
  86. package/dist/types/wasm-loader.d.ts +35 -0
  87. package/dist/types/wasm-loader.d.ts.map +1 -0
  88. package/dist/wasm-loader.d.ts +97 -0
  89. package/dist/wasm-loader.d.ts.map +1 -0
  90. package/package.json +9 -9
  91. 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,MAA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