Skip to content

Commit 67e6684

Browse files
committed
Auto-generated commit
1 parent 2787651 commit 67e6684

File tree

5 files changed

+33
-2
lines changed

5 files changed

+33
-2
lines changed

README.md

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -84,6 +84,15 @@ var out = countSameValue( x, 1 );
8484
// returns 2
8585
```
8686

87+
In contrast to an implementation using the strict equality operator `===`, the function distinguishes between `+0` and `-0` and treats `NaNs` as the same value.
88+
89+
```javascript
90+
var x = [ NaN, NaN, NaN ];
91+
92+
var out = countSameValue( x, NaN );
93+
// returns 3
94+
```
95+
8796
</section>
8897

8998
<!-- /.usage -->
@@ -92,6 +101,10 @@ var out = countSameValue( x, 1 );
92101

93102
<section class="notes">
94103

104+
## Notes
105+
106+
- The function uses the [SameValue Algorithm][@stdlib/assert/is-same-value] as specified in ECMAScript 5.
107+
95108
</section>
96109

97110
<!-- /.notes -->
@@ -209,6 +222,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
209222

210223
[stdlib-license]: https://raw.githubusercontent.com/stdlib-js/array-base-count-same-value/main/LICENSE
211224

225+
[@stdlib/assert/is-same-value]: https://github.com/stdlib-js/assert-is-same-value
226+
212227
</section>
213228

214229
<!-- /.links -->

dist/index.js.map

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

docs/repl.txt

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@
33
Counts the number of elements in an array that are equal to a specified
44
value.
55

6+
The function treats `-0` and `+0` as distinct and `NaNs` as the same.
7+
68
Parameters
79
----------
810
x: ArrayLikeObject

docs/types/index.d.ts

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,13 @@ import { Collection } from '@stdlib/types/array';
2525
/**
2626
* Counts the number of elements in an array that are equal to a specified value.
2727
*
28+
* ## Notes
29+
*
30+
* - The function uses the [SameValue Algorithm][ecma-262-same-value-algorithm], as specified in ECMAScript 5.
31+
* - In contrast to the strict equality operator `===`, `-0` and `+0` are distinguishable and `NaNs` are the same.
32+
*
33+
* [ecma-262-same-value-algorithm]: http://ecma-international.org/ecma-262/5.1/#sec-9.12
34+
*
2835
* @param x - input array
2936
* @param value - search value
3037
* @returns number of elements that are equal to a specified value

lib/main.js

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -138,6 +138,13 @@ function complex( x, value ) {
138138
/**
139139
* Counts the number of elements in an array that are equal to a specified value.
140140
*
141+
* ## Notes
142+
*
143+
* - The function uses the [SameValue Algorithm][ecma-262-same-value-algorithm], as specified in ECMAScript 5.
144+
* - In contrast to the strict equality operator `===`, `-0` and `+0` are distinguishable and `NaNs` are the same.
145+
*
146+
* [ecma-262-same-value-algorithm]: http://ecma-international.org/ecma-262/5.1/#sec-9.12
147+
*
141148
* @param {Collection} x - input array
142149
* @param {*} value - search value
143150
* @returns {NonNegativeInteger} number of elements that are equal to a specified value

0 commit comments

Comments
 (0)