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 8, 2024
1 parent ecff63a commit 5cee291
Show file tree
Hide file tree
Showing 14 changed files with 772 additions and 2 deletions.
87 changes: 87 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,93 @@

> Package changelog.

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

## Unreleased (2024-09-08)

<section class="packages">

### Packages

<section class="package" id="assert-unreleased">

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

<details>

<section class="features">

##### Features

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

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

<details>

<section class="features">

##### Features

- [`4e4d18d`](https://github.com/stdlib-js/stdlib/commit/4e4d18d142ca65c1257c2e2b7fa979dbbafb4741) - add `assert/is-same-array-like`

</section>

<!-- /.features -->

</details>

</section>

<!-- /.package -->

</section>

<!-- /.packages -->

<section class="contributors">

### Contributors

A total of 1 person contributed to this release. Thank you to this contributor:

- Athan Reines

</section>

<!-- /.contributors -->

<section class="commits">

### Commits

<details>

- [`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)_

</details>

</section>

<!-- /.commits -->

</section>

<!-- /.release -->

<section class="release" id="v0.3.1">

## 0.3.1 (2024-08-18)
Expand Down
5 changes: 5 additions & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -26,11 +26,13 @@ EuniceSim142 <[email protected]>
Frank Kovacs <[email protected]>
Golden Kumar <[email protected]>
Gunj Joshi <[email protected]>
HarshaNP <[email protected]>
Harshita Kalani <[email protected]>
Hridyanshu <[email protected]>
Jaimin Godhani <[email protected]>
James Gelok <[email protected]>
Jaysukh Makvana <[email protected]>
Jenish Thapa <[email protected]>
Jithin KS <[email protected]>
Joel Mathew Koshy <[email protected]>
Joey Reed <[email protected]>
Expand Down Expand Up @@ -86,8 +88,10 @@ Stephannie Jiménez Gacha <[email protected]>
Suraj kumar <[email protected]>
Tirtadwipa Manunggal <[email protected]>
Tudor Pagu <[email protected]>
Tufailahmed Bargir <[email protected]>
Utkarsh <http://[email protected]>
Utkarsh Raj <[email protected]>
Vaibhav Patel <[email protected]>
Varad Gupta <[email protected]>
Xiaochuan Ye <[email protected]>
Yernar Yergaziyev <[email protected]>
Expand All @@ -96,3 +100,4 @@ nishant-s7 <[email protected]>
orimiles5 <[email protected]>
rainn <[email protected]>
rei2hu <[email protected]>
yaswanth <[email protected]>
4 changes: 2 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -593,8 +593,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
[npm-image]: http://img.shields.io/npm/v/@stdlib/assert.svg
[npm-url]: https://npmjs.org/package/@stdlib/assert

[test-image]: https://github.com/stdlib-js/assert/actions/workflows/test.yml/badge.svg?branch=v0.3.1
[test-url]: https://github.com/stdlib-js/assert/actions/workflows/test.yml?query=branch:v0.3.1
[test-image]: https://github.com/stdlib-js/assert/actions/workflows/test.yml/badge.svg?branch=main
[test-url]: https://github.com/stdlib-js/assert/actions/workflows/test.yml?query=branch:main

[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/assert/main.svg
[coverage-url]: https://codecov.io/github/stdlib-js/assert?branch=main
Expand Down
110 changes: 110 additions & 0 deletions is-same-array-like/README.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,110 @@
<!--
@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.
-->

# isSameArrayLike

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

## Usage

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

#### isSameArrayLike( v1, v2 )

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

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

bool = isSameArrayLike( 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 isSameArrayLike = require( '@stdlib/assert/is-same-array-like' );

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

x = [ -0.0, 0.0, -0.0 ];
y = [ 0.0, -0.0, 0.0 ];
out = isSameArrayLike( x, y );
// returns false

x = [ NaN, NaN, NaN ];
y = [ NaN, NaN, NaN ];
out = isSameArrayLike( 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

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

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

</section>

<!-- /.links -->
96 changes: 96 additions & 0 deletions is-same-array-like/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 isSameArrayLike = 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 = isSameArrayLike( 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-same-array-like/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 array-like 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 the same.

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 )
true

See Also
--------

Loading

0 comments on commit 5cee291

Please sign in to comment.