mirror of
https://github.com/josdejong/mathjs.git
synced 2026-02-01 16:07:46 +00:00
Merge branch 'develop'
This commit is contained in:
commit
6bbdb652e9
1
AUTHORS
1
AUTHORS
@ -249,5 +249,6 @@ Laurent Gérin <41303636+lgerin@users.noreply.github.com>
|
||||
Adam Jones <domdomegg+git@gmail.com>
|
||||
Lucas Eng <lucaseng19@gmail.com>
|
||||
Orel Ben Neriah <77707952+orelbn@users.noreply.github.com>
|
||||
Vistinum <eugene225@gmail.com>
|
||||
|
||||
# Generated by tools/update-authors.js
|
||||
|
||||
@ -1,5 +1,14 @@
|
||||
# History
|
||||
|
||||
# 2024-07-18, 13.0.3
|
||||
|
||||
- Fix: #3232 fix type definitions of function `format` to support notations
|
||||
`hex`, `bin`, and `oct`.
|
||||
- Fix: use more precise definitions for US liquid volume units (#3229).
|
||||
Thanks @Vistinum.
|
||||
- Fix: #2286 types static methods and members for Unit class (#3230).
|
||||
Thanks @orelbn.
|
||||
|
||||
# 2024-07-04, 13.0.2
|
||||
|
||||
- Fix an error in the type definitions of `quantileSeq` (#3223).
|
||||
|
||||
507
examples/code editor/package-lock.json
generated
507
examples/code editor/package-lock.json
generated
File diff suppressed because it is too large
Load Diff
@ -9,14 +9,14 @@
|
||||
"preview": "vite preview"
|
||||
},
|
||||
"devDependencies": {
|
||||
"vite": "5.0.11"
|
||||
"vite": "5.3.3"
|
||||
},
|
||||
"dependencies": {
|
||||
"@codemirror/language": "6.10.0",
|
||||
"@codemirror/state": "6.4.0",
|
||||
"@codemirror/language": "6.10.2",
|
||||
"@codemirror/state": "6.4.1",
|
||||
"codemirror": "6.0.1",
|
||||
"github-markdown-css": "5.5.0",
|
||||
"katex": "0.16.9",
|
||||
"mathjs": "12.3.0"
|
||||
"github-markdown-css": "5.6.1",
|
||||
"katex": "0.16.11",
|
||||
"mathjs": "13.0.2"
|
||||
}
|
||||
}
|
||||
|
||||
559
package-lock.json
generated
559
package-lock.json
generated
File diff suppressed because it is too large
Load Diff
22
package.json
22
package.json
@ -1,6 +1,6 @@
|
||||
{
|
||||
"name": "mathjs",
|
||||
"version": "13.0.2",
|
||||
"version": "13.0.3",
|
||||
"description": "Math.js is an extensive math library for JavaScript and Node.js. It features a flexible expression parser with support for symbolic computation, comes with a large set of built-in functions and constants, and offers an integrated solution to work with different data types like numbers, big numbers, complex numbers, fractions, units, and matrices.",
|
||||
"author": "Jos de Jong <wjosdejong@gmail.com> (https://github.com/josdejong)",
|
||||
"homepage": "https://mathjs.org",
|
||||
@ -25,7 +25,7 @@
|
||||
"unit"
|
||||
],
|
||||
"dependencies": {
|
||||
"@babel/runtime": "^7.24.7",
|
||||
"@babel/runtime": "^7.24.8",
|
||||
"complex.js": "^2.1.1",
|
||||
"decimal.js": "^10.4.3",
|
||||
"escape-latex": "^1.2.0",
|
||||
@ -36,16 +36,16 @@
|
||||
"typed-function": "^4.2.1"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@babel/core": "7.24.7",
|
||||
"@babel/core": "7.24.9",
|
||||
"@babel/plugin-transform-object-assign": "7.24.7",
|
||||
"@babel/plugin-transform-optional-catch-binding": "7.24.7",
|
||||
"@babel/plugin-transform-runtime": "7.24.7",
|
||||
"@babel/preset-env": "7.24.7",
|
||||
"@babel/preset-env": "7.24.8",
|
||||
"@babel/register": "7.24.6",
|
||||
"@types/assert": "1.5.10",
|
||||
"@types/mocha": "10.0.7",
|
||||
"@typescript-eslint/eslint-plugin": "7.15.0",
|
||||
"@typescript-eslint/parser": "7.15.0",
|
||||
"@typescript-eslint/eslint-plugin": "7.16.1",
|
||||
"@typescript-eslint/parser": "7.16.1",
|
||||
"assert": "2.1.0",
|
||||
"babel-loader": "9.1.3",
|
||||
"benchmark": "2.1.4",
|
||||
@ -60,16 +60,16 @@
|
||||
"eslint-plugin-import": "2.29.1",
|
||||
"eslint-plugin-mocha": "10.4.3",
|
||||
"eslint-plugin-n": "16.6.2",
|
||||
"eslint-plugin-prettier": "5.1.3",
|
||||
"eslint-plugin-prettier": "5.2.1",
|
||||
"eslint-plugin-promise": "6.4.0",
|
||||
"expect-type": "0.19.0",
|
||||
"expr-eval": "2.0.2",
|
||||
"fancy-log": "2.0.0",
|
||||
"glob": "10.4.2",
|
||||
"glob": "11.0.0",
|
||||
"gulp": "5.0.0",
|
||||
"gulp-babel": "8.0.0",
|
||||
"handlebars": "4.7.8",
|
||||
"jsep": "1.3.8",
|
||||
"jsep": "1.3.9",
|
||||
"karma": "6.4.3",
|
||||
"karma-browserstack-launcher": "1.6.0",
|
||||
"karma-firefox-launcher": "2.1.3",
|
||||
@ -86,13 +86,13 @@
|
||||
"ndarray-pack": "1.2.1",
|
||||
"numericjs": "1.2.6",
|
||||
"pad-right": "0.2.2",
|
||||
"prettier": "3.3.2",
|
||||
"prettier": "3.3.3",
|
||||
"process": "0.11.10",
|
||||
"sinon": "18.0.0",
|
||||
"sylvester": "0.0.21",
|
||||
"ts-node": "10.9.2",
|
||||
"typescript": "5.5.3",
|
||||
"webpack": "5.92.1",
|
||||
"webpack": "5.93.0",
|
||||
"zeros": "1.0.0"
|
||||
},
|
||||
"type": "module",
|
||||
|
||||
@ -466,7 +466,7 @@ export const createUnitClass = /* #__PURE__ */ factory(name, dependencies, ({
|
||||
* Return the type of the value of this unit
|
||||
*
|
||||
* @memberof Unit
|
||||
* @ return {string} type of the value of the unit
|
||||
* @return {string} type of the value of the unit
|
||||
*/
|
||||
Unit.prototype.valueType = function () {
|
||||
return typeOf(this.value)
|
||||
@ -476,6 +476,7 @@ export const createUnitClass = /* #__PURE__ */ factory(name, dependencies, ({
|
||||
* Return whether the unit is derived (such as m/s, or cm^2, but not N)
|
||||
* @memberof Unit
|
||||
* @return {boolean} True if the unit is derived
|
||||
* @private
|
||||
*/
|
||||
Unit.prototype._isDerived = function () {
|
||||
if (this.units.length === 0) {
|
||||
@ -585,7 +586,7 @@ export const createUnitClass = /* #__PURE__ */ factory(name, dependencies, ({
|
||||
* check if this unit has given base unit
|
||||
* If this unit is a derived unit, this will ALWAYS return false, since by definition base units are not derived.
|
||||
* @memberof Unit
|
||||
* @param {BASE_UNITS | string | undefined} base
|
||||
* @param {BASE_UNIT | string | undefined} base
|
||||
*/
|
||||
Unit.prototype.hasBase = function (base) {
|
||||
if (typeof (base) === 'string') {
|
||||
@ -1833,30 +1834,30 @@ export const createUnitClass = /* #__PURE__ */ factory(name, dependencies, ({
|
||||
name: 'minim',
|
||||
base: BASE_UNITS.VOLUME,
|
||||
prefixes: PREFIXES.NONE,
|
||||
value: 0.00000006161152,
|
||||
value: 0.000000061611519921875,
|
||||
offset: 0
|
||||
}, // 0.06161152 mL
|
||||
}, // 1/61440 gallons
|
||||
fluiddram: {
|
||||
name: 'fluiddram',
|
||||
base: BASE_UNITS.VOLUME,
|
||||
prefixes: PREFIXES.NONE,
|
||||
value: 0.0000036966911,
|
||||
value: 0.0000036966911953125,
|
||||
offset: 0
|
||||
}, // 3.696691 mL
|
||||
}, // 1/1024 gallons
|
||||
fluidounce: {
|
||||
name: 'fluidounce',
|
||||
base: BASE_UNITS.VOLUME,
|
||||
prefixes: PREFIXES.NONE,
|
||||
value: 0.00002957353,
|
||||
value: 0.0000295735295625,
|
||||
offset: 0
|
||||
}, // 29.57353 mL
|
||||
}, // 1/128 gallons
|
||||
gill: {
|
||||
name: 'gill',
|
||||
base: BASE_UNITS.VOLUME,
|
||||
prefixes: PREFIXES.NONE,
|
||||
value: 0.0001182941,
|
||||
value: 0.00011829411825,
|
||||
offset: 0
|
||||
}, // 118.2941 mL
|
||||
}, // 1/32 gallons
|
||||
cc: {
|
||||
name: 'cc',
|
||||
base: BASE_UNITS.VOLUME,
|
||||
@ -1868,117 +1869,51 @@ export const createUnitClass = /* #__PURE__ */ factory(name, dependencies, ({
|
||||
name: 'cup',
|
||||
base: BASE_UNITS.VOLUME,
|
||||
prefixes: PREFIXES.NONE,
|
||||
value: 0.0002365882,
|
||||
value: 0.0002365882365,
|
||||
offset: 0
|
||||
}, // 236.5882 mL
|
||||
}, // 1/16 gallons
|
||||
pint: {
|
||||
name: 'pint',
|
||||
base: BASE_UNITS.VOLUME,
|
||||
prefixes: PREFIXES.NONE,
|
||||
value: 0.0004731765,
|
||||
value: 0.000473176473,
|
||||
offset: 0
|
||||
}, // 473.1765 mL
|
||||
}, // 1/8 gallons
|
||||
quart: {
|
||||
name: 'quart',
|
||||
base: BASE_UNITS.VOLUME,
|
||||
prefixes: PREFIXES.NONE,
|
||||
value: 0.0009463529,
|
||||
value: 0.000946352946,
|
||||
offset: 0
|
||||
}, // 946.3529 mL
|
||||
}, // 1/4 gallons
|
||||
gallon: {
|
||||
name: 'gallon',
|
||||
base: BASE_UNITS.VOLUME,
|
||||
prefixes: PREFIXES.NONE,
|
||||
value: 0.003785412,
|
||||
value: 0.003785411784,
|
||||
offset: 0
|
||||
}, // 3.785412 L
|
||||
}, // 3.785411784 L
|
||||
beerbarrel: {
|
||||
name: 'beerbarrel',
|
||||
base: BASE_UNITS.VOLUME,
|
||||
prefixes: PREFIXES.NONE,
|
||||
value: 0.1173478,
|
||||
value: 0.117347765304,
|
||||
offset: 0
|
||||
}, // 117.3478 L
|
||||
}, // 31 gallons
|
||||
oilbarrel: {
|
||||
name: 'oilbarrel',
|
||||
base: BASE_UNITS.VOLUME,
|
||||
prefixes: PREFIXES.NONE,
|
||||
value: 0.1589873,
|
||||
value: 0.158987294928,
|
||||
offset: 0
|
||||
}, // 158.9873 L
|
||||
}, // 42 gallons
|
||||
hogshead: {
|
||||
name: 'hogshead',
|
||||
base: BASE_UNITS.VOLUME,
|
||||
prefixes: PREFIXES.NONE,
|
||||
value: 0.2384810,
|
||||
value: 0.238480942392,
|
||||
offset: 0
|
||||
}, // 238.4810 L
|
||||
|
||||
// {name: 'min', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.00000006161152, offset: 0}, // 0.06161152 mL // min is already in use as minute
|
||||
fldr: {
|
||||
name: 'fldr',
|
||||
base: BASE_UNITS.VOLUME,
|
||||
prefixes: PREFIXES.NONE,
|
||||
value: 0.0000036966911,
|
||||
offset: 0
|
||||
}, // 3.696691 mL
|
||||
floz: {
|
||||
name: 'floz',
|
||||
base: BASE_UNITS.VOLUME,
|
||||
prefixes: PREFIXES.NONE,
|
||||
value: 0.00002957353,
|
||||
offset: 0
|
||||
}, // 29.57353 mL
|
||||
gi: {
|
||||
name: 'gi',
|
||||
base: BASE_UNITS.VOLUME,
|
||||
prefixes: PREFIXES.NONE,
|
||||
value: 0.0001182941,
|
||||
offset: 0
|
||||
}, // 118.2941 mL
|
||||
cp: {
|
||||
name: 'cp',
|
||||
base: BASE_UNITS.VOLUME,
|
||||
prefixes: PREFIXES.NONE,
|
||||
value: 0.0002365882,
|
||||
offset: 0
|
||||
}, // 236.5882 mL
|
||||
pt: {
|
||||
name: 'pt',
|
||||
base: BASE_UNITS.VOLUME,
|
||||
prefixes: PREFIXES.NONE,
|
||||
value: 0.0004731765,
|
||||
offset: 0
|
||||
}, // 473.1765 mL
|
||||
qt: {
|
||||
name: 'qt',
|
||||
base: BASE_UNITS.VOLUME,
|
||||
prefixes: PREFIXES.NONE,
|
||||
value: 0.0009463529,
|
||||
offset: 0
|
||||
}, // 946.3529 mL
|
||||
gal: {
|
||||
name: 'gal',
|
||||
base: BASE_UNITS.VOLUME,
|
||||
prefixes: PREFIXES.NONE,
|
||||
value: 0.003785412,
|
||||
offset: 0
|
||||
}, // 3.785412 L
|
||||
bbl: {
|
||||
name: 'bbl',
|
||||
base: BASE_UNITS.VOLUME,
|
||||
prefixes: PREFIXES.NONE,
|
||||
value: 0.1173478,
|
||||
offset: 0
|
||||
}, // 117.3478 L
|
||||
obl: {
|
||||
name: 'obl',
|
||||
base: BASE_UNITS.VOLUME,
|
||||
prefixes: PREFIXES.NONE,
|
||||
value: 0.1589873,
|
||||
offset: 0
|
||||
}, // 158.9873 L
|
||||
// {name: 'hogshead', base: BASE_UNITS.VOLUME, prefixes: PREFIXES.NONE, value: 0.2384810, offset: 0}, // 238.4810 L // TODO: hh?
|
||||
}, // 63 gallons
|
||||
|
||||
// Mass
|
||||
g: {
|
||||
@ -2786,14 +2721,23 @@ export const createUnitClass = /* #__PURE__ */ factory(name, dependencies, ({
|
||||
teaspoons: 'teaspoon',
|
||||
tablespoons: 'tablespoon',
|
||||
minims: 'minim',
|
||||
fldr: 'fluiddram',
|
||||
fluiddrams: 'fluiddram',
|
||||
floz: 'fluidounce',
|
||||
fluidounces: 'fluidounce',
|
||||
gi: 'gill',
|
||||
gills: 'gill',
|
||||
cp: 'cup',
|
||||
cups: 'cup',
|
||||
pt: 'pint',
|
||||
pints: 'pint',
|
||||
qt: 'quart',
|
||||
quarts: 'quart',
|
||||
gal: 'gallon',
|
||||
gallons: 'gallon',
|
||||
bbl: 'beerbarrel',
|
||||
beerbarrels: 'beerbarrel',
|
||||
obl: 'oilbarrel',
|
||||
oilbarrels: 'oilbarrel',
|
||||
hogsheads: 'hogshead',
|
||||
gtts: 'gtt',
|
||||
@ -2975,6 +2919,7 @@ export const createUnitClass = /* #__PURE__ */ factory(name, dependencies, ({
|
||||
|
||||
/**
|
||||
* Set a unit system for formatting derived units.
|
||||
* @memberof Unit
|
||||
* @param {string} [name] The name of the unit system.
|
||||
*/
|
||||
Unit.setUnitSystem = function (name) {
|
||||
@ -2987,6 +2932,7 @@ export const createUnitClass = /* #__PURE__ */ factory(name, dependencies, ({
|
||||
|
||||
/**
|
||||
* Return the current unit system.
|
||||
* @memberof Unit
|
||||
* @return {string} The current unit system.
|
||||
*/
|
||||
Unit.getUnitSystem = function () {
|
||||
@ -3080,7 +3026,9 @@ export const createUnitClass = /* #__PURE__ */ factory(name, dependencies, ({
|
||||
/**
|
||||
* Checks if a character is a valid latin letter (upper or lower case).
|
||||
* Note that this function can be overridden, for example to allow support of other alphabets.
|
||||
* @memberof Unit
|
||||
* @param {string} c Tested character
|
||||
* @return {boolean} true if the character is a latin letter
|
||||
*/
|
||||
Unit.isValidAlpha = function isValidAlpha (c) {
|
||||
return /^[a-zA-Z]$/.test(c)
|
||||
@ -3100,20 +3048,24 @@ export const createUnitClass = /* #__PURE__ */ factory(name, dependencies, ({
|
||||
/**
|
||||
* Wrapper around createUnitSingle.
|
||||
* Example:
|
||||
* createUnit({
|
||||
* foo: { },
|
||||
* bar: {
|
||||
* definition: 'kg/foo',
|
||||
* aliases: ['ba', 'barr', 'bars'],
|
||||
* offset: 200
|
||||
* },
|
||||
* baz: '4 bar'
|
||||
* },
|
||||
* {
|
||||
* override: true
|
||||
* })
|
||||
* createUnit( {
|
||||
* foo: {
|
||||
* prefixes: 'long',
|
||||
* baseName: 'essence-of-foo'
|
||||
* },
|
||||
* bar: '40 foo',
|
||||
* baz: {
|
||||
* definition: '1 bar/hour',
|
||||
* prefixes: 'long'
|
||||
* }
|
||||
* },
|
||||
* {
|
||||
* override: true
|
||||
* })
|
||||
* @memberof Unit
|
||||
* @param {object} obj Object map. Each key becomes a unit which is defined by its value.
|
||||
* @param {object} options
|
||||
* @return {Unit} the last created unit
|
||||
*/
|
||||
Unit.createUnit = function (obj, options) {
|
||||
if (typeof (obj) !== 'object') {
|
||||
@ -3148,13 +3100,13 @@ export const createUnitClass = /* #__PURE__ */ factory(name, dependencies, ({
|
||||
* Create a user-defined unit and register it with the Unit type.
|
||||
* Example:
|
||||
* createUnitSingle('knot', '0.514444444 m/s')
|
||||
* createUnitSingle('acre', new Unit(43560, 'ft^2'))
|
||||
*
|
||||
* @memberof Unit
|
||||
* @param {string} name The name of the new unit. Must be unique. Example: 'knot'
|
||||
* @param {string, Unit, Object} definition Definition of the unit in terms
|
||||
* @param {string | Unit | object} definition Definition of the unit in terms
|
||||
* of existing units. For example, '0.514444444 m / s'. Can be a Unit, a string,
|
||||
* or an Object. If an Object, may have the following properties:
|
||||
* - definition {string|Unit} The definition of this unit.
|
||||
* - definition {string | Unit} The definition of this unit.
|
||||
* - prefixes {string} "none", "short", "long", "binary_short", or "binary_long".
|
||||
* The default is "none".
|
||||
* - aliases {Array} Array of strings. Example: ['knots', 'kt', 'kts']
|
||||
|
||||
@ -1,3 +1,3 @@
|
||||
export const version = '13.0.2'
|
||||
export const version = '13.0.3'
|
||||
// Note: This file is automatically generated when building math.js.
|
||||
// Changes made in this file will be overwritten.
|
||||
|
||||
@ -43,6 +43,7 @@ import {
|
||||
SymbolNode,
|
||||
MathNodeCommon,
|
||||
Unit,
|
||||
UnitPrefix,
|
||||
Node,
|
||||
isSymbolNode,
|
||||
MathScalarType
|
||||
@ -1609,6 +1610,59 @@ Units examples
|
||||
math.unit('1 m').splitUnit(['ft', 'in'])
|
||||
}
|
||||
|
||||
/**
|
||||
* Unit static methods and members
|
||||
*/
|
||||
{
|
||||
expectTypeOf(new Unit(15, 'cm')).toMatchTypeOf<Unit>()
|
||||
|
||||
const prefixes = Unit.PREFIXES
|
||||
assert.ok(Object.keys(prefixes).length > 0)
|
||||
expectTypeOf(Unit.PREFIXES).toMatchTypeOf<Record<string, UnitPrefix>>()
|
||||
|
||||
const baseDimensions = Unit.BASE_DIMENSIONS
|
||||
assert.ok(baseDimensions.length > 0)
|
||||
expectTypeOf(Unit.BASE_DIMENSIONS).toMatchTypeOf<string[]>()
|
||||
|
||||
const baseUnits = Unit.BASE_UNITS
|
||||
assert.ok(Object.keys(baseUnits).length > 0)
|
||||
|
||||
const units = Unit.UNITS
|
||||
assert.ok(Object.keys(units).length > 0)
|
||||
|
||||
Unit.createUnit(
|
||||
{
|
||||
foo: {
|
||||
prefixes: 'long',
|
||||
baseName: 'essence-of-foo'
|
||||
},
|
||||
bar: '40 foo',
|
||||
baz: {
|
||||
definition: '1 bar/hour',
|
||||
prefixes: 'long'
|
||||
}
|
||||
},
|
||||
{
|
||||
override: true
|
||||
}
|
||||
)
|
||||
|
||||
Unit.createUnitSingle('knot', '0.514444444 m/s')
|
||||
|
||||
const unitSystems = Unit.UNIT_SYSTEMS
|
||||
assert.ok(Object.keys(unitSystems).length > 0)
|
||||
|
||||
Unit.setUnitSystem('si')
|
||||
assert.strictEqual(Unit.getUnitSystem(), 'si')
|
||||
|
||||
expectTypeOf(Unit.isValuelessUnit('cm')).toMatchTypeOf<boolean>()
|
||||
expectTypeOf(Unit.parse('5cm')).toMatchTypeOf<Unit>()
|
||||
expectTypeOf(
|
||||
Unit.fromJSON({ value: 5.2, unit: 'inch' })
|
||||
).toMatchTypeOf<Unit>()
|
||||
expectTypeOf(Unit.isValidAlpha('cm')).toMatchTypeOf<boolean>()
|
||||
}
|
||||
|
||||
/**
|
||||
* Example of custom fallback for onUndefinedSymbol & onUndefinedFunction
|
||||
*/
|
||||
@ -2168,6 +2222,9 @@ Factory Test
|
||||
const d = divide(a, b)
|
||||
assert.strictEqual(format(c), '16/21')
|
||||
assert.strictEqual(format(d), '7/9')
|
||||
assert.strictEqual(format(255, { notation: 'bin' }), '0b11111111')
|
||||
assert.strictEqual(format(255, { notation: 'hex' }), '0xff')
|
||||
assert.strictEqual(format(255, { notation: 'oct' }), '0o377')
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -158,8 +158,8 @@ describe('divide', function () {
|
||||
})
|
||||
|
||||
it('should divide one valued unit by a valueless unit and vice-versa', function () {
|
||||
assert.strictEqual(divide(math.unit('4 gal'), math.unit('L')).toString(), '15.141648')
|
||||
assert.strictEqual(divide(math.unit('gal'), math.unit('4 L')).toString(), '0.946353')
|
||||
assert.strictEqual(divide(math.unit('4 gal'), math.unit('L')).toString(), '15.141647136')
|
||||
assert.strictEqual(divide(math.unit('gal'), math.unit('4 L')).toString(), '0.946352946')
|
||||
|
||||
assert.strictEqual(divide(math.unit('inch'), math.unit(math.fraction(1), 'cm')).toFraction(), '127/50')
|
||||
})
|
||||
|
||||
58
types/index.d.ts
vendored
58
types/index.d.ts
vendored
@ -508,6 +508,7 @@ export interface MathJsInstance extends MathJsFactory {
|
||||
RelationalNode: RelationalNodeCtor
|
||||
SymbolNode: SymbolNodeCtor
|
||||
|
||||
Unit: UnitCtor
|
||||
Matrix: MatrixCtor
|
||||
|
||||
/**
|
||||
@ -3989,15 +3990,17 @@ export interface MathJSON {
|
||||
fixPrefix?: boolean
|
||||
}
|
||||
|
||||
export interface BaseUnit {
|
||||
dimensions: number[]
|
||||
key: string
|
||||
}
|
||||
|
||||
export interface UnitComponent {
|
||||
power: number
|
||||
prefix: string
|
||||
unit: {
|
||||
name: string
|
||||
base: {
|
||||
dimensions: number[]
|
||||
key: string
|
||||
}
|
||||
base: BaseUnit
|
||||
prefixes: Record<string, UnitPrefix>
|
||||
value: number
|
||||
offset: number
|
||||
@ -4014,8 +4017,7 @@ export interface UnitPrefix {
|
||||
export interface Unit {
|
||||
valueOf(): string
|
||||
clone(): Unit
|
||||
// eslint-disable-next-line @typescript-eslint/no-explicit-any
|
||||
hasBase(base: any): boolean
|
||||
hasBase(base: BaseUnit | string | undefined): boolean
|
||||
equalBase(unit: Unit): boolean
|
||||
equals(unit: Unit): boolean
|
||||
multiply(unit: Unit): Unit
|
||||
@ -4040,6 +4042,40 @@ export interface Unit {
|
||||
skipAutomaticSimplification: true
|
||||
}
|
||||
|
||||
export type UnitSystemName = 'si' | 'cgs' | 'us' | 'auto'
|
||||
|
||||
export interface UnitStatic {
|
||||
PREFIXES: Record<string, UnitPrefix>
|
||||
BASE_DIMENSIONS: string[]
|
||||
BASE_UNITS: Record<string, BaseUnit>
|
||||
UNIT_SYSTEMS: Record<
|
||||
UnitSystemName,
|
||||
Record<string, { unit: Unit; prefix: UnitPrefix }>
|
||||
>
|
||||
UNITS: Record<string, Unit>
|
||||
parse(str: string): Unit
|
||||
isValuelessUnit(name: string): boolean
|
||||
fromJSON(json: MathJSON): Unit
|
||||
isValidAlpha(c: string): boolean
|
||||
createUnit(
|
||||
obj: Record<string, string | Unit | UnitDefinition>,
|
||||
options?: { override: boolean }
|
||||
): Unit
|
||||
createUnitSingle(
|
||||
name: string,
|
||||
definition: string | Unit | UnitDefinition
|
||||
): Unit
|
||||
getUnitSystem(): UnitSystemName
|
||||
setUnitSystem(name: UnitSystemName): void
|
||||
}
|
||||
|
||||
export interface UnitCtor extends UnitStatic {
|
||||
new (
|
||||
value: number | BigNumber | Fraction | Complex | boolean,
|
||||
name: string
|
||||
): Unit
|
||||
}
|
||||
|
||||
export interface CreateUnitOptions {
|
||||
prefixes?: 'none' | 'short' | 'long' | 'binary_short' | 'binary_long'
|
||||
aliases?: string[]
|
||||
@ -4352,7 +4388,14 @@ export interface FormatOptions {
|
||||
* elsewhere. Lower bound is included, upper bound is excluded. For
|
||||
* example '123.4' and '1.4e7'.
|
||||
*/
|
||||
notation?: 'fixed' | 'exponential' | 'engineering' | 'auto'
|
||||
notation?:
|
||||
| 'fixed'
|
||||
| 'exponential'
|
||||
| 'engineering'
|
||||
| 'auto'
|
||||
| 'hex'
|
||||
| 'bin'
|
||||
| 'oct'
|
||||
|
||||
/**
|
||||
* A number between 0 and 16 to round the digits of the number. In case
|
||||
@ -6846,6 +6889,7 @@ export const {
|
||||
RelationalNode,
|
||||
SymbolNode,
|
||||
Matrix,
|
||||
Unit,
|
||||
|
||||
uninitialized,
|
||||
version,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user