From e8b1e0d29377e3c6c0cc1c1ed184f6d3e2fe00b2 Mon Sep 17 00:00:00 2001 From: Lucas Eng Date: Thu, 30 May 2024 11:04:49 -0400 Subject: [PATCH 1/2] chore: added test cases to deepForEach (#3211) --- .../type/matrix/utils/deepForEach.test.js | 64 ++++++++++++++++++- 1 file changed, 63 insertions(+), 1 deletion(-) diff --git a/test/unit-tests/type/matrix/utils/deepForEach.test.js b/test/unit-tests/type/matrix/utils/deepForEach.test.js index 36d0e030c..6245eb380 100644 --- a/test/unit-tests/type/matrix/utils/deepForEach.test.js +++ b/test/unit-tests/type/matrix/utils/deepForEach.test.js @@ -1 +1,63 @@ -// TODO: test deepForEach +import assert from 'assert' +import math from '../../../../../src/defaultInstance.js' +import { deepForEach } from '../../../../../src/utils/collection.js' + +const DenseMatrix = math.DenseMatrix + +describe('deepForEach', function () { + it('should iterate over all elements in a simple array', function () { + const array = [1, 2, 3] + const result = [] + deepForEach(array, value => result.push(value)) + assert.deepStrictEqual(result, [1, 2, 3]) + }) + + it('should iterate over all elements in a nested array', function () { + const array = [[1, 2], [3, [4, 5]]] + const result = [] + deepForEach(array, value => result.push(value)) + assert.deepStrictEqual(result, [1, 2, 3, 4, 5]) + }) + + it('should iterate over all elements in a mixed type array', function () { + const array = [1, 'two', [3, null, undefined, true]] + const result = [] + deepForEach(array, value => result.push(value)) + assert.deepStrictEqual(result, [1, 'two', 3, null, undefined, true]) + }) + + it('should handle an empty array', function () { + const array = [] + const result = [] + deepForEach(array, value => result.push(value)) + assert.deepStrictEqual(result, []) + }) + + it('should handle an array with empty nested arrays', function () { + const array = [[], [1, []], [2, [3, []]]] + const result = [] + deepForEach(array, value => result.push(value)) + assert.deepStrictEqual(result, [1, 2, 3]) + }) + + it('should iterate over all elements in a DenseMatrix', function () { + const matrix = new DenseMatrix([[1, 2], [3, 4]]) + const result = [] + deepForEach(matrix, value => result.push(value)) + assert.deepStrictEqual(result, [1, 2, 3, 4]) + }) + + it('should call the callback with each element of a matrix after converting to array', function () { + const matrix = math.matrix([[1, 2], [3, 4]]) + const result = [] + deepForEach(matrix, value => result.push(value)) + assert.deepStrictEqual(result, [1, 2, 3, 4]) + }) + + it('should work with arrays containing complex numbers', function () { + const array = [math.complex(2, 3), [math.complex(4, 5)]] + const result = [] + deepForEach(array, value => result.push(value)) + assert.deepStrictEqual(result, [math.complex(2, 3), math.complex(4, 5)]) + }) +}) From 0f65a4486a752a64fb0cc26a41fb6d5dff7e33bc Mon Sep 17 00:00:00 2001 From: Jos de Jong Date: Fri, 31 May 2024 14:01:18 +0200 Subject: [PATCH 2/2] chore: publish v12.4.3 --- AUTHORS | 2 ++ HISTORY.md | 2 +- package-lock.json | 32 ++++++++++++++++---------------- package.json | 2 +- src/version.js | 2 +- 5 files changed, 21 insertions(+), 19 deletions(-) diff --git a/AUTHORS b/AUTHORS index c9587cdaf..0e4b9b73f 100644 --- a/AUTHORS +++ b/AUTHORS @@ -246,5 +246,7 @@ Brian Fugate Sukka Rohil Shah Laurent Gérin <41303636+lgerin@users.noreply.github.com> +Adam Jones +Lucas Eng # Generated by tools/update-authors.js diff --git a/HISTORY.md b/HISTORY.md index 6292ff2ce..a5abab9c0 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -1,6 +1,6 @@ # History -# unpublished changes since 12.4.2 +# 2024-05-31, 12.4.3 - Fix: serialization of Units without a value, see #1240. - Fix: outdated, incorrect documentation about the order of precedence for diff --git a/package-lock.json b/package-lock.json index ee86c900a..6d74b1203 100644 --- a/package-lock.json +++ b/package-lock.json @@ -1,12 +1,12 @@ { "name": "mathjs", - "version": "12.4.2", + "version": "12.4.3", "lockfileVersion": 2, "requires": true, "packages": { "": { "name": "mathjs", - "version": "12.4.2", + "version": "12.4.3", "license": "Apache-2.0", "dependencies": { "@babel/runtime": "^7.24.4", @@ -1976,9 +1976,9 @@ "dev": true }, "node_modules/@definitelytyped/utils": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/@definitelytyped/utils/-/utils-0.1.5.tgz", - "integrity": "sha512-DwWL7/wwmK9Oe0zPYTYX3KBv6m92+tCxX8cD/K/wyEv4kfZerW21xNFzOFiwrpmtg6ghCMmvoeklvJ120B5v5A==", + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/@definitelytyped/utils/-/utils-0.1.6.tgz", + "integrity": "sha512-QRA3Gr2jfQcPoN35yLexdW/JCoYNNLSLX0xKMa+y28nZXyv+9RVr+UruoYiyxtwcf+W3b49X2I8fGYIlzoGw6w==", "dev": true, "dependencies": { "@qiwi/npm-registry-client": "^8.9.1", @@ -1986,7 +1986,7 @@ "cachedir": "^2.0.0", "charm": "^1.0.2", "minimatch": "^9.0.3", - "tar": "^6.2.0", + "tar": "^6.2.1", "tar-stream": "^3.1.6", "which": "^4.0.0" }, @@ -11491,9 +11491,9 @@ } }, "node_modules/tar": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.0.tgz", - "integrity": "sha512-/Wo7DcT0u5HUV486xg675HtjNd3BXZ6xDbzsCUZPt5iw8bTQ63bP0Raut3mvro9u+CUyq7YQd8Cx55fsZXxqLQ==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz", + "integrity": "sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==", "dev": true, "dependencies": { "chownr": "^2.0.0", @@ -14402,9 +14402,9 @@ "dev": true }, "@definitelytyped/utils": { - "version": "0.1.5", - "resolved": "https://registry.npmjs.org/@definitelytyped/utils/-/utils-0.1.5.tgz", - "integrity": "sha512-DwWL7/wwmK9Oe0zPYTYX3KBv6m92+tCxX8cD/K/wyEv4kfZerW21xNFzOFiwrpmtg6ghCMmvoeklvJ120B5v5A==", + "version": "0.1.6", + "resolved": "https://registry.npmjs.org/@definitelytyped/utils/-/utils-0.1.6.tgz", + "integrity": "sha512-QRA3Gr2jfQcPoN35yLexdW/JCoYNNLSLX0xKMa+y28nZXyv+9RVr+UruoYiyxtwcf+W3b49X2I8fGYIlzoGw6w==", "dev": true, "requires": { "@qiwi/npm-registry-client": "^8.9.1", @@ -14412,7 +14412,7 @@ "cachedir": "^2.0.0", "charm": "^1.0.2", "minimatch": "^9.0.3", - "tar": "^6.2.0", + "tar": "^6.2.1", "tar-stream": "^3.1.6", "which": "^4.0.0" }, @@ -21590,9 +21590,9 @@ "dev": true }, "tar": { - "version": "6.2.0", - "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.0.tgz", - "integrity": "sha512-/Wo7DcT0u5HUV486xg675HtjNd3BXZ6xDbzsCUZPt5iw8bTQ63bP0Raut3mvro9u+CUyq7YQd8Cx55fsZXxqLQ==", + "version": "6.2.1", + "resolved": "https://registry.npmjs.org/tar/-/tar-6.2.1.tgz", + "integrity": "sha512-DZ4yORTwrbTj/7MZYq2w+/ZFdI6OZ/f9SFHR+71gIVUZhOQPHzVCLpvRnPgyaMpfWxxk/4ONva3GQSyNIKRv6A==", "dev": true, "requires": { "chownr": "^2.0.0", diff --git a/package.json b/package.json index b56669ae6..51cfd8719 100644 --- a/package.json +++ b/package.json @@ -1,6 +1,6 @@ { "name": "mathjs", - "version": "12.4.2", + "version": "12.4.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 (https://github.com/josdejong)", "homepage": "https://mathjs.org", diff --git a/src/version.js b/src/version.js index 48f9706d1..6cf204477 100644 --- a/src/version.js +++ b/src/version.js @@ -1,3 +1,3 @@ -export const version = '12.4.2' +export const version = '12.4.3' // Note: This file is automatically generated when building math.js. // Changes made in this file will be overwritten.