Skip to content

Commit 9e0aa02

Browse files
committed
Add Typescript definitions
1 parent f8a007b commit 9e0aa02

File tree

9 files changed

+256
-0
lines changed

9 files changed

+256
-0
lines changed
Lines changed: 57 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,57 @@
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 number of minutes in a month.
23+
*
24+
* ## Notes
25+
*
26+
* - By default, the function returns the number of minutes in the current month of the current year (according to local time). To determine the number of minutes for a particular month and year, provide `month` and `year` arguments.
27+
* - A `month` may be either a month's integer value, three letter abbreviation, or full name (case insensitive).
28+
* - The function's return value is a generalization and does **not** take into account inaccuracies due to daylight savings conventions, crossing timezones, or other complications with time and dates.
29+
*
30+
* @param [month] - month
31+
* @param [year] - year
32+
* @throws must provide a recognized month
33+
* @throws an integer month argument must be on the interval `[1,12]`
34+
* @returns minutes in a month
35+
*
36+
* @example
37+
* var num = minutesInMonth();
38+
* // returns <number>
39+
*
40+
* @example
41+
* var num = minutesInMonth( 2 );
42+
* // returns <number>
43+
*
44+
* @example
45+
* var num = minutesInMonth( 2, 2016 );
46+
* // returns 41760
47+
*
48+
* @example
49+
* var num = minutesInMonth( 2, 2017 );
50+
* // returns 40320
51+
*/
52+
declare function minutesInMonth( month?: string | number | Date, year?: number ): number; // tslint-disable-line max-line-length
53+
54+
55+
// EXPORTS //
56+
57+
export = minutesInMonth;
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
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 minutesInMonth = require( './index' );
20+
21+
22+
// TESTS //
23+
24+
// The function returns a number...
25+
{
26+
minutesInMonth( 1, 1990 ); // $ExpectType number
27+
minutesInMonth( 'Jan', 1990 ); // $ExpectType number
28+
minutesInMonth(); // $ExpectType number
29+
minutesInMonth( new Date() ) ; // $ExpectType number
30+
}
31+
32+
// The function does not compile if provided arguments of invalid types...
33+
{
34+
minutesInMonth( [], 2016 ); // $ExpectError
35+
minutesInMonth( {}, 2016 ); // $ExpectError
36+
minutesInMonth( false, 2016 ); // $ExpectError
37+
minutesInMonth( true, 2016 ); // $ExpectError
38+
minutesInMonth( ( x: number ): number => x, 2016 ); // $ExpectError
39+
40+
minutesInMonth( 2, true ); // $ExpectError
41+
minutesInMonth( 2, false ); // $ExpectError
42+
minutesInMonth( 2, ( x: number ): number => x ); // $ExpectError
43+
minutesInMonth( 2, [] ); // $ExpectError
44+
minutesInMonth( 2, {} ); // $ExpectError
45+
minutesInMonth( 2, 'beep' ); // $ExpectError
46+
}
47+
48+
// The function does not compile if provided more than two arguments...
49+
{
50+
minutesInMonth( 1, 15, 1990 ); // $ExpectError
51+
}

lib/node_modules/@stdlib/time/minutes-in-month/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: 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 time in seconds since the epoch.
23+
*
24+
* ## Notes
25+
*
26+
* - The Unix epoch is 00:00:00 UTC on 1 January 1970.
27+
*
28+
* @returns time
29+
*
30+
* @example
31+
* var ts = now();
32+
* // returns <number>
33+
*/
34+
declare function now(): number;
35+
36+
37+
// EXPORTS //
38+
39+
export = now;
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 now = require( './index' );
20+
21+
22+
// TESTS //
23+
24+
// The function returns a number...
25+
{
26+
now(); // $ExpectType number
27+
}
28+
29+
// The compiler throws an error if the function is provided arguments...
30+
{
31+
now( true ); // $ExpectError
32+
now( [], 123 ); // $ExpectError
33+
}

lib/node_modules/@stdlib/time/now/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: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,40 @@
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 high-resolution time.
23+
*
24+
* ## Notes
25+
*
26+
* - The returned array has the following format: `[seconds, nanoseconds]`.
27+
*
28+
*
29+
* @returns high resolution time
30+
*
31+
* @example
32+
* var t = tic();
33+
* // returns [<number>,<number>]
34+
*/
35+
declare function tic(): Array<number>;
36+
37+
38+
// EXPORTS //
39+
40+
export = tic;
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 tic = require( './index' );
20+
21+
22+
// TESTS //
23+
24+
// The function returns an array of numbers...
25+
{
26+
tic(); // $ExpectType number[]
27+
}
28+
29+
// The compiler throws an error if the function is provided arguments...
30+
{
31+
tic( true ); // $ExpectError
32+
tic( [], 123 ); // $ExpectError
33+
}

lib/node_modules/@stdlib/time/tic/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)