diff --git a/types/mathjs/index.d.ts b/types/mathjs/index.d.ts index a8ec6114eb..c72ca68941 100644 --- a/types/mathjs/index.d.ts +++ b/types/mathjs/index.d.ts @@ -1299,8 +1299,8 @@ declare namespace math { * traversed. The function must return a boolean. */ filter( - x: Matrix | MathArray, - test: ((value: any, index: any, matrix: Matrix | MathArray) => Matrix | MathArray) | RegExp + x: Matrix | MathArray | string[], + test: ((value: any, index: any, matrix: Matrix | MathArray | string[]) => boolean) | RegExp ): Matrix | MathArray; /** diff --git a/types/mathjs/mathjs-tests.ts b/types/mathjs/mathjs-tests.ts index 0d21be817e..15d455e427 100644 --- a/types/mathjs/mathjs-tests.ts +++ b/types/mathjs/mathjs-tests.ts @@ -281,6 +281,12 @@ Matrices examples return value * value; }); // returns [1, 4, 9] } + + // filter matrix + { + math.filter([6, -2, -1, 4, 3], function(x) { return x > 0; }); // returns [6, 4, 3] + math.filter(["23", "foo", "100", "55", "bar"], /[0-9]+/); // returns ["23", "100", "55"] + } } /*