Skip to content

Commit fdd797d

Browse files
committed
Add Typescript definitions
1 parent 8566fff commit fdd797d

File tree

7 files changed

+184
-1
lines changed

7 files changed

+184
-1
lines changed
Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,58 @@
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+
* Tests if a value is a JavaScript boxed primitive.
23+
*
24+
* @param value - value to test
25+
* @returns boolean indicating if a value is a JavaScript boxed primitive
26+
*
27+
* @example
28+
* var bool = isBoxedPrimitive( new String( 'beep' ) );
29+
* // returns true
30+
*
31+
* @example
32+
* var bool = isBoxedPrimitive( new Number( 3.21 ) );
33+
* // returns true
34+
*
35+
* @example
36+
* var Symbol = require( '@stdlib/symbol/ctor' );
37+
* var bool = isBoxedPrimitive( Object( Symbol( 'beep' ) ) );
38+
* // returns true
39+
*
40+
* @example
41+
* var bool = isBoxedPrimitive( true );
42+
* // returns false
43+
*
44+
* @example
45+
* var bool = isBoxedPrimitive( {} );
46+
* // returns false
47+
*
48+
* @example
49+
* var Symbol = require( '@stdlib/symbol/ctor' );
50+
* var bool = isBoxedPrimitive( Symbol( 'beep' ) );
51+
* // returns false
52+
*/
53+
declare function isBoxedPrimitive( value: any ): boolean;
54+
55+
56+
// EXPORTS //
57+
58+
export = isBoxedPrimitive;
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
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 isBoxedPrimitive = require( './index' );
20+
21+
22+
// TESTS //
23+
24+
// The function returns a boolean...
25+
{
26+
// tslint:disable-next-line:no-construct
27+
isBoxedPrimitive( new String( 'beep' ) ); // $ExpectType boolean
28+
isBoxedPrimitive( 'beep' ); // $ExpectType boolean
29+
isBoxedPrimitive( [] ); // $ExpectType boolean
30+
31+
// tslint:disable-next-line:no-construct
32+
isBoxedPrimitive( new Number( 3.21 ) ); // $ExpectType boolean
33+
}
34+
35+
// The compiler throws an error if the function is provided an unsupported number of arguments...
36+
{
37+
isBoxedPrimitive(); // $ExpectError
38+
39+
// tslint:disable-next-line:no-construct
40+
isBoxedPrimitive( new String( 'beep' ), 123 ); // $ExpectError
41+
}

lib/node_modules/@stdlib/assert/is-boxed-primitive/lib/main.js

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,6 @@ var isSymbol = require( '@stdlib/assert/is-symbol' ).isObject;
5959
* var Symbol = require( '@stdlib/symbol/ctor' );
6060
* var bool = isBoxedPrimitive( Symbol( 'beep' ) );
6161
* // returns false
62-
*
6362
*/
6463
function isBoxedPrimitive( value ) {
6564
if ( typeof value !== 'object' ) {

lib/node_modules/@stdlib/assert/is-boxed-primitive/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+
* Tests whether a string matches a Node.js built-in module name.
23+
*
24+
* @param x - value to test
25+
* @returns boolean indicating whether a string matches a Node.js built-in module name
26+
*
27+
* @example
28+
* var out = isNodeBuiltin( 'cluster' );
29+
* // returns true
30+
*
31+
* @example
32+
* var out = isNodeBuiltin( 'crypto' );
33+
* // returns true
34+
*
35+
* @example
36+
* var out = isNodeBuiltin( 'fs-extra' );
37+
* // returns false
38+
*
39+
* @example
40+
* var out = isNodeBuiltin( '' );
41+
* // returns false
42+
*/
43+
declare function isNodeBuiltin( x: any ): boolean;
44+
45+
46+
// EXPORTS //
47+
48+
export = isNodeBuiltin;
Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,35 @@
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 isNodeBuiltin = require( './index' );
20+
21+
22+
// TESTS //
23+
24+
// The function returns a boolean...
25+
{
26+
isNodeBuiltin( 'cluster' ); // $ExpectType boolean
27+
isNodeBuiltin( 'fs-extra' ); // $ExpectType boolean
28+
isNodeBuiltin( null ); // $ExpectType boolean
29+
}
30+
31+
// The compiler throws an error if the function is provided an unsupported number of arguments...
32+
{
33+
isNodeBuiltin(); // $ExpectError
34+
isNodeBuiltin( null, 123 ); // $ExpectError
35+
}

lib/node_modules/@stdlib/assert/is-node-builtin/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,7 @@
2525
"lib": "./lib",
2626
"test": "./test"
2727
},
28+
"types": "./docs/types",
2829
"scripts": {},
2930
"homepage": "https://github.com/stdlib-js/stdlib",
3031
"repository": {

0 commit comments

Comments
 (0)