@@ -64,6 +64,8 @@ import cartesianSquare = require( '@stdlib/array/base/cartesian-square' );
64
64
import copy = require( '@stdlib/array/base/copy' ) ;
65
65
import copyIndexed = require( '@stdlib/array/base/copy-indexed' ) ;
66
66
import countFalsy = require( '@stdlib/array/base/count-falsy' ) ;
67
+ import countSameValue = require( '@stdlib/array/base/count-same-value' ) ;
68
+ import countSameValueZero = require( '@stdlib/array/base/count-same-value-zero' ) ;
67
69
import countTruthy = require( '@stdlib/array/base/count-truthy' ) ;
68
70
import dedupe = require( '@stdlib/array/base/dedupe' ) ;
69
71
import every = require( '@stdlib/array/base/every' ) ;
@@ -1340,6 +1342,47 @@ interface Namespace {
1340
1342
*/
1341
1343
countFalsy : typeof countFalsy ;
1342
1344
1345
+ /**
1346
+ * Counts the number of elements in an array that are equal to a specified value.
1347
+ *
1348
+ * ## Notes
1349
+ *
1350
+ * - The function uses the [SameValue Algorithm][ecma-262-same-value-algorithm], as specified in ECMAScript 5.
1351
+ * - In contrast to the strict equality operator `===`, `-0` and `+0` are distinguishable and `NaNs` are the same.
1352
+ *
1353
+ * [ecma-262-same-value-algorithm]: http://ecma-international.org/ecma-262/5.1/#sec-9.12
1354
+ *
1355
+ * @param x - input array
1356
+ * @param value - search value
1357
+ * @returns number of elements that are equal to a specified value
1358
+ *
1359
+ * @example
1360
+ * var x = [ 0, 1, 0, 1, 1 ];
1361
+ *
1362
+ * var out = ns.countSameValue( x, 1 );
1363
+ * // returns 3
1364
+ */
1365
+ countSameValue : typeof countSameValue ;
1366
+
1367
+ /**
1368
+ * Counts the number of elements in an array that are equal to a specified value.
1369
+ *
1370
+ * ## Notes
1371
+ *
1372
+ * - In contrast to an implementation based on the strict equality operator `===`, the function treats `NaNs` as the same value.
1373
+ *
1374
+ * @param x - input array
1375
+ * @param value - search value
1376
+ * @returns number of elements that are equal to a specified value
1377
+ *
1378
+ * @example
1379
+ * var x = [ 0, 1, 0, 1, 1 ];
1380
+ *
1381
+ * var out = ns.countSameValueZero( x, 1 );
1382
+ * // returns 3
1383
+ */
1384
+ countSameValueZero : typeof countSameValueZero ;
1385
+
1343
1386
/**
1344
1387
* Counts the number of truthy values in an array.
1345
1388
*
0 commit comments