@danielsimonjr/mathts-core 0.3.1 → 0.4.1
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/chunk-ZPGSJR5L.js +6258 -0
- package/dist/index-DpOizJsa.d.ts +337 -0
- package/dist/index.d.ts +212 -186
- package/dist/index.js +140 -2746
- package/dist/internal.d.ts +510 -0
- package/dist/internal.js +144 -0
- package/package.json +7 -3
|
@@ -0,0 +1,510 @@
|
|
|
1
|
+
import { b as UnitConstructor, c as UnitDependencies } from './index-DpOizJsa.js';
|
|
2
|
+
export { B as BaseUnitDef, d as BigNumber, e as BigNumberConstructor, f as BigNumberValue, C as Complex, g as ComplexConstructor, h as ComplexValue, j as ConverterFn, U as CoreUnit, k as CreateUnitDefObject, l as CreateUnitOptions, D as DenseMatrix, F as Fraction, m as FractionConstructor, n as FractionValue, I as Index, o as IndexDimension, M as Matrix, N as Numeric, P as ParseOptions, p as PrefixDef, q as PrefixTable, R as Range, S as ScalarBinaryOp, r as ScalarUnaryOp, s as SparseMatrix, t as SubtractScalar, T as TypeConverters, u as Unit, v as UnitComponent, w as UnitConfig, x as UnitDef, y as UnitFormatOptions, a as UnitInstance, z as UnitJSON, A as UnitSystem, E as UnitSystemEntry, G as isArray, H as isBigInt, J as isBigNumber, K as isBoolean, L as isCollection, O as isComplex, Q as isDate, V as isDenseMatrix, W as isFraction, X as isFunction, Y as isIndex, Z as isMap, _ as isMatrix, $ as isNull, a0 as isNumber, a1 as isObject, a2 as isRange, a3 as isRegExp, a4 as isSparseMatrix, a5 as isString, a6 as isUndefined, i as isUnit, a7 as typeOf } from './index-DpOizJsa.js';
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Type for a factory function that creates instances
|
|
6
|
+
*/
|
|
7
|
+
interface FactoryFunction<TResult = unknown> {
|
|
8
|
+
(scope: Record<string, unknown>): TResult;
|
|
9
|
+
isFactory: true;
|
|
10
|
+
fn: string;
|
|
11
|
+
dependencies: string[];
|
|
12
|
+
meta?: FactoryMeta;
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Meta information that can be attached to a factory
|
|
16
|
+
*/
|
|
17
|
+
interface FactoryMeta {
|
|
18
|
+
/**
|
|
19
|
+
* If true, the factory will be recreated when config changes
|
|
20
|
+
*/
|
|
21
|
+
recreateOnConfigChange?: boolean;
|
|
22
|
+
/**
|
|
23
|
+
* If true, this is a lazy factory that should only be created when needed
|
|
24
|
+
*/
|
|
25
|
+
lazy?: boolean;
|
|
26
|
+
/**
|
|
27
|
+
* Additional custom metadata
|
|
28
|
+
*/
|
|
29
|
+
[key: string]: unknown;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
declare const createUnitClass: FactoryFunction<UnitConstructor>;
|
|
33
|
+
|
|
34
|
+
/** The full dependency bundle for `createUnitClass`. */
|
|
35
|
+
declare const unitDependencies: UnitDependencies;
|
|
36
|
+
|
|
37
|
+
/**
|
|
38
|
+
* Split value representation with sign, coefficients, and exponent
|
|
39
|
+
*/
|
|
40
|
+
interface SplitValue {
|
|
41
|
+
sign: '+' | '-' | '';
|
|
42
|
+
coefficients: number[];
|
|
43
|
+
exponent: number;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Configuration for number type handling
|
|
47
|
+
*/
|
|
48
|
+
interface NumberTypeConfig {
|
|
49
|
+
number: 'number' | 'BigNumber' | 'bigint' | 'Fraction';
|
|
50
|
+
numberFallback: 'number' | 'BigNumber';
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Format options for number formatting
|
|
54
|
+
*/
|
|
55
|
+
interface FormatOptions {
|
|
56
|
+
notation?: 'auto' | 'exponential' | 'fixed' | 'engineering' | 'bin' | 'oct' | 'hex';
|
|
57
|
+
precision?: number;
|
|
58
|
+
wordSize?: number;
|
|
59
|
+
lowerExp?: number;
|
|
60
|
+
upperExp?: number;
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Normalized format options
|
|
64
|
+
*/
|
|
65
|
+
interface NormalizedFormatOptions {
|
|
66
|
+
notation: 'auto' | 'exponential' | 'fixed' | 'engineering' | 'bin' | 'oct' | 'hex';
|
|
67
|
+
precision: number | undefined;
|
|
68
|
+
wordSize: number | undefined;
|
|
69
|
+
}
|
|
70
|
+
/**
|
|
71
|
+
* Check if a number is integer
|
|
72
|
+
* @param value The value to check
|
|
73
|
+
* @return true if value is an integer
|
|
74
|
+
*/
|
|
75
|
+
declare function isInteger(value: number | boolean): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Ensure the number type is compatible with the provided value.
|
|
78
|
+
* If not, return 'number' instead.
|
|
79
|
+
*
|
|
80
|
+
* For example:
|
|
81
|
+
*
|
|
82
|
+
* safeNumberType('2.3', { number: 'bigint', numberFallback: 'number' })
|
|
83
|
+
*
|
|
84
|
+
* will return 'number' and not 'bigint' because trying to create a bigint with
|
|
85
|
+
* value 2.3 would throw an exception.
|
|
86
|
+
*
|
|
87
|
+
* @param numberStr The number as a string
|
|
88
|
+
* @param config Configuration with number type preferences
|
|
89
|
+
* @returns The safe number type to use
|
|
90
|
+
*/
|
|
91
|
+
declare function safeNumberType(numberStr: string, config: NumberTypeConfig): 'number' | 'BigNumber' | 'bigint' | 'Fraction';
|
|
92
|
+
/**
|
|
93
|
+
* Calculate the sign of a number
|
|
94
|
+
* @param x The number
|
|
95
|
+
* @returns 1 for positive, -1 for negative, 0 for zero
|
|
96
|
+
*/
|
|
97
|
+
declare const sign: (x: number) => number;
|
|
98
|
+
/**
|
|
99
|
+
* Calculate the base-2 logarithm of a number
|
|
100
|
+
* @param x The number
|
|
101
|
+
* @returns The base-2 logarithm
|
|
102
|
+
*/
|
|
103
|
+
declare const log2: (x: number) => number;
|
|
104
|
+
/**
|
|
105
|
+
* Calculate the base-10 logarithm of a number
|
|
106
|
+
* @param x The number
|
|
107
|
+
* @returns The base-10 logarithm
|
|
108
|
+
*/
|
|
109
|
+
declare const log10: (x: number) => number;
|
|
110
|
+
/**
|
|
111
|
+
* Calculate the natural logarithm of a number + 1
|
|
112
|
+
* @param x The number
|
|
113
|
+
* @returns ln(x + 1)
|
|
114
|
+
*/
|
|
115
|
+
declare const log1p: (x: number) => number;
|
|
116
|
+
/**
|
|
117
|
+
* Calculate cubic root for a number
|
|
118
|
+
*
|
|
119
|
+
* Code from es6-shim.js:
|
|
120
|
+
* https://github.com/paulmillr/es6-shim/blob/master/es6-shim.js#L1564-L1577
|
|
121
|
+
*
|
|
122
|
+
* @param x The number
|
|
123
|
+
* @returns The cubic root of x
|
|
124
|
+
*/
|
|
125
|
+
declare const cbrt: (x: number) => number;
|
|
126
|
+
/**
|
|
127
|
+
* Calculates exponentiation minus 1
|
|
128
|
+
* @param x The exponent
|
|
129
|
+
* @return exp(x) - 1
|
|
130
|
+
*/
|
|
131
|
+
declare const expm1: (x: number) => number;
|
|
132
|
+
/**
|
|
133
|
+
* Convert a number to a formatted string representation.
|
|
134
|
+
*
|
|
135
|
+
* Syntax:
|
|
136
|
+
*
|
|
137
|
+
* format(value)
|
|
138
|
+
* format(value, options)
|
|
139
|
+
* format(value, precision)
|
|
140
|
+
* format(value, fn)
|
|
141
|
+
*
|
|
142
|
+
* Where:
|
|
143
|
+
*
|
|
144
|
+
* {number} value The value to be formatted
|
|
145
|
+
* {Object} options An object with formatting options. Available options:
|
|
146
|
+
* {string} notation
|
|
147
|
+
* Number notation. Choose from:
|
|
148
|
+
* 'fixed' Always use regular number notation.
|
|
149
|
+
* For example '123.40' and '14000000'
|
|
150
|
+
* 'exponential' Always use exponential notation.
|
|
151
|
+
* For example '1.234e+2' and '1.4e+7'
|
|
152
|
+
* 'engineering' Always use engineering notation.
|
|
153
|
+
* For example '123.4e+0' and '14.0e+6'
|
|
154
|
+
* 'auto' (default) Regular number notation for numbers
|
|
155
|
+
* having an absolute value between
|
|
156
|
+
* `lowerExp` and `upperExp` bounds, and
|
|
157
|
+
* uses exponential notation elsewhere.
|
|
158
|
+
* Lower bound is included, upper bound
|
|
159
|
+
* is excluded.
|
|
160
|
+
* For example '123.4' and '1.4e7'.
|
|
161
|
+
* 'bin', 'oct, or
|
|
162
|
+
* 'hex' Format the number using binary, octal,
|
|
163
|
+
* or hexadecimal notation.
|
|
164
|
+
* For example '0b1101' and '0x10fe'.
|
|
165
|
+
* {number} wordSize The word size in bits to use for formatting
|
|
166
|
+
* in binary, octal, or hexadecimal notation.
|
|
167
|
+
* To be used only with 'bin', 'oct', or 'hex'
|
|
168
|
+
* values for 'notation' option. When this option
|
|
169
|
+
* is defined the value is formatted as a signed
|
|
170
|
+
* twos complement integer of the given word size
|
|
171
|
+
* and the size suffix is appended to the output.
|
|
172
|
+
* For example
|
|
173
|
+
* format(-1, {notation: 'hex', wordSize: 8}) === '0xffi8'.
|
|
174
|
+
* Default value is undefined.
|
|
175
|
+
* {number} precision A number between 0 and 16 to round
|
|
176
|
+
* the digits of the number.
|
|
177
|
+
* In case of notations 'exponential',
|
|
178
|
+
* 'engineering', and 'auto',
|
|
179
|
+
* `precision` defines the total
|
|
180
|
+
* number of significant digits returned.
|
|
181
|
+
* In case of notation 'fixed',
|
|
182
|
+
* `precision` defines the number of
|
|
183
|
+
* significant digits after the decimal
|
|
184
|
+
* point.
|
|
185
|
+
* `precision` is undefined by default,
|
|
186
|
+
* not rounding any digits.
|
|
187
|
+
* {number} lowerExp Exponent determining the lower boundary
|
|
188
|
+
* for formatting a value with an exponent
|
|
189
|
+
* when `notation='auto`.
|
|
190
|
+
* Default value is `-3`.
|
|
191
|
+
* {number} upperExp Exponent determining the upper boundary
|
|
192
|
+
* for formatting a value with an exponent
|
|
193
|
+
* when `notation='auto`.
|
|
194
|
+
* Default value is `5`.
|
|
195
|
+
* {Function} fn A custom formatting function. Can be used to override the
|
|
196
|
+
* built-in notations. Function `fn` is called with `value` as
|
|
197
|
+
* parameter and must return a string. Is useful for example to
|
|
198
|
+
* format all values inside a matrix in a particular way.
|
|
199
|
+
*
|
|
200
|
+
* Examples:
|
|
201
|
+
*
|
|
202
|
+
* format(6.4) // '6.4'
|
|
203
|
+
* format(1240000) // '1.24e6'
|
|
204
|
+
* format(1/3) // '0.3333333333333333'
|
|
205
|
+
* format(1/3, 3) // '0.333'
|
|
206
|
+
* format(21385, 2) // '21000'
|
|
207
|
+
* format(12.071, {notation: 'fixed'}) // '12'
|
|
208
|
+
* format(2.3, {notation: 'fixed', precision: 2}) // '2.30'
|
|
209
|
+
* format(52.8, {notation: 'exponential'}) // '5.28e+1'
|
|
210
|
+
* format(12345678, {notation: 'engineering'}) // '12.345678e+6'
|
|
211
|
+
*
|
|
212
|
+
* @param value The number to format
|
|
213
|
+
* @param options Optional formatting options or custom formatter function or precision
|
|
214
|
+
* @return The formatted value
|
|
215
|
+
*/
|
|
216
|
+
declare function format(value: number, options?: FormatOptions | ((value: number) => string) | number): string;
|
|
217
|
+
/**
|
|
218
|
+
* Normalize format options into an object:
|
|
219
|
+
* {
|
|
220
|
+
* notation: string,
|
|
221
|
+
* precision: number | undefined,
|
|
222
|
+
* wordSize: number | undefined
|
|
223
|
+
* }
|
|
224
|
+
* @param options The input options
|
|
225
|
+
* @returns Normalized format options
|
|
226
|
+
*/
|
|
227
|
+
declare function normalizeFormatOptions(options?: FormatOptions | number): NormalizedFormatOptions;
|
|
228
|
+
/**
|
|
229
|
+
* Split a number into sign, coefficients, and exponent
|
|
230
|
+
* @param value The number or string to split
|
|
231
|
+
* @return Object containing sign, coefficients, and exponent
|
|
232
|
+
*/
|
|
233
|
+
declare function splitNumber(value: number | string): SplitValue;
|
|
234
|
+
/**
|
|
235
|
+
* Format a number in engineering notation. Like '1.23e+6', '2.3e+0', '3.500e-3'
|
|
236
|
+
* @param value The number or string to format
|
|
237
|
+
* @param precision Optional number of significant figures to return
|
|
238
|
+
* @returns The formatted string
|
|
239
|
+
*/
|
|
240
|
+
declare function toEngineering(value: number | string, precision?: number): string;
|
|
241
|
+
/**
|
|
242
|
+
* Format a number with fixed notation.
|
|
243
|
+
* @param value The number or string to format
|
|
244
|
+
* @param precision Optional number of decimals after the decimal point
|
|
245
|
+
* @returns The formatted string
|
|
246
|
+
*/
|
|
247
|
+
declare function toFixed(value: number | string, precision?: number): string;
|
|
248
|
+
/**
|
|
249
|
+
* Format a number in exponential notation. Like '1.23e+5', '2.3e+0', '3.500e-3'
|
|
250
|
+
* @param value The number or string to format
|
|
251
|
+
* @param precision Number of digits in formatted output
|
|
252
|
+
* @returns The formatted string
|
|
253
|
+
*/
|
|
254
|
+
declare function toExponential(value: number | string, precision?: number): string;
|
|
255
|
+
/**
|
|
256
|
+
* Format a number with a certain precision
|
|
257
|
+
* @param value The number or string to format
|
|
258
|
+
* @param precision Optional number of digits
|
|
259
|
+
* @param options Optional formatting options (lowerExp, upperExp)
|
|
260
|
+
* @return The formatted string
|
|
261
|
+
*/
|
|
262
|
+
declare function toPrecision(value: number | string, precision?: number, options?: FormatOptions): string;
|
|
263
|
+
/**
|
|
264
|
+
* Round the number of digits of a number
|
|
265
|
+
* @param split A value split with .splitNumber(value)
|
|
266
|
+
* @param precision A positive integer
|
|
267
|
+
* @return Object containing sign, coefficients, and exponent with rounded digits
|
|
268
|
+
*/
|
|
269
|
+
declare function roundDigits(split: SplitValue, precision?: number): SplitValue;
|
|
270
|
+
/**
|
|
271
|
+
* Count the number of significant digits of a number.
|
|
272
|
+
*
|
|
273
|
+
* For example:
|
|
274
|
+
* 2.34 returns 3
|
|
275
|
+
* 0.0034 returns 2
|
|
276
|
+
* 120.5e+30 returns 4
|
|
277
|
+
*
|
|
278
|
+
* @param value The number
|
|
279
|
+
* @return Number of significant digits
|
|
280
|
+
*/
|
|
281
|
+
declare function digits(value: number): number;
|
|
282
|
+
/**
|
|
283
|
+
* Compares two floating point numbers.
|
|
284
|
+
* @param a First value to compare
|
|
285
|
+
* @param b Second value to compare
|
|
286
|
+
* @param relTol The relative tolerance, indicating the maximum allowed difference relative to the larger absolute value. Must be greater than 0.
|
|
287
|
+
* @param absTol The minimum absolute tolerance, useful for comparisons near zero. Must be at least 0.
|
|
288
|
+
* @return whether the two numbers are nearly equal
|
|
289
|
+
*
|
|
290
|
+
* @throws Error If `relTol` is less than or equal to 0.
|
|
291
|
+
* @throws Error If `absTol` is less than 0.
|
|
292
|
+
*
|
|
293
|
+
* @example
|
|
294
|
+
* nearlyEqual(1.000000001, 1.0, 1e-8); // true
|
|
295
|
+
* nearlyEqual(1.000000002, 1.0, 0); // false
|
|
296
|
+
* nearlyEqual(1.0, 1.009, undefined, 0.01); // true
|
|
297
|
+
* nearlyEqual(0.000000001, 0.0, undefined, 1e-8); // true
|
|
298
|
+
*/
|
|
299
|
+
declare function nearlyEqual(a: number, b: number, relTol?: number, absTol?: number): boolean;
|
|
300
|
+
/**
|
|
301
|
+
* Calculate the hyperbolic arccos of a number
|
|
302
|
+
* @param x The number
|
|
303
|
+
* @return The hyperbolic arccosine
|
|
304
|
+
*/
|
|
305
|
+
declare const acosh: (x: number) => number;
|
|
306
|
+
/**
|
|
307
|
+
* Calculate the hyperbolic arcsine of a number
|
|
308
|
+
* @param x The number
|
|
309
|
+
* @return The hyperbolic arcsine
|
|
310
|
+
*/
|
|
311
|
+
declare const asinh: (x: number) => number;
|
|
312
|
+
/**
|
|
313
|
+
* Calculate the hyperbolic arctangent of a number
|
|
314
|
+
* @param x The number
|
|
315
|
+
* @return The hyperbolic arctangent
|
|
316
|
+
*/
|
|
317
|
+
declare const atanh: (x: number) => number;
|
|
318
|
+
/**
|
|
319
|
+
* Calculate the hyperbolic cosine of a number
|
|
320
|
+
* @param x The number
|
|
321
|
+
* @returns The hyperbolic cosine
|
|
322
|
+
*/
|
|
323
|
+
declare const cosh: (x: number) => number;
|
|
324
|
+
/**
|
|
325
|
+
* Calculate the hyperbolic sine of a number
|
|
326
|
+
* @param x The number
|
|
327
|
+
* @returns The hyperbolic sine
|
|
328
|
+
*/
|
|
329
|
+
declare const sinh: (x: number) => number;
|
|
330
|
+
/**
|
|
331
|
+
* Calculate the hyperbolic tangent of a number
|
|
332
|
+
* @param x The number
|
|
333
|
+
* @returns The hyperbolic tangent
|
|
334
|
+
*/
|
|
335
|
+
declare const tanh: (x: number) => number;
|
|
336
|
+
/**
|
|
337
|
+
* Returns a value with the magnitude of x and the sign of y.
|
|
338
|
+
* @param x The value providing the magnitude
|
|
339
|
+
* @param y The value providing the sign
|
|
340
|
+
* @returns Value with magnitude of x and sign of y
|
|
341
|
+
*/
|
|
342
|
+
declare function copysign(x: number, y: number): number;
|
|
343
|
+
/**
|
|
344
|
+
* Check if x^y is 0 due to infinity
|
|
345
|
+
* @param x The base
|
|
346
|
+
* @param y The exponent
|
|
347
|
+
* @returns true if x^y is 0 due to infinity
|
|
348
|
+
*/
|
|
349
|
+
declare function isPowZeroAtInfinity(x: number, y: number): boolean;
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* Shared utility functions used across core utility modules.
|
|
353
|
+
* This file must have ZERO imports from other core utility files
|
|
354
|
+
* to serve as the base of the dependency graph and break circular imports.
|
|
355
|
+
*/
|
|
356
|
+
/**
|
|
357
|
+
* A safe hasOwnProperty
|
|
358
|
+
* @param {Object} object
|
|
359
|
+
* @param {string} property
|
|
360
|
+
*/
|
|
361
|
+
declare function hasOwnProperty(object: unknown, property: string): boolean;
|
|
362
|
+
/**
|
|
363
|
+
* True when `text` ends with `search`. (Equivalent to `String.prototype.endsWith`;
|
|
364
|
+
* kept as a named helper so relocated modules read the same as their mathjs origin.)
|
|
365
|
+
*/
|
|
366
|
+
declare function endsWith(text: string, search: string): boolean;
|
|
367
|
+
/**
|
|
368
|
+
* Warn to the console at most once per distinct message, deduped for the process
|
|
369
|
+
* lifetime. Used for deprecation notices (e.g. `Unit.toNumber`).
|
|
370
|
+
*/
|
|
371
|
+
declare const warnOnce: (...args: unknown[]) => void;
|
|
372
|
+
/** A function whose results are cached; clear the cache with `delete fn.cache`. */
|
|
373
|
+
interface MemoizedFunction {
|
|
374
|
+
(...args: unknown[]): unknown;
|
|
375
|
+
cache?: Map<string, unknown>;
|
|
376
|
+
}
|
|
377
|
+
/**
|
|
378
|
+
* Memoize a pure function, caching results in a `Map` keyed by a string hash of the
|
|
379
|
+
* arguments (default `JSON.stringify`; override via `hasher`). Pass `limit` to bound
|
|
380
|
+
* the cache to N most-recently-used entries (LRU eviction via `Map` insertion order —
|
|
381
|
+
* on a hit the key is moved to the most-recent end; on overflow the oldest key is
|
|
382
|
+
* dropped); omit for an unbounded cache. The cache is exposed as `fn.cache` and can be
|
|
383
|
+
* reset with `delete fn.cache` — the next call lazily recreates it. (The relocated
|
|
384
|
+
* `Unit` relies on that reset when `createUnit`/`deleteUnit` invalidate the unit-name
|
|
385
|
+
* lookup cache, and passes `limit: 100` to bound the parse cache.)
|
|
386
|
+
*/
|
|
387
|
+
declare function memoize(fn: (...args: unknown[]) => unknown, { hasher, limit }?: {
|
|
388
|
+
hasher?: (args: unknown[]) => string;
|
|
389
|
+
limit?: number;
|
|
390
|
+
}): MemoizedFunction;
|
|
391
|
+
|
|
392
|
+
/**
|
|
393
|
+
* Clone an object
|
|
394
|
+
*
|
|
395
|
+
* clone(x)
|
|
396
|
+
*
|
|
397
|
+
* Can clone any primitive type, array, and object.
|
|
398
|
+
* If x has a function clone, this function will be invoked to clone the object.
|
|
399
|
+
*
|
|
400
|
+
* @param {*} x
|
|
401
|
+
* @return {*} clone
|
|
402
|
+
*/
|
|
403
|
+
declare function clone<T>(x: T): T;
|
|
404
|
+
/**
|
|
405
|
+
* Apply map to all properties of an object
|
|
406
|
+
* @param {Object} object
|
|
407
|
+
* @param {function} callback
|
|
408
|
+
* @return {Object} Returns a copy of the object with mapped properties
|
|
409
|
+
*/
|
|
410
|
+
declare function mapObject<T, U>(object: Record<string, T>, callback: (value: T) => U): Record<string, U>;
|
|
411
|
+
/**
|
|
412
|
+
* Extend object a with the properties of object b
|
|
413
|
+
* @param {Object} a
|
|
414
|
+
* @param {Object} b
|
|
415
|
+
* @return {Object} a
|
|
416
|
+
*/
|
|
417
|
+
declare function extend<T extends Record<string, unknown>, U extends Record<string, unknown>>(a: T, b: U): T & U;
|
|
418
|
+
/**
|
|
419
|
+
* Deep extend an object a with the properties of object b
|
|
420
|
+
* @param {Object} a
|
|
421
|
+
* @param {Object} b
|
|
422
|
+
* @returns {Object}
|
|
423
|
+
*/
|
|
424
|
+
declare function deepExtend<T>(a: T, b: unknown): T;
|
|
425
|
+
/**
|
|
426
|
+
* Deep test equality of all fields in two pairs of arrays or objects.
|
|
427
|
+
* Compares values and functions strictly (ie. 2 is not the same as '2').
|
|
428
|
+
* @param {Array | Object} a
|
|
429
|
+
* @param {Array | Object} b
|
|
430
|
+
* @returns {boolean}
|
|
431
|
+
*/
|
|
432
|
+
declare function deepStrictEqual(a: unknown, b: unknown): boolean;
|
|
433
|
+
/**
|
|
434
|
+
* Recursively flatten a nested object.
|
|
435
|
+
* @param {Object} nestedObject
|
|
436
|
+
* @return {Object} Returns the flattened object
|
|
437
|
+
*/
|
|
438
|
+
declare function deepFlatten(nestedObject: Record<string, unknown>): Record<string, unknown>;
|
|
439
|
+
/**
|
|
440
|
+
* Test whether the current JavaScript engine supports Object.defineProperty
|
|
441
|
+
* @returns {boolean} returns true if supported
|
|
442
|
+
*/
|
|
443
|
+
declare function canDefineProperty(): boolean;
|
|
444
|
+
/**
|
|
445
|
+
* Attach a lazy loading property to a constant.
|
|
446
|
+
* The given function `fn` is called once when the property is first requested.
|
|
447
|
+
*
|
|
448
|
+
* @param {Object} object Object where to add the property
|
|
449
|
+
* @param {string} prop Property name
|
|
450
|
+
* @param {Function} valueResolver Function returning the property value. Called
|
|
451
|
+
* without arguments.
|
|
452
|
+
*/
|
|
453
|
+
declare function lazy<T>(object: Record<string, unknown>, prop: string, valueResolver: () => T): void;
|
|
454
|
+
/**
|
|
455
|
+
* Traverse a path into an object.
|
|
456
|
+
* When a namespace is missing, it will be created
|
|
457
|
+
* @param {Object} object
|
|
458
|
+
* @param {string | string[]} path A dot separated string like 'name.space'
|
|
459
|
+
* @return {Object} Returns the object at the end of the path
|
|
460
|
+
*/
|
|
461
|
+
declare function traverse(object: Record<string, unknown>, path: string | string[]): Record<string, unknown>;
|
|
462
|
+
|
|
463
|
+
/**
|
|
464
|
+
* Test whether an object is a factory. a factory has fields:
|
|
465
|
+
*
|
|
466
|
+
* - factory: function (type: Object, config: Object, load: function, typed: function [, math: Object]) (required)
|
|
467
|
+
* - name: string (optional)
|
|
468
|
+
* - path: string A dot separated path (optional)
|
|
469
|
+
* - math: boolean If true (false by default), the math namespace is passed
|
|
470
|
+
* as fifth argument of the factory function
|
|
471
|
+
*
|
|
472
|
+
* @param {*} object
|
|
473
|
+
* @returns {boolean}
|
|
474
|
+
*/
|
|
475
|
+
declare function isLegacyFactory(object: unknown): boolean;
|
|
476
|
+
/**
|
|
477
|
+
* Get a nested property from an object
|
|
478
|
+
* @param {Object} object
|
|
479
|
+
* @param {string | string[]} path
|
|
480
|
+
* @returns {Object}
|
|
481
|
+
*/
|
|
482
|
+
declare function get(object: Record<string, unknown>, path: string | string[]): unknown;
|
|
483
|
+
/**
|
|
484
|
+
* Set a nested property in an object
|
|
485
|
+
* Mutates the object itself
|
|
486
|
+
* If the path doesn't exist, it will be created
|
|
487
|
+
* @param {Object} object
|
|
488
|
+
* @param {string | string[]} path
|
|
489
|
+
* @param {*} value
|
|
490
|
+
* @returns {Object}
|
|
491
|
+
*/
|
|
492
|
+
declare function set<T extends Record<string, unknown>>(object: T, path: string | string[], value: unknown): T;
|
|
493
|
+
/**
|
|
494
|
+
* Create an object composed of the picked object properties
|
|
495
|
+
* @param {Object} object
|
|
496
|
+
* @param {string[]} properties
|
|
497
|
+
* @param {function} [transform] Optional value to transform a value when picking it
|
|
498
|
+
* @return {Object}
|
|
499
|
+
*/
|
|
500
|
+
declare function pick(object: Record<string, unknown>, properties: string[], transform?: (value: unknown, key: string) => unknown): Record<string, unknown>;
|
|
501
|
+
/**
|
|
502
|
+
* Shallow version of pick, creating an object composed of the picked object properties
|
|
503
|
+
* but not for nested properties
|
|
504
|
+
* @param {Object} object
|
|
505
|
+
* @param {string[]} properties
|
|
506
|
+
* @return {Object}
|
|
507
|
+
*/
|
|
508
|
+
declare function pickShallow(object: Record<string, unknown>, properties: string[]): Record<string, unknown>;
|
|
509
|
+
|
|
510
|
+
export { type FormatOptions, type MemoizedFunction, type NormalizedFormatOptions, type NumberTypeConfig, type SplitValue, UnitConstructor, UnitDependencies, acosh, asinh, atanh, canDefineProperty, cbrt, clone, copysign, cosh, createUnitClass, deepExtend, deepFlatten, deepStrictEqual, digits, endsWith, expm1, extend, format, get, hasOwnProperty, isInteger, isLegacyFactory, isPowZeroAtInfinity, lazy, log10, log1p, log2, mapObject, memoize, nearlyEqual, normalizeFormatOptions, pick, pickShallow, roundDigits, safeNumberType, set, sign, sinh, splitNumber, tanh, toEngineering, toExponential, toFixed, toPrecision, traverse, unitDependencies, warnOnce };
|
package/dist/internal.js
ADDED
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
import {
|
|
2
|
+
Unit,
|
|
3
|
+
acosh,
|
|
4
|
+
asinh,
|
|
5
|
+
atanh,
|
|
6
|
+
canDefineProperty,
|
|
7
|
+
cbrt,
|
|
8
|
+
clone,
|
|
9
|
+
copysign,
|
|
10
|
+
cosh,
|
|
11
|
+
createUnitClass,
|
|
12
|
+
deepExtend,
|
|
13
|
+
deepFlatten,
|
|
14
|
+
deepStrictEqual,
|
|
15
|
+
digits,
|
|
16
|
+
endsWith,
|
|
17
|
+
expm1,
|
|
18
|
+
extend,
|
|
19
|
+
format,
|
|
20
|
+
get,
|
|
21
|
+
hasOwnProperty,
|
|
22
|
+
isArray,
|
|
23
|
+
isBigInt,
|
|
24
|
+
isBigNumber2 as isBigNumber,
|
|
25
|
+
isBoolean,
|
|
26
|
+
isCollection,
|
|
27
|
+
isComplex2 as isComplex,
|
|
28
|
+
isDate,
|
|
29
|
+
isDenseMatrix,
|
|
30
|
+
isFraction2 as isFraction,
|
|
31
|
+
isFunction,
|
|
32
|
+
isIndex,
|
|
33
|
+
isInteger,
|
|
34
|
+
isLegacyFactory,
|
|
35
|
+
isMap,
|
|
36
|
+
isMatrix,
|
|
37
|
+
isNull,
|
|
38
|
+
isNumber,
|
|
39
|
+
isObject,
|
|
40
|
+
isPowZeroAtInfinity,
|
|
41
|
+
isRange,
|
|
42
|
+
isRegExp,
|
|
43
|
+
isSparseMatrix,
|
|
44
|
+
isString,
|
|
45
|
+
isUndefined,
|
|
46
|
+
isUnit,
|
|
47
|
+
lazy,
|
|
48
|
+
log10,
|
|
49
|
+
log1p,
|
|
50
|
+
log2,
|
|
51
|
+
mapObject,
|
|
52
|
+
memoize,
|
|
53
|
+
nearlyEqual,
|
|
54
|
+
normalizeFormatOptions,
|
|
55
|
+
pick,
|
|
56
|
+
pickShallow,
|
|
57
|
+
roundDigits,
|
|
58
|
+
safeNumberType,
|
|
59
|
+
set,
|
|
60
|
+
sign,
|
|
61
|
+
sinh,
|
|
62
|
+
splitNumber,
|
|
63
|
+
tanh,
|
|
64
|
+
toEngineering,
|
|
65
|
+
toExponential,
|
|
66
|
+
toFixed,
|
|
67
|
+
toPrecision,
|
|
68
|
+
traverse,
|
|
69
|
+
typeOf,
|
|
70
|
+
unitDependencies,
|
|
71
|
+
warnOnce
|
|
72
|
+
} from "./chunk-ZPGSJR5L.js";
|
|
73
|
+
export {
|
|
74
|
+
Unit as CoreUnit,
|
|
75
|
+
acosh,
|
|
76
|
+
asinh,
|
|
77
|
+
atanh,
|
|
78
|
+
canDefineProperty,
|
|
79
|
+
cbrt,
|
|
80
|
+
clone,
|
|
81
|
+
copysign,
|
|
82
|
+
cosh,
|
|
83
|
+
createUnitClass,
|
|
84
|
+
deepExtend,
|
|
85
|
+
deepFlatten,
|
|
86
|
+
deepStrictEqual,
|
|
87
|
+
digits,
|
|
88
|
+
endsWith,
|
|
89
|
+
expm1,
|
|
90
|
+
extend,
|
|
91
|
+
format,
|
|
92
|
+
get,
|
|
93
|
+
hasOwnProperty,
|
|
94
|
+
isArray,
|
|
95
|
+
isBigInt,
|
|
96
|
+
isBigNumber,
|
|
97
|
+
isBoolean,
|
|
98
|
+
isCollection,
|
|
99
|
+
isComplex,
|
|
100
|
+
isDate,
|
|
101
|
+
isDenseMatrix,
|
|
102
|
+
isFraction,
|
|
103
|
+
isFunction,
|
|
104
|
+
isIndex,
|
|
105
|
+
isInteger,
|
|
106
|
+
isLegacyFactory,
|
|
107
|
+
isMap,
|
|
108
|
+
isMatrix,
|
|
109
|
+
isNull,
|
|
110
|
+
isNumber,
|
|
111
|
+
isObject,
|
|
112
|
+
isPowZeroAtInfinity,
|
|
113
|
+
isRange,
|
|
114
|
+
isRegExp,
|
|
115
|
+
isSparseMatrix,
|
|
116
|
+
isString,
|
|
117
|
+
isUndefined,
|
|
118
|
+
isUnit,
|
|
119
|
+
lazy,
|
|
120
|
+
log10,
|
|
121
|
+
log1p,
|
|
122
|
+
log2,
|
|
123
|
+
mapObject,
|
|
124
|
+
memoize,
|
|
125
|
+
nearlyEqual,
|
|
126
|
+
normalizeFormatOptions,
|
|
127
|
+
pick,
|
|
128
|
+
pickShallow,
|
|
129
|
+
roundDigits,
|
|
130
|
+
safeNumberType,
|
|
131
|
+
set,
|
|
132
|
+
sign,
|
|
133
|
+
sinh,
|
|
134
|
+
splitNumber,
|
|
135
|
+
tanh,
|
|
136
|
+
toEngineering,
|
|
137
|
+
toExponential,
|
|
138
|
+
toFixed,
|
|
139
|
+
toPrecision,
|
|
140
|
+
traverse,
|
|
141
|
+
typeOf,
|
|
142
|
+
unitDependencies,
|
|
143
|
+
warnOnce
|
|
144
|
+
};
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@danielsimonjr/mathts-core",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.4.1",
|
|
4
4
|
"description": "Core types, utilities, and configuration for MathTS",
|
|
5
5
|
"author": "Daniel Simon Jr.",
|
|
6
6
|
"license": "MIT",
|
|
@@ -12,6 +12,10 @@
|
|
|
12
12
|
".": {
|
|
13
13
|
"import": "./dist/index.js",
|
|
14
14
|
"types": "./dist/index.d.ts"
|
|
15
|
+
},
|
|
16
|
+
"./internal": {
|
|
17
|
+
"import": "./dist/internal.js",
|
|
18
|
+
"types": "./dist/internal.d.ts"
|
|
15
19
|
}
|
|
16
20
|
},
|
|
17
21
|
"files": [
|
|
@@ -19,8 +23,8 @@
|
|
|
19
23
|
"README.md"
|
|
20
24
|
],
|
|
21
25
|
"scripts": {
|
|
22
|
-
"build": "tsup src/index.ts --format esm --dts --clean",
|
|
23
|
-
"dev": "tsup src/index.ts --format esm --dts --watch",
|
|
26
|
+
"build": "tsup src/index.ts src/internal.ts --format esm --dts --clean",
|
|
27
|
+
"dev": "tsup src/index.ts src/internal.ts --format esm --dts --watch",
|
|
24
28
|
"test": "vitest run",
|
|
25
29
|
"test:watch": "vitest",
|
|
26
30
|
"test:coverage": "vitest run --coverage",
|