Skip to content

Commit ec00271

Browse files
committed
Add Typescript definition files
1 parent 9beb9c1 commit ec00271

File tree

9 files changed

+287
-0
lines changed

9 files changed

+287
-0
lines changed
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
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+
/**
22+
* Rounds a numeric value toward zero.
23+
*
24+
* @param x - input value
25+
* @returns rounded value
26+
*
27+
* @example
28+
* var v = trunc( -4.2 );
29+
* // returns -4.0
30+
*
31+
* @example
32+
* var v = trunc( 9.99999 );
33+
* // returns 9.0
34+
*
35+
* @example
36+
* var v = trunc( 0.0 );
37+
* // returns 0.0
38+
*
39+
* @example
40+
* var v = trunc( -0.0 );
41+
* // returns -0.0
42+
*
43+
* @example
44+
* var v = trunc( NaN );
45+
* // returns NaN
46+
*
47+
* @example
48+
* var v = trunc( Infinity );
49+
* // returns Infinity
50+
*
51+
* @example
52+
* var v = trunc( -Infinity );
53+
* // returns -Infinity
54+
*/
55+
declare function trunc( x: number ): number;
56+
57+
58+
// EXPORTS //
59+
60+
export = trunc;
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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 trunc = require( './index' );
20+
21+
22+
// TESTS //
23+
24+
// The function returns a number...
25+
{
26+
trunc( 8.5 ); // $ExpectType number
27+
}
28+
29+
// The function does not compile if provided a value other than a number...
30+
{
31+
trunc( true ); // $ExpectError
32+
trunc( false ); // $ExpectError
33+
trunc( null ); // $ExpectError
34+
trunc( undefined ); // $ExpectError
35+
trunc( '5' ); // $ExpectError
36+
trunc( [] ); // $ExpectError
37+
trunc( {} ); // $ExpectError
38+
trunc( ( x: number ): number => x ); // $ExpectError
39+
}
40+
41+
// The function does not compile if provided insufficient arguments...
42+
{
43+
trunc(); // $ExpectError
44+
}

lib/node_modules/@stdlib/math/base/special/trunc/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"lib": "./lib",
2222
"test": "./test"
2323
},
24+
"types": "./docs/types",
2425
"scripts": {},
2526
"homepage": "https://github.com/stdlib-js/stdlib",
2627
"repository": {
Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
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+
/**
22+
* Rounds a numeric value to the nearest power of `10` toward zero.
23+
*
24+
* ## Notes
25+
*
26+
* - The function may not return accurate results for subnormals due to a general loss in precision.
27+
*
28+
* @param x - input value
29+
* @returns rounded value
30+
*
31+
* @example
32+
* var v = trunc10( 3.141592653589793 );
33+
* // returns 1.0
34+
*
35+
* @example
36+
* var v = trunc10( 13.0 );
37+
* // returns 10.0
38+
*
39+
* @example
40+
* var v = trunc10( -0.314 );
41+
* // returns -0.1
42+
*/
43+
declare function trunc10( x: number ): number;
44+
45+
46+
// EXPORTS //
47+
48+
export = trunc10;
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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 trunc10 = require( './index' );
20+
21+
22+
// TESTS //
23+
24+
// The function returns a number...
25+
{
26+
trunc10( 13 ); // $ExpectType number
27+
}
28+
29+
// The function does not compile if provided a value other than a number...
30+
{
31+
trunc10( true ); // $ExpectError
32+
trunc10( false ); // $ExpectError
33+
trunc10( null ); // $ExpectError
34+
trunc10( undefined ); // $ExpectError
35+
trunc10( '5' ); // $ExpectError
36+
trunc10( [] ); // $ExpectError
37+
trunc10( {} ); // $ExpectError
38+
trunc10( ( x: number ): number => x ); // $ExpectError
39+
}
40+
41+
// The function does not compile if provided insufficient arguments...
42+
{
43+
trunc10(); // $ExpectError
44+
}

lib/node_modules/@stdlib/math/base/special/trunc10/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"lib": "./lib",
2222
"test": "./test"
2323
},
24+
"types": "./docs/types",
2425
"scripts": {},
2526
"homepage": "https://github.com/stdlib-js/stdlib",
2627
"repository": {
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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+
/**
22+
* Rounds a numeric value to the nearest power of two toward zero.
23+
*
24+
* @param x - input value
25+
* @returns rounded value
26+
*
27+
* @example
28+
* var v = trunc2( 3.141592653589793 );
29+
* // returns 2.0
30+
*
31+
* @example
32+
* var v = trunc2( 13.0 );
33+
* // returns 8.0
34+
*
35+
* @example
36+
* var v = trunc2( -0.314 );
37+
* // returns -0.25
38+
*/
39+
declare function trunc2( x: number ): number;
40+
41+
42+
// EXPORTS //
43+
44+
export = trunc2;
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
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 trunc2 = require( './index' );
20+
21+
22+
// TESTS //
23+
24+
// The function returns a number...
25+
{
26+
trunc2( 13 ); // $ExpectType number
27+
}
28+
29+
// The function does not compile if provided a value other than a number...
30+
{
31+
trunc2( true ); // $ExpectError
32+
trunc2( false ); // $ExpectError
33+
trunc2( null ); // $ExpectError
34+
trunc2( undefined ); // $ExpectError
35+
trunc2( '5' ); // $ExpectError
36+
trunc2( [] ); // $ExpectError
37+
trunc2( {} ); // $ExpectError
38+
trunc2( ( x: number ): number => x ); // $ExpectError
39+
}
40+
41+
// The function does not compile if provided insufficient arguments...
42+
{
43+
trunc2(); // $ExpectError
44+
}

lib/node_modules/@stdlib/math/base/special/trunc2/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
"lib": "./lib",
2222
"test": "./test"
2323
},
24+
"types": "./docs/types",
2425
"scripts": {},
2526
"homepage": "https://github.com/stdlib-js/stdlib",
2627
"repository": {

0 commit comments

Comments
 (0)