Skip to content

Commit

Permalink
feat: added docs
Browse files Browse the repository at this point in the history
  • Loading branch information
aayush0325 committed Oct 9, 2024
1 parent 0711fb5 commit 4c2151f
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 0 deletions.
30 changes: 30 additions & 0 deletions lib/node_modules/@stdlib/math/base/special/gcdf/docs/repl.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,30 @@

{{alias}}( a, b )
Computes the greatest common divisor (gcd).

If both `a` and `b` are `0`, the function returns `0`.

Both `a` and `b` must have integer values; otherwise, the function returns
`NaN`.

Parameters
----------
a: integer
First number.

b: integer
Second number.

Returns
-------
out: integer
Greatest common divisor.

Examples
--------
> var v = {{alias}}( 48, 18 )
6

See Also
--------

Original file line number Diff line number Diff line change
@@ -0,0 +1,50 @@
/*
* @license Apache-2.0
*
* Copyright (c) 2019 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

// TypeScript Version: 4.1

/**
* Computes the greatest common divisor (gcd).
*
* ## Notes
*
* - If both `a` and `b` are `0`, the function returns `0`.
* - Both `a` and `b` must have integer values; otherwise, the function returns `NaN`.
*
* @param a - first number
* @param b - second number
* @returns greatest common divisor
*
* @example
* var v = gcdf( 48, 18 );
* // returns 6
*
* @example
* var v = gcdf( 3.14, 18 );
* // returns NaN
*
* @example
* var v = gcdf( NaN, 18 );
* // returns NaN
*/
declare function gcdf( a: number, b: number ): number;


// EXPORTS //

export = gcdf;
56 changes: 56 additions & 0 deletions lib/node_modules/@stdlib/math/base/special/gcdf/docs/types/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
/*
* @license Apache-2.0
*
* Copyright (c) 2019 The Stdlib Authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

import gcdf = require( './index' );


// TESTS //

// The function returns a number...
{
gcdf( 8, 2 ); // $ExpectType number
}

// The compiler throws an error if the function is provided values other than two numbers...
{
gcdf( true, 3 ); // $ExpectError
gcdf( false, 2 ); // $ExpectError
gcdf( '5', 1 ); // $ExpectError
gcdf( [], 1 ); // $ExpectError
gcdf( {}, 2 ); // $ExpectError
gcdf( ( x: number ): number => x, 2 ); // $ExpectError

gcdf( 9, true ); // $ExpectError
gcdf( 9, false ); // $ExpectError
gcdf( 5, '5' ); // $ExpectError
gcdf( 8, [] ); // $ExpectError
gcdf( 9, {} ); // $ExpectError
gcdf( 8, ( x: number ): number => x ); // $ExpectError

gcdf( [], true ); // $ExpectError
gcdf( {}, false ); // $ExpectError
gcdf( false, '5' ); // $ExpectError
gcdf( {}, [] ); // $ExpectError
gcdf( '5', ( x: number ): number => x ); // $ExpectError
}

// The compiler throws an error if the function is provided insufficient arguments...
{
gcdf(); // $ExpectError
gcdf( 3 ); // $ExpectError
}

0 comments on commit 4c2151f

Please sign in to comment.