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 Mar 16, 2024
1 parent b98d7a3 commit 45326af
Show file tree
Hide file tree
Showing 4 changed files with 31 additions and 0 deletions.
15 changes: 15 additions & 0 deletions base/count-same-value/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,15 @@ var out = countSameValue( x, 1 );
// returns 2
```

In contrast to an implementation using the strict equality operator `===`, the function distinguishes between `+0` and `-0` and treats `NaNs` as the same value.

```javascript
var x = [ NaN, NaN, NaN ];

var out = countSameValue( x, NaN );
// returns 3
```

</section>

<!-- /.usage -->
Expand All @@ -59,6 +68,10 @@ var out = countSameValue( x, 1 );

<section class="notes">

## Notes

- The function uses the [SameValue Algorithm][@stdlib/assert/is-same-value] as specified in ECMAScript 5.

</section>

<!-- /.notes -->
Expand Down Expand Up @@ -108,6 +121,8 @@ console.log( n );

<section class="links">

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

</section>

<!-- /.links -->
2 changes: 2 additions & 0 deletions base/count-same-value/docs/repl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@
Counts the number of elements in an array that are equal to a specified
value.

The function treats `-0` and `+0` as distinct and `NaNs` as the same.

Parameters
----------
x: ArrayLikeObject
Expand Down
7 changes: 7 additions & 0 deletions base/count-same-value/docs/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -25,6 +25,13 @@ import { Collection } from '@stdlib/types/array';
/**
* Counts the number of elements in an array that are equal to a specified value.
*
* ## Notes
*
* - The function uses the [SameValue Algorithm][ecma-262-same-value-algorithm], as specified in ECMAScript 5.
* - In contrast to the strict equality operator `===`, `-0` and `+0` are distinguishable and `NaNs` are the same.
*
* [ecma-262-same-value-algorithm]: http://ecma-international.org/ecma-262/5.1/#sec-9.12
*
* @param x - input array
* @param value - search value
* @returns number of elements that are equal to a specified value
Expand Down
7 changes: 7 additions & 0 deletions base/count-same-value/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -138,6 +138,13 @@ function complex( x, value ) {
/**
* Counts the number of elements in an array that are equal to a specified value.
*
* ## Notes
*
* - The function uses the [SameValue Algorithm][ecma-262-same-value-algorithm], as specified in ECMAScript 5.
* - In contrast to the strict equality operator `===`, `-0` and `+0` are distinguishable and `NaNs` are the same.
*
* [ecma-262-same-value-algorithm]: http://ecma-international.org/ecma-262/5.1/#sec-9.12
*
* @param {Collection} x - input array
* @param {*} value - search value
* @returns {NonNegativeInteger} number of elements that are equal to a specified value
Expand Down

0 comments on commit 45326af

Please sign in to comment.