Skip to content

Commit cdd2442

Browse files
committed
Add Typescript definitions
1 parent d0faf1e commit cdd2442

File tree

16 files changed

+823
-0
lines changed

16 files changed

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

lib/node_modules/@stdlib/assert/is-empty-string/lib/main.js

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,18 @@ var isObject = require( './object.js' );
3131
*
3232
* @param {*} value - value to test
3333
* @returns {boolean} boolean indicating whether value is an empty string
34+
*
35+
* @example
36+
* var bool = isEmptyString( '' );
37+
* // returns true
38+
*
39+
* @example
40+
* var bool = isEmptyString( 'beep' );
41+
* // returns false
42+
*
43+
* @example
44+
* var bool = isEmptyString( [] );
45+
* // returns false
3446
*/
3547
function isEmptyString( value ) {
3648
return ( isPrimitive( value ) || isObject( value ) );

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

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