Skip to content

Commit e1f162e

Browse files
committedMar 15, 2019
Add Typescript definitions
1 parent e46f5bb commit e1f162e

File tree

12 files changed

+647
-0
lines changed

12 files changed

+647
-0
lines changed
 
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,125 @@
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+
* Interface defining `isFiniteArray` with methods for testing for primitive and object arrays, respectively.
23+
*/
24+
interface IsFiniteArray {
25+
/**
26+
* Tests if a value is an array-like object of finite numbers.
27+
*
28+
* @param value - value to test
29+
* @returns boolean indicating whether a value is an array-like object of finite numbers
30+
*
31+
* @example
32+
* var bool = isFiniteArray( [ -3.0, new Number(0.0), 2.0 ] );
33+
* // returns true
34+
*
35+
* @example
36+
* var bool = isFiniteArray( [ -3.0, 1.0/0.0 ] );
37+
* // returns false
38+
*/
39+
( value: any ): boolean;
40+
41+
/**
42+
* Tests if a value is an array-like object containing only primitive finite numbers.
43+
*
44+
* @param value - value to test
45+
* @returns boolean indicating whether a value is an array-like object containing only primitive finite numbers
46+
*
47+
* @example
48+
* var bool = isFiniteArray.primitives( [ -1.0, 10.0 ] );
49+
* // returns true
50+
*
51+
* @example
52+
* var bool = isFiniteArray.primitives( [ -1.5, 0.0, 5.0 ] );
53+
* // returns true
54+
*
55+
* @example
56+
* var bool = isFiniteArray.primitives( [ -3.0, new Number(-1.0) ] );
57+
* // returns false
58+
*/
59+
primitives( value: any ): boolean;
60+
61+
/**
62+
* Tests if a value is an array-like object containing only number objects having finite values.
63+
*
64+
* @param value - value to test
65+
* @returns boolean indicating whether a value is an array-like object containing only number objects having finite values
66+
*
67+
* @example
68+
* var bool = isFiniteArray.objects( [ new Number(1.0), new Number(3.0) ] );
69+
* // returns true
70+
*
71+
* @example
72+
* var bool = isFiniteArray.objects( [ -1.0, 0.0, 3.0 ] );
73+
* // returns false
74+
*
75+
* @example
76+
* var bool = isFiniteArray.objects( [ 3.0, new Number(-1.0) ] );
77+
* // returns false
78+
*/
79+
objects( value: any ): boolean;
80+
}
81+
82+
/**
83+
* Tests if a value is an array-like object of finite numbers.
84+
*
85+
* @param value - value to test
86+
* @returns boolean indicating whether a value is an array-like object of finite numbers
87+
*
88+
* @example
89+
* var bool = isFiniteArray( [ -3.0, new Number(0.0), 2.0 ] );
90+
* // returns true
91+
*
92+
* @example
93+
* var bool = isFiniteArray( [ -3.0, 1.0/0.0 ] );
94+
* // returns false
95+
*
96+
* @example
97+
* var bool = isFiniteArray.primitives( [ -1.0, 10.0 ] );
98+
* // returns true
99+
*
100+
* @example
101+
* var bool = isFiniteArray.primitives( [ -1.5, 0.0, 5.0 ] );
102+
* // returns true
103+
*
104+
* @example
105+
* var bool = isFiniteArray.primitives( [ -3.0, new Number(-1.0) ] );
106+
* // returns false
107+
*
108+
* @example
109+
* var bool = isFiniteArray.objects( [ new Number(1.0), new Number(3.0) ] );
110+
* // returns true
111+
*
112+
* @example
113+
* var bool = isFiniteArray.objects( [ -1.0, 0.0, 3.0 ] );
114+
* // returns false
115+
*
116+
* @example
117+
* var bool = isFiniteArray.objects( [ 3.0, new Number(-1.0) ] );
118+
* // returns false
119+
*/
120+
declare var isFiniteArray: IsFiniteArray;
121+
122+
123+
// EXPORTS //
124+
125+
export = isFiniteArray;
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+
import isFiniteArray = require( './index' );
20+
21+
22+
// TESTS //
23+
24+
// The function returns a boolean...
25+
{
26+
isFiniteArray( [ 4 ] ); // $ExpectType boolean
27+
isFiniteArray( [ 2.8, 1 / 0 ] ); // $ExpectType boolean
28+
isFiniteArray( [ '2.8' ] ); // $ExpectType boolean
29+
}
30+
31+
// The compiler throws an error if the function is provided an unsupported number of arguments...
32+
{
33+
isFiniteArray(); // $ExpectError
34+
isFiniteArray( [ -3 ], 123 ); // $ExpectError
35+
}
36+
37+
// Attached to main export is a `primitives` method which returns a boolean...
38+
{
39+
// tslint:disable-next-line:no-construct
40+
isFiniteArray.primitives( [ new Number( 3 ) ] ); // $ExpectType boolean
41+
isFiniteArray.primitives( [ 3 ] ); // $ExpectType boolean
42+
}
43+
44+
// The compiler throws an error if the `primitives` method is provided an unsupported number of arguments...
45+
{
46+
isFiniteArray.primitives(); // $ExpectError
47+
isFiniteArray.primitives( [ 2 ], 123 ); // $ExpectError
48+
}
49+
50+
// Attached to main export is an `objects` method which returns a boolean...
51+
{
52+
// tslint:disable-next-line:no-construct
53+
isFiniteArray.objects( [ new Number( -2 ) ] ); // $ExpectType boolean
54+
isFiniteArray.objects( [ -2 ] ); // $ExpectType boolean
55+
}
56+
57+
// The compiler throws an error if the `objects` method is provided an unsupported number of arguments...
58+
{
59+
isFiniteArray.objects(); // $ExpectError
60+
isFiniteArray.objects( [ 2 ], 123 ); // $ExpectError
61+
}

‎lib/node_modules/@stdlib/assert/is-finite-array/package.json

+1
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": {
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
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+
/**
23+
* Tests if a value is a numeric array.
24+
*
25+
* @param v - value to test
26+
* @returns boolean indicating if a value is a numeric array
27+
*
28+
* @example
29+
* var bool = isNumericArray( new Int8Array( 10 ) );
30+
* // returns true
31+
*
32+
* bool = isNumericArray( [ 1, 2, 3 ] );
33+
* // returns true
34+
*
35+
* bool = isNumericArray( [ '1', '2', '3' ] );
36+
* // returns false
37+
*/
38+
declare function isNumericArray( v: any ): boolean;
39+
40+
41+
// EXPORTS //
42+
43+
export = isNumericArray;
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
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 isNumericArray = require( './index' );
20+
21+
22+
// TESTS //
23+
24+
// The function returns a boolean...
25+
{
26+
isNumericArray( [ 1, 2, 3 ] ); // $ExpectType boolean
27+
isNumericArray( [] ); // $ExpectType boolean
28+
}
29+
30+
// The compiler throws an error if the function is provided an unsupported number of arguments...
31+
{
32+
isNumericArray(); // $ExpectError
33+
isNumericArray( [ 1, 2, 3 ], 123 ); // $ExpectError
34+
}

‎lib/node_modules/@stdlib/assert/is-numeric-array/package.json

+1
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)
Failed to load comments.