Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Sep 9, 2024
1 parent 5cee291 commit 29a487d
Show file tree
Hide file tree
Showing 12 changed files with 696 additions and 1 deletion.
27 changes: 26 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@

<section class="release" id="unreleased">

## Unreleased (2024-09-08)
## Unreleased (2024-09-09)

<section class="packages">

Expand All @@ -20,6 +20,7 @@

##### Features

- [`1123204`](https://github.com/stdlib-js/stdlib/commit/11232044680f87bb3b53b447dab24e4e54b659ef) - add `isEqualArray` to namespace
- [`d64eaf8`](https://github.com/stdlib-js/stdlib/commit/d64eaf86a770b6d7fad0078d65afe7e2a79361cb) - add `isSameArrayLike` to namespace

</section>
Expand All @@ -32,6 +33,28 @@

<!-- /.package -->

<section class="package" id="assert-is-equal-array-unreleased">

#### [@stdlib/assert/is-equal-array](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-equal-array)

<details>

<section class="features">

##### Features

- [`c992288`](https://github.com/stdlib-js/stdlib/commit/c99228859333cce71cb2f913aa8acb2020cda9a0) - add `assert/is-equal-array`

</section>

<!-- /.features -->

</details>

</section>

<!-- /.package -->

<section class="package" id="assert-is-same-array-like-unreleased">

#### [@stdlib/assert/is-same-array-like](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/assert/is-same-array-like)
Expand Down Expand Up @@ -76,6 +99,8 @@ A total of 1 person contributed to this release. Thank you to this contributor:

<details>

- [`1123204`](https://github.com/stdlib-js/stdlib/commit/11232044680f87bb3b53b447dab24e4e54b659ef) - **feat:** add `isEqualArray` to namespace _(by Athan Reines)_
- [`c992288`](https://github.com/stdlib-js/stdlib/commit/c99228859333cce71cb2f913aa8acb2020cda9a0) - **feat:** add `assert/is-equal-array` _(by Athan Reines)_
- [`d64eaf8`](https://github.com/stdlib-js/stdlib/commit/d64eaf86a770b6d7fad0078d65afe7e2a79361cb) - **feat:** add `isSameArrayLike` to namespace _(by Athan Reines)_
- [`4e4d18d`](https://github.com/stdlib-js/stdlib/commit/4e4d18d142ca65c1257c2e2b7fa979dbbafb4741) - **feat:** add `assert/is-same-array-like` _(by Athan Reines)_

Expand Down
108 changes: 108 additions & 0 deletions is-equal-array/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,108 @@
<!--
@license Apache-2.0
Copyright (c) 2024 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.
-->

# isEqualArray

> Test if two arguments are both generic arrays and have equal values.
<section class="usage">

## Usage

```javascript
var isEqualArray = require( '@stdlib/assert/is-equal-array' );
```

#### isEqualArray( v1, v2 )

Tests if two arguments are both generic arrays and have equal values.

```javascript
var x = [ 1.0, 2.0 ];
var y = [ 1.0, 2.0 ];
var bool = isEqualArray( x, y );
// returns true

bool = isEqualArray( x, [ -1.0, 2.0 ] );
// returns false
```

</section>

<!-- /.usage -->

<section class="notes">

## Notes

- The function performs strict equality comparison; thus, the function treats `-0` and `+0` as equal and `NaNs` as distinct.

</section>

<!-- /.notes -->

<section class="examples">

## Examples

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

```javascript
var isEqualArray = require( '@stdlib/assert/is-equal-array' );

var x = [ 1.0, 2.0, 3.0 ];
var y = [ 1.0, 2.0, 3.0 ];
var out = isEqualArray( x, y );
// returns true

x = [ -0.0, 0.0, -0.0 ];
y = [ 0.0, -0.0, 0.0 ];
out = isEqualArray( x, y );
// returns true

x = [ NaN, NaN, NaN ];
y = [ NaN, NaN, NaN ];
out = isEqualArray( x, y );
// returns false
```

</section>

<!-- /.examples -->

<!-- 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">

<!-- <related-links> -->

<!-- </related-links> -->

</section>

<!-- /.links -->
96 changes: 96 additions & 0 deletions is-equal-array/benchmark/benchmark.length.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,96 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2024 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 isBoolean = require( './../../is-boolean' ).isPrimitive;
var pow = require( '@stdlib/math/base/special/pow' );
var zeroTo = require( '@stdlib/array/base/zero-to' );
var pkg = require( './../package.json' ).name;
var isEqualArray = require( './../lib' );


// FUNCTIONS //

/**
* Creates a benchmark function.
*
* @private
* @param {PositiveInteger} len - array length
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var x = zeroTo( len );
var y = zeroTo( len );
return benchmark;

/**
* Benchmark function.
*
* @private
* @param {Benchmark} b - benchmark instance
*/
function benchmark( b ) {
var bool;
var i;

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
bool = isEqualArray( x, y );
if ( typeof bool !== 'boolean' ) {
b.fail( 'should return a boolean' );
}
}
b.toc();
if ( !isBoolean( bool ) ) {
b.fail( 'should return a boolean' );
}
b.pass( 'benchmark finished' );
b.end();
}
}


// MAIN //

/**
* Main execution sequence.
*
* @private
*/
function main() {
var len;
var min;
var max;
var f;
var i;

min = 1; // 10^min
max = 6; // 10^max

for ( i = min; i <= max; i++ ) {
len = pow( 10, i );
f = createBenchmark( len );
bench( pkg+':len='+len, f );
}
}

main();
35 changes: 35 additions & 0 deletions is-equal-array/docs/repl.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@

{{alias}}( v1, v2 )
Tests if two arguments are both generic arrays and have equal values.

The function performs strict equality comparison; thus, the function treats
`-0` and `+0` as equal and `NaNs` as distinct.

Parameters
----------
v1: any
First input value.

v2: any
Second input value.

Returns
-------
bool: boolean
Boolean indicating whether two arguments are equal.

Examples
--------
> var x = [ 1.0, 2.0, 3.0 ];
> var y = [ 1.0, 2.0, 3.0 ];
> var bool = {{alias}}( x, y )
true

> x = [ NaN, NaN, NaN ];
> y = [ NaN, NaN, NaN ];
> bool = {{alias}}( x, y )
false

See Also
--------

51 changes: 51 additions & 0 deletions is-equal-array/docs/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
/*
* @license Apache-2.0
*
* Copyright (c) 2024 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

/**
* Tests if two arguments are both generic arrays and have equal values.
*
* ## Notes
*
* - The function performs strict equality comparison; thus, the function treats `-0` and `+0` as equal and `NaNs` as distinct.
*
* @param v1 - first input value
* @param v2 - second input value
* @returns boolean indicating whether two arguments are equal
*
* @example
* var x = [ 1.0, 2.0, 3.0 ];
* var y = [ 1.0, 2.0, 3.0 ];
*
* var out = isEqualArray( x, y );
* // returns true
*
* @example
* var x = [ 1.0, 2.0, 3.0 ];
* var y = [ 1.0, 2.0, 4.0 ];
*
* var out = isEqualArray( x, y );
* // returns false
*/
declare function isEqualArray( v1: any, v2: any ): boolean;


// EXPORTS //

export = isEqualArray;
36 changes: 36 additions & 0 deletions is-equal-array/docs/types/test.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
* @license Apache-2.0
*
* Copyright (c) 2024 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 isEqualArray = require( './index' );


// TESTS //

// The function returns a boolean...
{
isEqualArray( 3.14, 3.14 ); // $ExpectType boolean
isEqualArray( null, null ); // $ExpectType boolean
isEqualArray( 'beep', 'boop' ); // $ExpectType boolean
}

// The compiler throws an error if the function is provided an unsupported number of arguments...
{
isEqualArray(); // $ExpectError
isEqualArray( 3.14 ); // $ExpectError
isEqualArray( 'beep', 'beep', 3.14 ); // $ExpectError
}
Loading

0 comments on commit 29a487d

Please sign in to comment.