Skip to content

Commit ac93021

Browse files
committed
docs: update examples and rearrange tests
1 parent e459df4 commit ac93021

File tree

2 files changed

+18
-18
lines changed

2 files changed

+18
-18
lines changed

lib/node_modules/@stdlib/math/base/tools/evalpoly/docs/types/index.d.ts

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ import { Collection } from '@stdlib/types/array';
2828
* @param x - value at which to evaluate a polynomial
2929
* @returns evaluated polynomial
3030
*/
31-
type EvaluationFunction = ( x: number ) => number;
31+
type PolynomialFunction = ( x: number ) => number;
3232

3333
/**
3434
* Interface for evaluating polynomials.
@@ -49,7 +49,7 @@ interface EvalPoly {
4949
* @returns evaluated polynomial
5050
*
5151
* @example
52-
* var v = evalpoly( [3.0,2.0,1.0], 10.0 ); // 3*10^0 + 2*10^1 + 1*10^2
52+
* var v = evalpoly( [ 3.0, 2.0, 1.0 ], 10.0 ); // 3*10^0 + 2*10^1 + 1*10^2
5353
* // returns 123.0
5454
*/
5555
( c: Collection<number>, x: number ): number;
@@ -68,15 +68,15 @@ interface EvalPoly {
6868
* @returns function for evaluating a polynomial
6969
*
7070
* @example
71-
* var polyval = evalpoly.factory( [3.0,2.0,1.0] );
71+
* var polyval = evalpoly.factory( [ 3.0, 2.0, 1.0 ] );
7272
*
7373
* var v = polyval( 10.0 ); // => 3*10^0 + 2*10^1 + 1*10^2
7474
* // returns 123.0
7575
*
7676
* v = polyval( 5.0 ); // => 3*5^0 + 2*5^1 + 1*5^2
7777
* // returns 38.0
7878
*/
79-
factory( c: Collection<number> ): EvaluationFunction;
79+
factory( c: Collection<number> ): PolynomialFunction;
8080
}
8181

8282
/**
@@ -94,11 +94,11 @@ interface EvalPoly {
9494
* @returns evaluated polynomial
9595
*
9696
* @example
97-
* var v = evalpoly( [3.0,2.0,1.0], 10.0 ); // 3*10^0 + 2*10^1 + 1*10^2
97+
* var v = evalpoly( [ 3.0, 2.0, 1.0 ], 10.0 ); // 3*10^0 + 2*10^1 + 1*10^2
9898
* // returns 123.0
9999
*
100100
* @example
101-
* var polyval = evalpoly.factory( [3.0,2.0,1.0] );
101+
* var polyval = evalpoly.factory( [ 3.0, 2.0, 1.0 ] );
102102
*
103103
* var v = polyval( 10.0 ); // => 3*10^0 + 2*10^1 + 1*10^2
104104
* // returns 123.0

lib/node_modules/@stdlib/math/base/tools/evalpoly/docs/types/test.ts

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,17 @@ import evalpoly = require( './index' );
5757
// Attached to main export is a `factory` method which returns a function...
5858
{
5959
const c = [ 3.0, 2.0, 1.0 ];
60-
evalpoly.factory( c ); // $ExpectType EvaluationFunction
60+
evalpoly.factory( c ); // $ExpectType PolynomialFunction
61+
}
62+
63+
// The compiler throws an error if the `factory` method is provided a first argument which is not an array of numbers...
64+
{
65+
evalpoly.factory( true ); // $ExpectError
66+
evalpoly.factory( false ); // $ExpectError
67+
evalpoly.factory( 'abc' ); // $ExpectError
68+
evalpoly.factory( 123 ); // $ExpectError
69+
evalpoly.factory( {} ); // $ExpectError
70+
evalpoly.factory( ( x: number ): number => x ); // $ExpectError
6171
}
6272

6373
// The compiler throws an error if the `factory` method is provided an unsupported number of arguments...
@@ -74,7 +84,7 @@ import evalpoly = require( './index' );
7484
polyval( 1.0 ); // $ExpectType number
7585
}
7686

77-
// The `factory` method returns a function which does not compile if provided a first argument which is not a number...
87+
// The compiler throws an error if the function returned by the `factory` method is provided a first argument which is not a number...
7888
{
7989
const c = [ 3.0, 2.0, 1.0 ];
8090
const polyval = evalpoly.factory( c );
@@ -85,13 +95,3 @@ import evalpoly = require( './index' );
8595
polyval( {} ); // $ExpectError
8696
polyval( ( x: number ): number => x ); // $ExpectError
8797
}
88-
89-
// The compiler throws an error if the `factory` method is provided a first argument which is not an array of numbers...
90-
{
91-
evalpoly.factory( true ); // $ExpectError
92-
evalpoly.factory( false ); // $ExpectError
93-
evalpoly.factory( 'abc' ); // $ExpectError
94-
evalpoly.factory( 123 ); // $ExpectError
95-
evalpoly.factory( {} ); // $ExpectError
96-
evalpoly.factory( ( x: number ): number => x ); // $ExpectError
97-
}

0 commit comments

Comments
 (0)