Skip to content

Commit 011f73f

Browse files
committed
Add Typescript definitions
1 parent ae0da11 commit 011f73f

File tree

12 files changed

+526
-0
lines changed

12 files changed

+526
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2019 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
// TypeScript Version: 2.0
20+
21+
/// <reference types="@stdlib/types"/>
22+
23+
/**
24+
* If provided input values, the accumulator function returns an updated mean arctangent absolute percentage error. If not provided input values, the accumulator function returns the current mean arctangent absolute percentage error.
25+
*
26+
* ## Notes
27+
*
28+
* - Note that, unlike the mean absolute percentage error (MAPE), the mean arctangent absolute percentage error is expressed in radians on the interval [0,π/2].
29+
* - If provided `NaN` or a value which, when used in computations, results in `NaN`, the accumulated value is `NaN` for all future invocations.
30+
*
31+
* @param f - input value
32+
* @param a - input value
33+
* @returns mean arctangent absolute percentage error or null
34+
*/
35+
type accumulator = ( f?: number, a?: number ) => number | null;
36+
37+
/**
38+
* Returns an accumulator function which incrementally computes the mean arctangent absolute percentage error.
39+
*
40+
* @returns accumulator function
41+
*
42+
* @example
43+
* var accumulator = incrmaape();
44+
*
45+
* var m = accumulator();
46+
* // returns null
47+
*
48+
* m = accumulator( 2.0, 3.0 );
49+
* // returns ~0.3218
50+
*
51+
* m = accumulator( 5.0, 2.0 );
52+
* // returns ~0.6523
53+
*
54+
* m = accumulator();
55+
* // returns ~0.6523
56+
*/
57+
declare function incrmaape(): accumulator;
58+
59+
60+
// EXPORTS //
61+
62+
export = incrmaape;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2019 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
import incrmaape = require( './index' );
20+
21+
22+
// TESTS //
23+
24+
// The function returns an accumulator function...
25+
{
26+
incrmaape(); // $ExpectType accumulator
27+
}
28+
29+
// The compiler throws an error if the function is provided arguments...
30+
{
31+
incrmaape( '5' ); // $ExpectError
32+
incrmaape( 5 ); // $ExpectError
33+
incrmaape( true ); // $ExpectError
34+
incrmaape( false ); // $ExpectError
35+
incrmaape( null ); // $ExpectError
36+
incrmaape( undefined ); // $ExpectError
37+
incrmaape( [] ); // $ExpectError
38+
incrmaape( {} ); // $ExpectError
39+
incrmaape( ( x: number ): number => x ); // $ExpectError
40+
}
41+
42+
// The functions returns an accumulator function which returns an accumulated result...
43+
{
44+
const acc = incrmaape();
45+
46+
acc(); // $ExpectType number | null
47+
acc( 3.14, 2.0 ); // $ExpectType number | null
48+
}
49+
50+
// The compiler throws an error if the returned accumulator function is provided invalid arguments...
51+
{
52+
const acc = incrmaape();
53+
54+
acc( '5', 2.0 ); // $ExpectError
55+
acc( true, 2.0 ); // $ExpectError
56+
acc( false, 2.0 ); // $ExpectError
57+
acc( null, 2.0 ); // $ExpectError
58+
acc( [], 2.0 ); // $ExpectError
59+
acc( {}, 2.0 ); // $ExpectError
60+
acc( ( x: number ): number => x, 2.0 ); // $ExpectError
61+
62+
acc( 3.14, '5' ); // $ExpectError
63+
acc( 3.14, true ); // $ExpectError
64+
acc( 3.14, false ); // $ExpectError
65+
acc( 3.14, null ); // $ExpectError
66+
acc( 3.14, [] ); // $ExpectError
67+
acc( 3.14, {} ); // $ExpectError
68+
acc( 3.14, ( x: number ): number => x ); // $ExpectError
69+
}

lib/node_modules/@stdlib/stats/incr/maape/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"lib": "./lib",
2121
"test": "./test"
2222
},
23+
"types": "./docs/types",
2324
"scripts": {},
2425
"homepage": "https://github.com/stdlib-js/stdlib",
2526
"repository": {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2019 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
// TypeScript Version: 2.0
20+
21+
/// <reference types="@stdlib/types"/>
22+
23+
/**
24+
* If provided input values, the accumulator function returns an updated mean absolute error. If not provided input values, the accumulator function returns the current mean absolute error.
25+
*
26+
* ## Notes
27+
*
28+
* - If provided `NaN` or a value which, when used in computations, results in `NaN`, the accumulated value is `NaN` for all future invocations.
29+
*
30+
* @param x - input value
31+
* @param y - input value
32+
* @returns mean absolute error or null
33+
*/
34+
type accumulator = ( x?: number, y?: number ) => number | null;
35+
36+
/**
37+
* Returns an accumulator function which incrementally computes the mean absolute error.
38+
*
39+
* @returns accumulator function
40+
*
41+
* @example
42+
* var accumulator = incrmae();
43+
*
44+
* var m = accumulator();
45+
* // returns null
46+
*
47+
* m = accumulator( 2.0, 3.0 );
48+
* // returns 1.0
49+
*
50+
* m = accumulator( -5.0, 2.0 );
51+
* // returns 4.0
52+
*
53+
* m = accumulator();
54+
* // returns 4.0
55+
*/
56+
declare function incrmae(): accumulator;
57+
58+
59+
// EXPORTS //
60+
61+
export = incrmae;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,69 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2019 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
import incrmae = require( './index' );
20+
21+
22+
// TESTS //
23+
24+
// The function returns an accumulator function...
25+
{
26+
incrmae(); // $ExpectType accumulator
27+
}
28+
29+
// The compiler throws an error if the function is provided arguments...
30+
{
31+
incrmae( '5' ); // $ExpectError
32+
incrmae( 5 ); // $ExpectError
33+
incrmae( true ); // $ExpectError
34+
incrmae( false ); // $ExpectError
35+
incrmae( null ); // $ExpectError
36+
incrmae( undefined ); // $ExpectError
37+
incrmae( [] ); // $ExpectError
38+
incrmae( {} ); // $ExpectError
39+
incrmae( ( x: number ): number => x ); // $ExpectError
40+
}
41+
42+
// The functions returns an accumulator function which returns an accumulated result...
43+
{
44+
const acc = incrmae();
45+
46+
acc(); // $ExpectType number | null
47+
acc( 3.14, 2.0 ); // $ExpectType number | null
48+
}
49+
50+
// The compiler throws an error if the returned accumulator function is provided invalid arguments...
51+
{
52+
const acc = incrmae();
53+
54+
acc( '5', 2.0 ); // $ExpectError
55+
acc( true, 2.0 ); // $ExpectError
56+
acc( false, 2.0 ); // $ExpectError
57+
acc( null, 2.0 ); // $ExpectError
58+
acc( [], 2.0 ); // $ExpectError
59+
acc( {}, 2.0 ); // $ExpectError
60+
acc( ( x: number ): number => x, 2.0 ); // $ExpectError
61+
62+
acc( 3.14, '5' ); // $ExpectError
63+
acc( 3.14, true ); // $ExpectError
64+
acc( 3.14, false ); // $ExpectError
65+
acc( 3.14, null ); // $ExpectError
66+
acc( 3.14, [] ); // $ExpectError
67+
acc( 3.14, {} ); // $ExpectError
68+
acc( 3.14, ( x: number ): number => x ); // $ExpectError
69+
}

lib/node_modules/@stdlib/stats/incr/mae/package.json

+1
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,7 @@
2020
"lib": "./lib",
2121
"test": "./test"
2222
},
23+
"types": "./docs/types",
2324
"scripts": {},
2425
"homepage": "https://github.com/stdlib-js/stdlib",
2526
"repository": {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,62 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2019 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
// TypeScript Version: 2.0
20+
21+
/// <reference types="@stdlib/types"/>
22+
23+
24+
/**
25+
* If provided input values, the accumulator function returns an updated mean absolute percentage error. If not provided input values, the accumulator function returns the current mean absolute percentage error.
26+
*
27+
* ## Notes
28+
*
29+
* - If provided `NaN` or a value which, when used in computations, results in `NaN`, the accumulated value is `NaN` for all future invocations.
30+
*
31+
* @param f - input value
32+
* @param a - input value
33+
* @returns mean absolute percentage error or null
34+
*/
35+
type accumulator = ( f?: number, a?: number ) => number | null;
36+
37+
/**
38+
* Returns an accumulator function which incrementally computes the mean absolute percentage error.
39+
*
40+
* @returns accumulator function
41+
*
42+
* @example
43+
* var accumulator = incrmape();
44+
*
45+
* var m = accumulator();
46+
* // returns null
47+
*
48+
* m = accumulator( 2.0, 3.0 );
49+
* // returns ~33.33
50+
*
51+
* m = accumulator( 5.0, 2.0 );
52+
* // returns ~91.67
53+
*
54+
* m = accumulator();
55+
* // returns ~91.67
56+
*/
57+
declare function incrmape(): accumulator;
58+
59+
60+
// EXPORTS //
61+
62+
export = incrmape;

0 commit comments

Comments
 (0)