fix types of filter function arguments

This commit is contained in:
Jongsu Liam Kim 2019-01-14 13:56:21 +09:00
parent 3a69de74e2
commit 02ca5e8e4e
2 changed files with 8 additions and 2 deletions

View File

@ -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;
/**

View File

@ -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"]
}
}
/*