Skip to content

Commit 3b3f56b

Browse files
committed
Add Typescript definitions
1 parent 8096d08 commit 3b3f56b

File tree

18 files changed

+458
-0
lines changed

18 files changed

+458
-0
lines changed
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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+
* Operating system CPU architecture.
23+
*
24+
* ## Notes
25+
*
26+
* Current possible values:
27+
*
28+
* - arm
29+
* - arm64
30+
* - ia32
31+
* - mips
32+
* - mipsel
33+
* - ppc
34+
* - ppc64
35+
* - s390
36+
* - s390x
37+
* - x32
38+
* - x64
39+
*
40+
* @example
41+
* if ( ARCH === 'arm' || ARCH === 'arm64' ) {
42+
* console.log( 'Running on ARM...' );
43+
* } else {
44+
* console.log( 'Running on something else...' );
45+
* }
46+
*/
47+
declare const ARCH: string;
48+
49+
50+
// EXPORTS //
51+
52+
export = ARCH;
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
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 ARCH = require( './index' );
20+
21+
22+
// TESTS //
23+
24+
// The variable is a string...
25+
{
26+
// tslint:disable-next-line:no-unused-expression
27+
ARCH; // $ExpectType string
28+
}

lib/node_modules/@stdlib/os/arch/package.json

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
"lib": "./lib",
2525
"test": "./test"
2626
},
27+
"types": "./docs/types",
2728
"scripts": {},
2829
"homepage": "https://github.com/stdlib-js/stdlib",
2930
"repository": {
Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
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+
* Returns a directory for user-specific configuration files.
23+
*
24+
* ## Notes
25+
*
26+
* - On Windows platforms, the function first checks for a `LOCALAPPDATA` environment variable before checking for an `APPDATA` environment variable. This means that machine specific user configuration files have precedence over roaming user configuration files.
27+
* - On non-Windows platforms, if the function is unable to locate the current user's `home` directory, the function returns `null`. Similarly, on Windows platforms, if the function is unable to locate an application data directory, the function also returns `null`.
28+
*
29+
* @param [p] - path to append to a base directory
30+
* @returns directory
31+
*
32+
* @example
33+
* var dir = configdir();
34+
* // e.g., returns '/Users/<username>/Library/Preferences'
35+
*
36+
* @example
37+
* var dir = configdir( 'appname/config' );
38+
* // e.g., returns '/Users/<username>/Library/Preferences/appname/config'
39+
*/
40+
declare function configdir( p?: string ): string;
41+
42+
43+
// EXPORTS //
44+
45+
export = configdir;
Lines changed: 43 additions & 0 deletions
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+
import configdir = require( './index' );
20+
21+
22+
// TESTS //
23+
24+
// The function returns a string...
25+
{
26+
configdir(); // $ExpectType string
27+
configdir( 'appname/config' ); // $ExpectType string
28+
}
29+
30+
// The function does not compile if provided a value other than a string...
31+
{
32+
configdir( true ); // $ExpectError
33+
configdir( false ); // $ExpectError
34+
configdir( 5 ); // $ExpectError
35+
configdir( [] ); // $ExpectError
36+
configdir( {} ); // $ExpectError
37+
configdir( ( x: number ): number => x ); // $ExpectError
38+
}
39+
40+
// The function does not compile if provided insufficient arguments...
41+
{
42+
configdir( 'appname/config', 2 ); // $ExpectError
43+
}

lib/node_modules/@stdlib/os/configdir/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": {
Lines changed: 39 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,39 @@
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+
* Returns the current user's home directory.
23+
*
24+
* ## Notes
25+
*
26+
* - If unable to locate a home directory, the function returns `null`.
27+
*
28+
* @returns home directory
29+
*
30+
* @example
31+
* var home = homedir();
32+
* // e.g., returns '/Users/<username>'
33+
*/
34+
declare function homedir(): string;
35+
36+
37+
// EXPORTS //
38+
39+
export = homedir;
Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,33 @@
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 homedir = require( './index' );
20+
21+
22+
// TESTS //
23+
24+
// The function returns a string...
25+
{
26+
homedir(); // $ExpectType string
27+
}
28+
29+
// The function does not compile if provided arguments...
30+
{
31+
homedir( 'appname/config' ); // $ExpectError
32+
homedir( 'appname/config', 2 ); // $ExpectError
33+
}

lib/node_modules/@stdlib/os/homedir/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": {
Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
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+
* Number of CPUs.
23+
*
24+
* ## Notes
25+
*
26+
* - In browser environments, the number of CPUs is determined by querying the hardware concurrency API.
27+
* - In Node.js environments, the number of CPUs is determined via the `os` module.
28+
*
29+
* @example
30+
* var num = NUM_CPUS;
31+
* // returns <number>
32+
*/
33+
declare const NUM_CPUS: number;
34+
35+
36+
// EXPORTS //
37+
38+
export = NUM_CPUS;

0 commit comments

Comments
 (0)