Skip to content

Commit 80ea46f

Browse files
committed
feat: docs added
1 parent b1f4e3e commit 80ea46f

File tree

3 files changed

+137
-0
lines changed

3 files changed

+137
-0
lines changed
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
2+
{{alias}}( a, b )
3+
Computes the least common multiple (lcm) of two
4+
single-precision floating-point numbers.
5+
6+
If either `a` or `b` is `0`, the function returns `0`.
7+
8+
Both `a` and `b` must have integer values; otherwise, the function returns
9+
`NaN`.
10+
11+
Parameters
12+
----------
13+
a: integer
14+
First integer.
15+
16+
b: integer
17+
Second integer.
18+
19+
Returns
20+
-------
21+
out: integer
22+
Least common multiple.
23+
24+
Examples
25+
--------
26+
> var v = {{alias}}( 21, 6 )
27+
42
28+
29+
See Also
30+
--------
31+
Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,50 @@
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: 4.1
20+
21+
/**
22+
* Computes the least common multiple (lcm) of two single-precision floating-point numbers.
23+
*
24+
* ## Notes
25+
*
26+
* - If either `a` or `b` is `0`, the function returns `0`.
27+
* - Both `a` and `b` must have integer values; otherwise, the function returns `NaN`.
28+
*
29+
* @param a - integer
30+
* @param b - integer
31+
* @returns least common multiple
32+
*
33+
* @example
34+
* var v = lcmf( 21, 6 );
35+
* // returns 42
36+
*
37+
* @example
38+
* var v = lcmf( 3.14, 6 );
39+
* // returns NaN
40+
*
41+
* @example
42+
* var v = lcmf( NaN, 6 );
43+
* // returns NaN
44+
*/
45+
declare function lcmf( a: number, b: number ): number;
46+
47+
48+
// EXPORTS //
49+
50+
export = lcmf;
Lines changed: 56 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,56 @@
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 lcmf = require( './index' );
20+
21+
22+
// TESTS //
23+
24+
// The function returns a number...
25+
{
26+
lcmf( 8, 2 ); // $ExpectType number
27+
}
28+
29+
// The compiler throws an error if the function is provided values other than two numbers...
30+
{
31+
lcmf( true, 3 ); // $ExpectError
32+
lcmf( false, 2 ); // $ExpectError
33+
lcmf( '5', 1 ); // $ExpectError
34+
lcmf( [], 1 ); // $ExpectError
35+
lcmf( {}, 2 ); // $ExpectError
36+
lcmf( ( x: number ): number => x, 2 ); // $ExpectError
37+
38+
lcmf( 9, true ); // $ExpectError
39+
lcmf( 9, false ); // $ExpectError
40+
lcmf( 5, '5' ); // $ExpectError
41+
lcmf( 8, [] ); // $ExpectError
42+
lcmf( 9, {} ); // $ExpectError
43+
lcmf( 8, ( x: number ): number => x ); // $ExpectError
44+
45+
lcmf( [], true ); // $ExpectError
46+
lcmf( {}, false ); // $ExpectError
47+
lcmf( false, '5' ); // $ExpectError
48+
lcmf( {}, [] ); // $ExpectError
49+
lcmf( '5', ( x: number ): number => x ); // $ExpectError
50+
}
51+
52+
// The compiler throws an error if the function is provided insufficient arguments...
53+
{
54+
lcmf(); // $ExpectError
55+
lcmf( 3 ); // $ExpectError
56+
}

0 commit comments

Comments
 (0)