Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
118 changes: 118 additions & 0 deletions lib/node_modules/@stdlib/number/uint64/base/assert/is-equal/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,118 @@
<!--

@license Apache-2.0

Copyright (c) 2026 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.

-->

# isEqual

> Test whether two unsigned 64-bit integers are equal.

<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->

<section class="intro">

</section>

<!-- /.intro -->

<!-- Package usage documentation. -->

<section class="usage">

## Usage

```javascript
var isEqual = require( '@stdlib/number/uint64/base/assert/is-equal' );
```

#### isEqual( a, b )

Tests whether two unsigned 64-bit integers are equal.

```javascript
var Uint64 = require( '@stdlib/number/uint64/ctor' );

var a = new Uint64( 1234 );
var b = Uint64.of( 0, 1234 );

var out = isEqual( a, b );
// returns true
```

</section>

<!-- /.usage -->

<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="notes">

</section>

<!-- /.notes -->

<!-- Package usage examples. -->

<section class="examples">

## Examples

<!-- eslint no-undef: "error" -->

```javascript
var Uint64 = require( '@stdlib/number/uint64/ctor' );
var isEqual = require( '@stdlib/number/uint64/base/assert/is-equal' );

var a = new Uint64( 1234 );
var b = Uint64.of( 0, 1234 );
var out = isEqual( a, b );
// returns true

a = new Uint64( 1234 );
b = new Uint64( 5678 );
out = isEqual( a, b );
// returns false
```

</section>

<!-- /.examples -->

<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="references">

</section>

<!-- /.references -->

<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->

<section class="related">

</section>

<!-- /.related -->

<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->

<section class="links">

</section>

<!-- /.links -->
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2026 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.
*/

'use strict';

// MODULES //

var bench = require( '@stdlib/bench' );
var MAX_SAFE_INTEGER = require( '@stdlib/constants/float64/max-safe-integer' );
var Uint64 = require( '@stdlib/number/uint64/ctor' );
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive;
var pkg = require( './../package.json' ).name;
var isEqual = require( './../lib' );


// MAIN //

bench( pkg, function benchmark( b ) {
var x;
var y;
var i;
var v;

x = discreteUniform( 100, 0, MAX_SAFE_INTEGER );
y = [];
for ( i = 0; i < x.length; i++ ) {
y.push( new Uint64( x[i] ) );
}

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
v = isEqual( y[ i % y.length ], y[ (i+1) % y.length ] );
if ( typeof v !== 'boolean' ) {
b.fail( 'should return a boolean' );
}
}
b.toc();
if ( !isBoolean( v ) ) {
b.fail( 'should return a boolean' );
}
b.pass( 'benchmark finished' );
b.end();
});
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@

{{alias}}( a, b )
Tests whether two unsigned 64-bit integers are equal.

Parameters
----------
a: Uint64
First unsigned 64-bit integer.

b: Uint64
Second unsigned 64-bit integer.

Returns
-------
out: boolean
Result.

Examples
--------
> var a = new {{alias:@stdlib/number/uint64/ctor}}( 1234 );
> var b = {{alias:@stdlib/number/uint64/ctor}}.of( 0, 1234 );
> var v = {{alias}}( a, b )
true

See Also
--------

Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
/*
* @license Apache-2.0
*
* Copyright (c) 2026 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

/// <reference types="@stdlib/types"/>

import { Uint64 } from '@stdlib/types/number';

/**
* Tests whether two unsigned 64-bit integers are equal.
*
* @param a - first unsigned 64-bit integer
* @param b - second unsigned 64-bit integer
* @returns boolean indicating if both unsigned 64-bit integers are equal
*
* @example
* var Uint64 = require( '@stdlib/number/uint64/ctor' );
*
* var a = new Uint64( 1234 );
* var b = Uint64.of( 0, 1234 );
*
* var v = isEqual( a, b );
* // returns true
*/
declare function isEqual( a: Uint64, b: Uint64 ): boolean;


// EXPORTS //

export = isEqual;
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/*
* @license Apache-2.0
*
* Copyright (c) 2026 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 Uint64 = require( '@stdlib/number/uint64/ctor' );
import isEqual = require( './index' );


// TESTS //

// The function returns a boolean...
{
const a = new Uint64( 1234 );
const b = Uint64.of( 0, 1234 );

isEqual( a, b ); // $ExpectType boolean
}

// The compiler throws an error if the function is provided a first argument that is not an unsigned 64-bit integer...
{
const b = new Uint64( 1234 );

isEqual( 'abc', b ); // $ExpectError
isEqual( 123, b ); // $ExpectError
isEqual( true, b ); // $ExpectError
isEqual( false, b ); // $ExpectError
isEqual( [], b ); // $ExpectError
isEqual( {}, b ); // $ExpectError
isEqual( ( x: number ): number => x, b ); // $ExpectError
}

// The compiler throws an error if the function is provided a second argument that is not an unsigned 64-bit integer...
{
const a = new Uint64( 1234 );

isEqual( a, 'abc' ); // $ExpectError
isEqual( a, 123 ); // $ExpectError
isEqual( a, true ); // $ExpectError
isEqual( a, false ); // $ExpectError
isEqual( a, [] ); // $ExpectError
isEqual( a, {} ); // $ExpectError
isEqual( a, ( x: number ): number => x ); // $ExpectError
}

// The compiler throws an error if the function is provided an unsupported number of arguments...
{
const a = new Uint64( 1234 );
const b = Uint64.of( 0, 1234 );

isEqual(); // $ExpectError
isEqual( a ); // $ExpectError
isEqual( a, b, {} ); // $ExpectError
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2026 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.
*/

'use strict';

var Uint64 = require( '@stdlib/number/uint64/ctor' );
var isEqual = require( './../lib' );

var a = new Uint64( 1234 );
var b = Uint64.of( 0, 1234 );
var out = isEqual( a, b );
// returns true

a = new Uint64( 1234 );
b = new Uint64( 5678 );
out = isEqual( a, b ); // eslint-disable-line no-unused-vars
// returns false
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2026 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.
*/

'use strict';

/**
* Test whether two unsigned 64-bit integers are equal.
*
* @module @stdlib/number/uint64/base/assert/is-equal
*
* @example
* var Uint64 = require( '@stdlib/number/uint64/ctor' );
* var isEqual = require( '@stdlib/number/uint64/base/assert/is-equal' );
*
* var a = new Uint64( 1234 );
* var b = Uint64.of( 0, 1234 );
*
* var v = isEqual( a, b );
* // returns true
*/

// MODULES //

var main = require( './main.js' );


// EXPORTS //

module.exports = main;
Loading