Skip to content

Commit 4848bda

Browse files
committed
Add Typescript definitions
1 parent 72eb7dd commit 4848bda

7 files changed

Lines changed: 352 additions & 3 deletions

File tree

lib/node_modules/@stdlib/assert/is-boolean/docs/types/index.d.ts

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,11 @@ interface IsBoolean {
9898
* // returns true
9999
*
100100
* @example
101-
* var bool = isBoolean( new Boolean( false ) );
102-
* // returns true
101+
* var bool = isBoolean.isPrimitive( new Boolean( true ) );
102+
* // returns false
103103
*
104104
* @example
105-
* var bool = isBoolean( new Boolean( true ) );
105+
* var bool = isBoolean.isObject( new Boolean( false ) );
106106
* // returns true
107107
*/
108108
declare var isBoolean: IsBoolean;
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
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 `isFinite` with methods for testing for primitives and objects, respectively.
23+
*/
24+
interface IsFinite {
25+
/**
26+
* Tests if a value is a finite number.
27+
*
28+
* @param value - value to test
29+
* @returns boolean indicating whether a value is a finite number
30+
*
31+
* @example
32+
* var bool = isFinite( 5.0 );
33+
* // returns true
34+
*
35+
* @example
36+
* var bool = isFinite( new Number( 5.0 ) );
37+
* // returns true
38+
*
39+
* @example
40+
* var bool = isFinite( 1.0/0.0 );
41+
* // returns false
42+
*
43+
* @example
44+
* var bool = isFinite( null );
45+
* // returns false
46+
*/
47+
( value: any ): boolean;
48+
49+
/**
50+
* Tests if a value is a number primitive having a finite value.
51+
*
52+
* @param value - value to test
53+
* @returns boolean indicating if a value is a number primitive having a finite value
54+
*
55+
* @example
56+
* var bool = isFinite.isPrimitive( -3.0 );
57+
* // returns true
58+
*
59+
* @example
60+
* var bool = isFinite.isPrimitive( new Number( -3.0 ) );
61+
* // returns false
62+
*/
63+
isPrimitive( value: any ): boolean;
64+
65+
/**
66+
* Tests if a value is a number object having a finite value.
67+
*
68+
* @param value - value to test
69+
* @returns boolean indicating if a value is a number object having a finite value
70+
*
71+
* @example
72+
* var bool = isFinite.isObject( 3.0 );
73+
* // returns false
74+
*
75+
* @example
76+
* var bool = isFinite.isObject( new Number( 3.0 ) );
77+
* // returns true
78+
*/
79+
isObject( value: any ): boolean;
80+
}
81+
82+
/**
83+
* Tests if a value is a finite number.
84+
*
85+
* @param value - value to test
86+
* @returns boolean indicating whether a value is a finite number
87+
*
88+
* @example
89+
* var bool = isFinite( 5.0 );
90+
* // returns true
91+
*
92+
* @example
93+
* var bool = isFinite( new Number( 5.0 ) );
94+
* // returns true
95+
*
96+
* @example
97+
* var bool = isFinite( 1.0/0.0 );
98+
* // returns false
99+
*
100+
* @example
101+
* var bool = isFinite( null );
102+
* // returns false
103+
*
104+
* @example
105+
* var bool = isFinite.isPrimitive( new Number( -3.0 ) );
106+
* // returns false
107+
* @example
108+
* var bool = isFinite.isObject( new Number( 3.0 ) );
109+
* // returns true
110+
*/
111+
declare var isFinite: IsFinite;
112+
113+
114+
// EXPORTS //
115+
116+
export = isFinite;
Lines changed: 61 additions & 0 deletions
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 isFinite = require( './index' );
20+
21+
22+
// TESTS //
23+
24+
// The function returns a boolean...
25+
{
26+
isFinite( 3 ); // $ExpectType boolean
27+
isFinite( 1 / 0 ); // $ExpectType boolean
28+
}
29+
30+
// The compiler throws an error if the function is provided an unsupported number of arguments...
31+
{
32+
isFinite(); // $ExpectError
33+
isFinite( 4, 123 ); // $ExpectError
34+
}
35+
36+
// Attached to main export is an isPrimitive method which returns a boolean...
37+
{
38+
// tslint:disable-next-line:no-construct
39+
isFinite.isPrimitive( new Number( 4 ) ); // $ExpectType boolean
40+
isFinite.isPrimitive( 4 ); // $ExpectType boolean
41+
}
42+
43+
// The compiler throws an error if the isPrimitive method is provided an unsupported number of arguments...
44+
{
45+
isFinite.isPrimitive(); // $ExpectError
46+
isFinite.isPrimitive( 4, 123 ); // $ExpectError
47+
}
48+
49+
50+
// Attached to main export is an isPrimitive method which returns a boolean...
51+
{
52+
// tslint:disable-next-line:no-construct
53+
isFinite.isObject( new Number( 4 ) ); // $ExpectType boolean
54+
isFinite.isObject( 4 ); // $ExpectType boolean
55+
}
56+
57+
// The compiler throws an error if the isObject method is provided an unsupported number of arguments...
58+
{
59+
isFinite.isObject(); // $ExpectError
60+
isFinite.isObject( 4, 123 ); // $ExpectError
61+
}

lib/node_modules/@stdlib/assert/is-finite/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: 109 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,109 @@
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 `isInfinite` with methods for testing for primitives and objects, respectively.
23+
*/
24+
interface IsInfinite {
25+
/**
26+
* Tests if a value is an infinite number.
27+
*
28+
* @param value - value to test
29+
* @returns boolean indicating whether a value is an infinite number
30+
*
31+
* @example
32+
* var bool = isInfinite( 1.0/0.0 );
33+
* // returns true
34+
*
35+
* @example
36+
* var bool = isInfinite( new Number( 1.0/0.0 ) );
37+
* // returns true
38+
*
39+
* @example
40+
* var bool = isInfinite( 5.0 );
41+
* // returns false
42+
*
43+
* @example
44+
* var bool = isInfinite( null );
45+
* // returns false
46+
*/
47+
( value: any ): boolean;
48+
49+
/**
50+
* Tests if a value is a number primitive having an infinite value.
51+
*
52+
* @param value - value to test
53+
* @returns boolean indicating if a value is a number primitive having an infinite value
54+
*
55+
* @example
56+
* var bool = isInfinite.isPrimitive( -1.0/0.0 );
57+
* // returns true
58+
*
59+
* @example
60+
* var bool = isInfinite.isPrimitive( new Number( -1.0/0.0 ) );
61+
* // returns false
62+
*/
63+
isPrimitive( value: any ): boolean;
64+
65+
/**
66+
* Tests if a value is a number object having an infinite value.
67+
*
68+
* @param value - value to test
69+
* @returns boolean indicating if a value is a number object having an infinite value
70+
*
71+
* @example
72+
* var bool = isInfinite.isObject( 1.0/0.0 );
73+
* // returns false
74+
*
75+
* @example
76+
* var bool = isInfinite.isObject( new Number( 1.0/0.0 ) );
77+
* // returns true
78+
*/
79+
isObject( value: any ): boolean;
80+
}
81+
82+
/**
83+
* Tests if a value is an infinite number.
84+
*
85+
* @param value - value to test
86+
* @returns boolean indicating whether a value is an infinite number
87+
*
88+
* @example
89+
* var bool = isInfinite( 1.0/0.0 );
90+
* // returns true
91+
*
92+
* @example
93+
* var bool = isInfinite( new Number( 1.0/0.0 ) );
94+
* // returns true
95+
*
96+
* @example
97+
* var bool = isInfinite( 5.0 );
98+
* // returns false
99+
*
100+
* @example
101+
* var bool = isInfinite( null );
102+
* // returns false
103+
*/
104+
declare var isInfinite: IsInfinite;
105+
106+
107+
// EXPORTS //
108+
109+
export = isInfinite;
Lines changed: 61 additions & 0 deletions
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 isInfinite = require( './index' );
20+
21+
22+
// TESTS //
23+
24+
// The function returns a boolean...
25+
{
26+
isInfinite( 3 ); // $ExpectType boolean
27+
isInfinite( 1 / 0 ); // $ExpectType boolean
28+
}
29+
30+
// The compiler throws an error if the function is provided an unsupported number of arguments...
31+
{
32+
isInfinite(); // $ExpectError
33+
isInfinite( 1 / 0, 123 ); // $ExpectError
34+
}
35+
36+
// Attached to main export is an isPrimitive method which returns a boolean...
37+
{
38+
// tslint:disable-next-line:no-construct
39+
isInfinite.isPrimitive( new Number( 1 / 0 ) ); // $ExpectType boolean
40+
isInfinite.isPrimitive( 1 / 0 ); // $ExpectType boolean
41+
}
42+
43+
// The compiler throws an error if the isPrimitive method is provided an unsupported number of arguments...
44+
{
45+
isInfinite.isPrimitive(); // $ExpectError
46+
isInfinite.isPrimitive( 1 / 0, 123 ); // $ExpectError
47+
}
48+
49+
50+
// Attached to main export is an isPrimitive method which returns a boolean...
51+
{
52+
// tslint:disable-next-line:no-construct
53+
isInfinite.isObject( new Number( 1 / 0 ) ); // $ExpectType boolean
54+
isInfinite.isObject( 1 / 0 ); // $ExpectType boolean
55+
}
56+
57+
// The compiler throws an error if the isObject method is provided an unsupported number of arguments...
58+
{
59+
isInfinite.isObject(); // $ExpectError
60+
isInfinite.isObject( 1 / 0, 123 ); // $ExpectError
61+
}

lib/node_modules/@stdlib/assert/is-infinite/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)