@danielsimonjr/mathts-core 0.13.0 → 0.14.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.
@@ -914,9 +914,7 @@ function toPrecision(value, precision, options) {
914
914
  if (precision && c.length < precision) {
915
915
  c = c.concat(zeros(precision - c.length));
916
916
  }
917
- c = c.concat(
918
- zeros(e - c.length + 1 + (precision && c.length < precision ? precision - c.length : 0))
919
- );
917
+ c = c.concat(zeros(e - c.length + 1));
920
918
  c = zeros(-e).concat(c);
921
919
  const dot = e > 0 ? e : 0;
922
920
  if (dot < c.length - 1) {
package/dist/index.d.ts CHANGED
@@ -2584,6 +2584,6 @@ declare function neumaierCumsum(xs: ArrayLike<number>, out: {
2584
2584
  * @packageDocumentation
2585
2585
  */
2586
2586
 
2587
- declare const VERSION = "0.1.0";
2587
+ declare const VERSION: string;
2588
2588
 
2589
2589
  export { ALL_UNITS, BASE_UNITS, BEST_PREFIXES, BIGNUMBER_E, BIGNUMBER_LN10, BIGNUMBER_LN2, BIGNUMBER_NEG_ONE, BIGNUMBER_ONE, BIGNUMBER_PI, BIGNUMBER_TEN, BIGNUMBER_ZERO, type BackendType, BigNumber, type BigNumberConfig, COMPLEX_NEG_ONE, COMPLEX_ONE, COMPLEX_ZERO, Complex, type ConversionDef, DEFAULT_CONFIG, DERIVED_UNITS, DIMENSIONLESS, DUAL_UNARY_RULES, DimensionMismatchError, type Dimensions, Dual, type DualUnaryRule, type DualUnaryRuleName, E, FRACTION_HALF, FRACTION_NEG_ONE, FRACTION_ONE, FRACTION_QUARTER, FRACTION_THIRD, FRACTION_ZERO, type FactoryDependencies, type FactoryFunction, type FactoryImport, Fraction, FunctionRegistry, I, type IBigNumber, type IComplex, type IFraction, type IMatrix, LN10, LN2, LOG10E, LOG2E, MATHTS_CONVERSIONS, MATHTS_TYPES, type MathTSConfig, type MathTSValue, type MatrixBackend, type MatrixDimensions, type NumericScalar, type NumericType, PHI, PI, Range, type RangeForEachCallback, type RangeFormatOptions, type RangeJSON, type RangeMapCallback, type RoundingMode, SI_PREFIXES, SQRT1_2, SQRT2, type Scalar, TAU, type TypeDef, TypeRegistry, UNIT_ALIASES, type UnitDef, UnitParseError, VERSION, abs, addScalar, createFactory, createMathTSTyped, createRangeClass, createTypedFunction, dim, divideScalar, equal, fix, getPrefix, getUnitDef, initTypedWasm, isArray, isBigInt, isBigNumber, isBoolean, isComplex, isDenseMatrix, isDual, isFraction, isFunction, isMatrix, isNull, isNumber, isNumeric, isObject, isSparseMatrix, isString, isTypedWasmAvailable, isUndefined, isUnit, math, mathTyped, multiplyScalar, neumaierCumsum, neumaierSum, norm2, number, pairwiseDot, pairwiseSum, pow, registerNativeTypes, registry, round, scaledDistance, subtractScalar, sumSquaredDeviations };
package/dist/index.js CHANGED
@@ -44,7 +44,7 @@ import {
44
44
  round,
45
45
  sign,
46
46
  subtractScalar
47
- } from "./chunk-7BUNGMQB.js";
47
+ } from "./chunk-YZN52XIQ.js";
48
48
 
49
49
  // src/types/matrix/Range.ts
50
50
  var name = "Range";
@@ -1321,7 +1321,7 @@ function neumaierCumsum(xs, out) {
1321
1321
  }
1322
1322
 
1323
1323
  // src/index.ts
1324
- var VERSION = "0.1.0";
1324
+ var VERSION = "0.14.0";
1325
1325
  export {
1326
1326
  ALL_UNITS,
1327
1327
  BASE_UNITS,
package/dist/internal.js CHANGED
@@ -78,7 +78,7 @@ import {
78
78
  typeOf,
79
79
  unitDependencies,
80
80
  warnOnce
81
- } from "./chunk-7BUNGMQB.js";
81
+ } from "./chunk-YZN52XIQ.js";
82
82
 
83
83
  // src/error/DimensionError.ts
84
84
  var DimensionError = class _DimensionError extends RangeError {
@@ -226,13 +226,31 @@ function format2(value, options) {
226
226
  return formatBigNumberToBase(v, 16, wordSize);
227
227
  case "auto": {
228
228
  const optionsObj = options;
229
- const lowerExp = _toNumberOrDefault(optionsObj?.lowerExp, -3);
230
- const upperExp = _toNumberOrDefault(optionsObj?.upperExp, 5);
229
+ const lowerExp = isNumber(optionsObj?.lowerExp) || isBigNumber(optionsObj?.lowerExp) ? optionsObj?.lowerExp : -3;
230
+ const upperExp = isNumber(optionsObj?.upperExp) || isBigNumber(optionsObj?.upperExp) ? optionsObj?.upperExp : 5;
231
231
  if (v.isZero()) return "0";
232
232
  let str;
233
233
  const rounded = v.toSignificantDigits(precision);
234
234
  const exp = rounded.e;
235
- if (exp >= lowerExp && exp < upperExp) {
235
+ let condition = false;
236
+ if (isBigNumber(lowerExp) && isBigNumber(upperExp)) {
237
+ const lowerExpBn = lowerExp;
238
+ const upperExpBn = upperExp;
239
+ condition = !lowerExpBn.greaterThan(exp) && upperExpBn.greaterThan(exp);
240
+ } else if (isBigNumber(lowerExp)) {
241
+ const lowerExpBn = lowerExp;
242
+ const upperExpNum = upperExp;
243
+ condition = !lowerExpBn.greaterThan(exp) && exp < upperExpNum;
244
+ } else if (isBigNumber(upperExp)) {
245
+ const upperExpBn = upperExp;
246
+ const lowerExpNum = lowerExp;
247
+ condition = exp >= lowerExpNum && upperExpBn.greaterThan(exp);
248
+ } else {
249
+ const lowerExpNum = lowerExp;
250
+ const upperExpNum = upperExp;
251
+ condition = exp >= lowerExpNum && exp < upperExpNum;
252
+ }
253
+ if (condition) {
236
254
  str = rounded.toFixed();
237
255
  } else {
238
256
  str = toExponential2(v, precision);
@@ -271,15 +289,6 @@ function toExponential2(value, precision) {
271
289
  function toFixed2(value, precision) {
272
290
  return value.toFixed(precision);
273
291
  }
274
- function _toNumberOrDefault(value, defaultValue) {
275
- if (isNumber(value)) {
276
- return value;
277
- } else if (isBigNumber(value)) {
278
- return value.toNumber();
279
- } else {
280
- return defaultValue;
281
- }
282
- }
283
292
 
284
293
  // src/string.ts
285
294
  function format3(value, options) {
@@ -1024,7 +1033,7 @@ function deepMap2(array, callback, skipZeros) {
1024
1033
  function reduce(mat, dim, callback) {
1025
1034
  const size = Array.isArray(mat) ? arraySize(mat) : mat.size();
1026
1035
  if (dim < 0 || dim >= size.length) {
1027
- throw new IndexError(dim, 0, size.length);
1036
+ throw new DimensionError(dim, size.length, "<");
1028
1037
  }
1029
1038
  if (isMatrix(mat)) {
1030
1039
  const reduced = _reduce(mat.valueOf(), dim, callback);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@danielsimonjr/mathts-core",
3
- "version": "0.13.0",
3
+ "version": "0.14.0",
4
4
  "description": "Core types, utilities, and configuration for MathTS",
5
5
  "author": "Daniel Simon Jr.",
6
6
  "license": "MIT",
@@ -23,8 +23,8 @@
23
23
  "README.md"
24
24
  ],
25
25
  "scripts": {
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",
26
+ "build": "tsup",
27
+ "dev": "tsup --watch",
28
28
  "test": "vitest run",
29
29
  "test:watch": "vitest",
30
30
  "test:coverage": "vitest run --coverage",
@@ -32,7 +32,7 @@
32
32
  "lint": "eslint src --ext .ts",
33
33
  "lint:fix": "eslint src --ext .ts --fix",
34
34
  "clean": "rm -rf dist",
35
- "build:prod": "tsup src/index.ts --format esm --dts --clean --minify --treeshake"
35
+ "build:prod": "tsup --minify --treeshake"
36
36
  },
37
37
  "dependencies": {
38
38
  "typed-function": "github:danielsimonjr/typed-function"
@@ -48,7 +48,7 @@
48
48
  },
49
49
  "repository": {
50
50
  "type": "git",
51
- "url": "https://github.com/danielsimonjr/mathts",
51
+ "url": "git+https://github.com/danielsimonjr/MathTS.git",
52
52
  "directory": "core"
53
53
  },
54
54
  "keywords": [