Skip to content

Commit 03e011d

Browse files
committed
Add Typescript definitions
1 parent fe60b0b commit 03e011d

File tree

5 files changed

+391
-0
lines changed

5 files changed

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

0 commit comments

Comments
 (0)