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 15, 2024
1 parent f69cf34 commit c3ee1c7
Show file tree
Hide file tree
Showing 11 changed files with 777 additions and 2 deletions.
28 changes: 26 additions & 2 deletions 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-11)
## Unreleased (2024-09-15)

<section class="packages">

Expand Down Expand Up @@ -101,6 +101,28 @@

<!-- /.package -->

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

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

<details>

<section class="features">

##### Features

- [`7bb8e20`](https://github.com/stdlib-js/stdlib/commit/7bb8e2020d334d9f9a838291e78d2f7442b24a67) - add `@stdlib/assert/is-same-accessor-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 @@ -131,8 +153,9 @@

### Contributors

A total of 3 people contributed to this release. Thank you to the following contributors:
A total of 4 people contributed to this release. Thank you to the following contributors:

- Aayush Khanna
- Athan Reines
- Philipp Burckhardt
- Soumajit Chatterjee
Expand All @@ -147,6 +170,7 @@ A total of 3 people contributed to this release. Thank you to the following cont

<details>

- [`7bb8e20`](https://github.com/stdlib-js/stdlib/commit/7bb8e2020d334d9f9a838291e78d2f7442b24a67) - **feat:** add `@stdlib/assert/is-same-accessor-array` _(by Aayush Khanna, Philipp Burckhardt)_
- [`1f6fc8b`](https://github.com/stdlib-js/stdlib/commit/1f6fc8b5b99837f9d8b378413298f7544f1cb38e) - **bench:** update benchmarks to measure affirmative/negative test values _(by Soumajit Chatterjee, Philipp Burckhardt)_
- [`e97215f`](https://github.com/stdlib-js/stdlib/commit/e97215fbf9f4d1ec8548086f78ed04a0ec80a43f) - **feat:** add `hasBtoaSupport` to namespace _(by Athan Reines)_
- [`33219ce`](https://github.com/stdlib-js/stdlib/commit/33219cecbc347a85b4bb9659d00005fe7b5a6e64) - **feat:** add `assert/has-btoa-support` _(by Athan Reines)_
Expand Down
115 changes: 115 additions & 0 deletions is-same-accessor-array/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,115 @@
<!--
@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.
-->

# isSameAccessorArray

> Test if two arguments are both [accessor arrays][@stdlib/assert/is-accessor-array] and have the [same values][@stdlib/assert/is-same-value].
<section class="usage">

## Usage

```javascript
var isSameAccessorArray = require( '@stdlib/assert/is-same-accessor-array' );
```

#### isSameAccessorArray( v1, v2 )

Tests if two arguments are both [accessor arrays][@stdlib/assert/is-accessor-array] and have the [same values][@stdlib/assert/is-same-value].

```javascript
var Complex128Array = require( '@stdlib/array/complex128' );

var x = new Complex128Array( [ 1.0, 2.0 ] );
var y = new Complex128Array( [ 1.0, 2.0 ] );
var bool = isSameAccessorArray( x, y );
// returns true

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

</section>

<!-- /.usage -->

<section class="notes">

## Notes

- In contrast to the strict equality operator `===`, the function distinguishes between `+0` and `-0` and treats `NaNs` as the [same value][@stdlib/assert/is-same-value].

</section>

<!-- /.notes -->

<section class="examples">

## Examples

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

```javascript
var isSameAccessorArray = require( '@stdlib/assert/is-same-accessor-array' );
var Complex128Array = require( '@stdlib/array/complex128' );

var x = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] );
var y = new Complex128Array( [ 1.0, 2.0, 3.0, 4.0 ] );
var out = isSameAccessorArray( x, y );
// returns true

x = new Complex128Array( [ 1.0, 2.0, 0.0, 4.0 ] );
y = new Complex128Array( [ 1.0, 2.0, 3.0, -1.0 ] );
out = isSameAccessorArray( x, y );
// returns false

x = new Complex128Array( [ NaN, NaN ] );
y = new Complex128Array( [ NaN, NaN ] );
out = isSameAccessorArray( x, y );
// returns true
```

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

[@stdlib/assert/is-same-value]: https://github.com/stdlib-js/assert/tree/main/is-same-value

[@stdlib/assert/is-accessor-array]: https://github.com/stdlib-js/assert/tree/main/is-accessor-array

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

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

</section>

<!-- /.links -->
97 changes: 97 additions & 0 deletions is-same-accessor-array/benchmark/benchmark.length.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,97 @@
/**
* @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 complex128Array = require( '@stdlib/array/complex128' );
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 isSameAccessorArray = require( './../lib' );


// FUNCTIONS //

/**
* Creates a benchmark function.
*
* @private
* @param {PositiveInteger} len - array length
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var x = complex128Array( zeroTo( len ) );
var y = complex128Array( 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 = isSameAccessorArray( 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();
36 changes: 36 additions & 0 deletions is-same-accessor-array/docs/repl.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@

{{alias}}( v1, v2 )
Tests if two arguments are both accessor arrays and have the same values.

The function differs from the `===` operator in that the function treats
`-0` and `+0` as distinct and `NaNs` as the same.

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

v2: any
Second input value.

Returns
-------
bool: boolean
Boolean indicating whether two arguments are both accessor arrays
having the same values.

Examples
--------
> var x = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0 ] );
> var y = new {{alias:@stdlib/array/complex128}}( [ 1.0, 2.0, 3.0, 4.0 ] );
> var bool = {{alias}}( x, y )
true

> x = new {{alias:@stdlib/array/complex128}}( [] );
> y = new {{alias:@stdlib/array/complex128}}( [] );
> bool = {{alias}}( x, y )
true

See Also
--------

61 changes: 61 additions & 0 deletions is-same-accessor-array/docs/types/index.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
/*
* @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 accessor arrays and have the same values.
*
* ## Notes
*
* - The function differs from the `===` operator in that the function treats `-0` and `+0` as distinct and `NaNs` as the same.
*
* @param v1 - first input value
* @param v2 - second input value
* @returns boolean indicating whether two arguments are accessor arrays with the same content
*
* @example
* var Complex128Array = require( '@stdlib/array/complex128' );
*
* var x = new Complex128Array( [ 1, 2, 1, 2 ] );
* var y = new Complex128Array( [ 1, 2, 1, 2 ] );
* var out = isSameAccessorArray( x, y );
* // returns true
*
* @example
* var Complex128Array = require( '@stdlib/array/complex128' );
*
* var x = new Complex128Array( [ 1, 2, 1, 2 ] );
* var y = new Complex128Array( [ 2, 1, 2, 1 ] );
* var out = isSameAccessorArray( x, y );
* // returns false
*
* @example
* var Complex128Array = require( '@stdlib/array/complex128' );
*
* var x = new Complex128Array( [ 1, 2, 1, 2 ] );
* var y = [ 1, 2, 3 ];
* var out = isSameAccessorArray( x, y );
* // returns false
*/
declare function isSameAccessorArray( v1: any, v2: any ): boolean;


// EXPORTS //

export = isSameAccessorArray;
Loading

0 comments on commit c3ee1c7

Please sign in to comment.