diff --git a/packages/core/evaluators/src/utils/__tests__/mathjs.test.ts b/packages/core/evaluators/src/utils/__tests__/mathjs.test.ts new file mode 100644 index 0000000000..9acab4caec --- /dev/null +++ b/packages/core/evaluators/src/utils/__tests__/mathjs.test.ts @@ -0,0 +1,16 @@ +/** + * This file is part of the NocoBase (R) project. + * Copyright (c) 2020-2024 NocoBase Co., Ltd. + * Authors: NocoBase Team. + * + * This project is dual-licensed under AGPL-3.0 and NocoBase Commercial License. + * For more information, please refer to: https://www.nocobase.com/agreement. + */ + +import mathjs from '../mathjs'; + +describe('evaluators > mathjs', () => { + it('matrix type should be to array', () => { + expect(mathjs('range(1, 3, 1)')).toEqual([1, 2, 3]); + }); +}); diff --git a/packages/core/evaluators/src/utils/mathjs.ts b/packages/core/evaluators/src/utils/mathjs.ts index 7b06c086a4..0a1c66ae5a 100644 --- a/packages/core/evaluators/src/utils/mathjs.ts +++ b/packages/core/evaluators/src/utils/mathjs.ts @@ -20,6 +20,9 @@ export default evaluate.bind( } return math.round(result, 9); } + if (result instanceof math.Matrix) { + return result.toArray(); + } return result; }, { replaceKey: true },