From 4d91f100956bde0e8fb500c54add0d389fc0b2a0 Mon Sep 17 00:00:00 2001 From: Jos de Jong Date: Wed, 4 Sep 2024 11:06:21 +0200 Subject: [PATCH] fix: #3259 function `symbolicEqual` missing in the TypeScript definitions --- HISTORY.md | 1 + test/typescript-tests/testTypes.ts | 16 ++++++++++++++++ types/index.d.ts | 18 ++++++++++++++++++ 3 files changed, 35 insertions(+) diff --git a/HISTORY.md b/HISTORY.md index cada00e60a..8e4083b28a 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -4,6 +4,7 @@ - Fix: improve the type definitions of `ConstantNode` to support all data types (#3257). Thanks @smith120bh. +- Fix: #3259 function `symbolicEqual` missing in the TypeScript definitions. - Docs: fix broken links on the Configuration page. Thanks @vassudanagunta. # 2024-08-27, 13.1.1 diff --git a/test/typescript-tests/testTypes.ts b/test/typescript-tests/testTypes.ts index 7538cad14c..c58e59ffb0 100644 --- a/test/typescript-tests/testTypes.ts +++ b/test/typescript-tests/testTypes.ts @@ -523,6 +523,22 @@ Chaining examples MathJsChain >() + // symbolicEqual + assert.strictEqual( + math.symbolicEqual(math.parse('x*y'), math.parse('y*x')), + true + ) + assert.strictEqual( + math.symbolicEqual(math.parse('x*y'), math.parse('y*x'), { + exactFractions: true + }), + true + ) + assert.strictEqual( + math.chain(math.parse('x*y')).symbolicEqual(math.parse('y*x')).done(), + true + ) + // slu expectTypeOf( math diff --git a/types/index.d.ts b/types/index.d.ts index 044611ec7d..fa7e4c9bad 100644 --- a/types/index.d.ts +++ b/types/index.d.ts @@ -1041,6 +1041,15 @@ export interface MathJsInstance extends MathJsFactory { simplifyConstant(expr: MathNode | string, options?: SimplifyOptions): MathNode simplifyCore(expr: MathNode | string, options?: SimplifyOptions): MathNode + /** + * Attempts to determine if two expressions are symbolically equal. + */ + symbolicEqual( + expr1: MathNode, + expr2: MathNode, + options?: SimplifyOptions + ): boolean + /** * Replaces variable nodes with their scoped values * @param node Tree to replace variable nodes in @@ -4888,6 +4897,15 @@ export interface MathJsChain { options?: SimplifyOptions ): MathJsChain + /** + * Attempts to determine if two expressions are symbolically equal. + */ + symbolicEqual( + this: MathJsChain, + expr2: MathNode, + options?: SimplifyOptions + ): MathJsChain + /** * Calculate the Sparse Matrix LU decomposition with full pivoting. * Sparse Matrix A is decomposed in two matrices (L, U) and two