diff --git a/src/function/arithmetic/round.js b/src/function/arithmetic/round.js index 49f7c18183..5065dafcc9 100644 --- a/src/function/arithmetic/round.js +++ b/src/function/arithmetic/round.js @@ -136,18 +136,6 @@ export const createRound = /* #__PURE__ */ factory(name, dependencies, ({ typed, 'Array | Matrix, Unit': typed.referToSelf(self => (x, unit) => self(x, 0, unit)), - 'Unit, Array | Matrix, Unit': typed.referToSelf(self => (x, nCollection, unit) => { - // deep map collection, skip zeros since round(0) = 0 - return deepMap(nCollection, (n) => self(x, n, unit), true) - }), - - 'Unit, number | BigNumber, Array | Matrix': typed.referToSelf(self => (x, n, unitCollection) => { - // deep map collection, skip zeros since round(0) = 0 - return deepMap(unitCollection, (unit) => self(x, n, unit), true) - }), - - 'Unit, Array | Matrix': typed.referToSelf(self => (x, unitCollection) => self(x, 0, unitCollection)), - 'Array | Matrix': typed.referToSelf(self => x => { // deep map collection, skip zeros since round(0) = 0 return deepMap(x, self, true) diff --git a/test/unit-tests/function/arithmetic/round.test.js b/test/unit-tests/function/arithmetic/round.test.js index f4520668be..624110cb80 100644 --- a/test/unit-tests/function/arithmetic/round.test.js +++ b/test/unit-tests/function/arithmetic/round.test.js @@ -133,13 +133,6 @@ describe('round', function () { // first argument is a collection assert.deepStrictEqual(round([unit('2 inch'), unit('3 inch')], unit('cm')), [unit('5 cm'), unit('8 cm')]) assert.deepStrictEqual(round(matrix([unit('2 inch'), unit('3 inch')]), unit('cm')), matrix([unit('5 cm'), unit('8 cm')])) - - // decimals is a collection - assert.deepStrictEqual(round(unit('3.12345 cm'), [0, 1, 2], unit('cm')), [unit('3 cm'), unit('3.1 cm'), unit('3.12 cm')]) - - // unit is a collection - assert.deepStrictEqual(round(unit('3.12345 cm'), [unit('cm'), unit('mm')]), [unit('3 cm'), unit('31 mm')]) - assert.deepStrictEqual(round(unit('3.12345 cm'), 1, [unit('cm'), unit('mm')]), [unit('3.1 cm'), unit('31.2 mm')]) }) it('should throw an error if used with a unit without valueless unit', function () { diff --git a/types/index.d.ts b/types/index.d.ts index 7ebc8e0f79..9678b6f6d6 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1104,13 +1104,10 @@ export interface MathJsInstance extends MathJsFactory { n?: number | BigNumber ): NoLiteralType round(x: MathNumericType, n: U): U - round(x: Unit, n: number | BigNumber, unit: Unit): Unit - round(x: Unit, unit: Unit): Unit round(x: U, unit: Unit): U + round(x: Unit, unit: Unit): Unit + round(x: Unit, n: number | BigNumber, unit: Unit): Unit round(x: U, n: number | BigNumber, unit: Unit): U - round(x: Unit, n: U, unit: Unit): U - round(x: Unit, n: number | BigNumber, unit: U): U - round(x: Unit, unit: U): U // End of group of rounding functions @@ -4751,34 +4748,20 @@ export interface MathJsChain { this: MathJsChain, n: U ): MathJsChain - round( - this: MathJsChain, - n: number | BigNumber, - unit: Unit - ): MathJsChain round(this: MathJsChain, unit: Unit): MathJsChain round( this: MathJsChain, unit: Unit ): MathJsChain - round( - this: MathJsChain, - n: number | BigNumber, - unit: Unit - ): MathJsChain - round( + round( this: MathJsChain, - n: U, + n: number | BigNumber, unit: Unit - ): MathJsChain + ): MathJsChain round( - this: MathJsChain, + this: MathJsChain, n: number | BigNumber, - unit: U - ): MathJsChain - round( - this: MathJsChain, - unit: U + unit: Unit ): MathJsChain // End of rounding group