From f8fcc76a66a786397bd63084db3008726561a62f Mon Sep 17 00:00:00 2001
From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com>
Date: Mon, 10 Mar 2025 10:45:51 +0000
Subject: [PATCH 1/7] feat: add array/base/count-ifs
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown
status: passed
- task: lint_package_json
status: passed
- task: lint_repl_help
status: passed
- task: lint_javascript_src
status: passed
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: passed
- task: lint_javascript_tests
status: passed
- task: lint_javascript_benchmarks
status: passed
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: na
- task: lint_c_examples
status: na
- task: lint_c_benchmarks
status: na
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: passed
- task: lint_license_headers
status: passed
---
---
.../@stdlib/array/base/count-ifs/README.md | 149 ++++++++++++++++
.../count-ifs/benchmark/benchmark.length.js | 123 +++++++++++++
.../array/base/count-ifs/docs/repl.txt | 39 ++++
.../base/count-ifs/docs/types/index.d.ts | 149 ++++++++++++++++
.../array/base/count-ifs/docs/types/test.ts | 118 +++++++++++++
.../array/base/count-ifs/examples/index.js | 42 +++++
.../@stdlib/array/base/count-ifs/lib/index.js | 51 ++++++
.../@stdlib/array/base/count-ifs/lib/main.js | 122 +++++++++++++
.../@stdlib/array/base/count-ifs/package.json | 67 +++++++
.../@stdlib/array/base/count-ifs/test/test.js | 166 ++++++++++++++++++
10 files changed, 1026 insertions(+)
create mode 100644 lib/node_modules/@stdlib/array/base/count-ifs/README.md
create mode 100644 lib/node_modules/@stdlib/array/base/count-ifs/benchmark/benchmark.length.js
create mode 100644 lib/node_modules/@stdlib/array/base/count-ifs/docs/repl.txt
create mode 100644 lib/node_modules/@stdlib/array/base/count-ifs/docs/types/index.d.ts
create mode 100644 lib/node_modules/@stdlib/array/base/count-ifs/docs/types/test.ts
create mode 100644 lib/node_modules/@stdlib/array/base/count-ifs/examples/index.js
create mode 100644 lib/node_modules/@stdlib/array/base/count-ifs/lib/index.js
create mode 100644 lib/node_modules/@stdlib/array/base/count-ifs/lib/main.js
create mode 100644 lib/node_modules/@stdlib/array/base/count-ifs/package.json
create mode 100644 lib/node_modules/@stdlib/array/base/count-ifs/test/test.js
diff --git a/lib/node_modules/@stdlib/array/base/count-ifs/README.md b/lib/node_modules/@stdlib/array/base/count-ifs/README.md
new file mode 100644
index 000000000000..ab8b02e61644
--- /dev/null
+++ b/lib/node_modules/@stdlib/array/base/count-ifs/README.md
@@ -0,0 +1,149 @@
+
+
+# countIfs
+
+> Count the number of elements in the input arrays which pass the tests implemented by the predicate functions.
+
+
+
+
+
+
+
+
+
+
+
+## Usage
+
+```javascript
+var countIfs = require( '@stdlib/array/base/count-ifs' );
+```
+
+#### countIfs( x0, predicate0\[, x1, predicate1\[, x2, predicate2, ...]] )
+
+Counts the number of elements in the input arrays which pass the tests implemented by the predicate functions.
+
+```javascript
+function predicate0( value ) {
+ return ( value > 0 );
+}
+
+function predicate1( value ) {
+ return ( value < 3 );
+}
+
+var x0 = [ 0, 1, 0, 1, 2 ];
+var x1 = [ 2, 3, 1, 2, 5 ];
+
+var out = countIfs( x0, predicate0, x1, predicate1 );
+// returns 1
+```
+
+The `predicate` function is provided three arguments:
+
+- **value**: current array element.
+- **index**: current array element index.
+- **arr**: input array.
+
+
+
+
+
+
+
+
+
+## Notes
+
+- The function assumes that all input arrays have the same length.
+- The function supports array-like objects supporting the accessor protocol (e.g., [`Complex128Array`][@stdlib/array/complex128], [`Complex64Array`][@stdlib/array/complex64], etc).
+
+
+
+
+
+
+
+
+
+## Examples
+
+
+
+```javascript
+var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
+var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive;
+var isNegativeInteger = require( '@stdlib/assert/is-negative-integer' ).isPrimitive;
+var naryFunction = require( '@stdlib/utils/nary-function' );
+var countIfs = require( '@stdlib/array/base/count-ifs' );
+
+var x = discreteUniform( 10, -5, 5, {
+ 'dtype': 'int32'
+});
+// returns
+
+var y = discreteUniform( 10, -5, 5, {
+ 'dtype': 'int32'
+});
+// returns
+
+var out = countIfs( x, naryFunction( isPositiveInteger, 1 ), y, naryFunction( isNegativeInteger, 1 ) ); // eslint-disable-line max-len
+// returns
+
+console.log( x );
+console.log( y );
+console.log( out );
+```
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+[@stdlib/array/complex128]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/complex128
+
+[@stdlib/array/complex64]: https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/array/complex64
+
+
+
+
diff --git a/lib/node_modules/@stdlib/array/base/count-ifs/benchmark/benchmark.length.js b/lib/node_modules/@stdlib/array/base/count-ifs/benchmark/benchmark.length.js
new file mode 100644
index 000000000000..aec6a8a6f106
--- /dev/null
+++ b/lib/node_modules/@stdlib/array/base/count-ifs/benchmark/benchmark.length.js
@@ -0,0 +1,123 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2025 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 pow = require( '@stdlib/math/base/special/pow' );
+var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive;
+var bernoulli = require( '@stdlib/random/array/bernoulli' );
+var pkg = require( './../package.json' ).name;
+var countIfs = require( './../lib' );
+
+
+// FUNCTIONS //
+
+/**
+* First predicate function.
+*
+* @private
+* @param {number} v - value
+* @returns {boolean} result
+*/
+function predicate0( v ) {
+ return v > 0.0;
+}
+
+/**
+* Second predicate function.
+*
+* @private
+* @param {number} v - value
+* @returns {boolean} result
+*/
+function predicate1( v ) {
+ return v < 0.0;
+}
+
+/**
+* Creates a benchmark function.
+*
+* @private
+* @param {PositiveInteger} len - array length
+* @returns {Function} benchmark function
+*/
+function createBenchmark( len ) {
+ var x0 = bernoulli( len, 0.5, {
+ 'dtype': 'generic'
+ });
+ var x1 = bernoulli( len, 0.5, {
+ 'dtype': 'generic'
+ });
+ return benchmark;
+
+ /**
+ * Benchmark function.
+ *
+ * @private
+ * @param {Benchmark} b - benchmark instance
+ */
+ function benchmark( b ) {
+ var out;
+ var i;
+
+ b.tic();
+ for ( i = 0; i < b.iterations; i++ ) {
+ out = countIfs( x0, predicate0, x1, predicate1 );
+ if ( typeof out !== 'number' ) {
+ b.fail( 'should return a number' );
+ }
+ }
+ b.toc();
+ if ( !isNonNegativeInteger( out ) ) {
+ b.fail( 'should return a nonnegative integer' );
+ }
+ 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+':dtype=generic,len='+len, f );
+ }
+}
+
+main();
diff --git a/lib/node_modules/@stdlib/array/base/count-ifs/docs/repl.txt b/lib/node_modules/@stdlib/array/base/count-ifs/docs/repl.txt
new file mode 100644
index 000000000000..81787be0b185
--- /dev/null
+++ b/lib/node_modules/@stdlib/array/base/count-ifs/docs/repl.txt
@@ -0,0 +1,39 @@
+
+{{alias}}( x0, predicate0[, x1, predicate1[, x2, predicate2, ...]] )
+ Counts the number of elements in the input arrays which pass the tests
+ implemented by the predicate functions.
+
+ The predicate function is provided three arguments:
+
+ - value: current array element.
+ - index: current array element index.
+ - arr: the input array.
+
+ Parameters
+ ----------
+ x0: ArrayLikeObject
+ First input array.
+
+ predicate0: Function
+ First predicate function.
+
+ x1: ArrayLikeObject (optional)
+ Second input array.
+
+ predicate1: Function (optional)
+ Second predicate function.
+
+ Returns
+ -------
+ out: integer
+ Result.
+
+ Examples
+ --------
+ > function f1( v ) { return ( v > 0 ); };
+ > function f2( v ) { return ( v < 0 ); };
+ > var out = {{alias}}( [ 0, 1, 1 ], f1, [ 1, -1, -1 ], f2 )
+ 2
+
+ See Also
+ --------
diff --git a/lib/node_modules/@stdlib/array/base/count-ifs/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/base/count-ifs/docs/types/index.d.ts
new file mode 100644
index 000000000000..57a20670719c
--- /dev/null
+++ b/lib/node_modules/@stdlib/array/base/count-ifs/docs/types/index.d.ts
@@ -0,0 +1,149 @@
+/*
+* @license Apache-2.0
+*
+* Copyright (c) 2025 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
+
+///
+
+import { Collection, AccessorArrayLike } from '@stdlib/types/array';
+
+/**
+* Returns a boolean indicating whether an element passes a test.
+*
+* @returns boolean indicating whether an element passes a test
+*/
+type Nullary = () => boolean;
+
+/**
+* Returns a boolean indicating whether an element passes a test.
+*
+* @param value - current array element
+* @returns boolean indicating whether an element passes a test
+*/
+type Unary = ( value: U ) => boolean;
+
+/**
+* Returns a boolean indicating whether an element passes a test.
+*
+* @param value - current array element
+* @param index - current array element index
+* @returns boolean indicating whether an element passes a test
+*/
+type Binary = ( value: U, index: number ) => boolean;
+
+/**
+* Returns a boolean indicating whether an element passes a test.
+*
+* @param value - current array element
+* @param index - current array element index
+* @param arr - input array
+* @returns boolean indicating whether an element passes a test
+*/
+type Ternary = ( value: U, index: number, arr: Collection | AccessorArrayLike ) => boolean;
+
+/**
+* Returns a boolean indicating whether an element passes a test.
+*
+* @param value - current array element
+* @param index - current array element index
+* @param arr - input array
+* @returns boolean indicating whether an element passes a test
+*/
+type Predicate = Nullary | Unary | Binary | Ternary;
+
+/**
+* Counts the number of elements in the input arrays which pass the tests implemented by the predicate functions.
+*
+* @param x - input array
+* @param predicate - predicate function
+* @returns result
+*
+* @example
+* function predicate( v ) {
+* return v > 0;
+* }
+*
+* var x = [ 0, 1, 0, 1, 1 ];
+*
+* var n = countIfs( x, predicate );
+* // returns 3
+*/
+declare function countIfs( x: Collection | AccessorArrayLike, predicate: Predicate ): number;
+
+/**
+* Counts the number of elements in the input arrays which pass the tests implemented by the predicate functions.
+*
+* @param x0 - first input array
+* @param predicate0 - first predicate function
+* @param x1 - second input array
+* @param predicate1 - second predicate function
+* @returns result
+*
+* @example
+* function predicate0( v ) {
+* return v > 0;
+* }
+*
+* function predicate1( v ) {
+* return v < 0;
+* }
+*
+* var x0 = [ 0, 1, 0, 1, 1 ];
+* var x1 = [ -1, 2, 4, -5, -8 ];
+*
+* var n = countIfs( x0, predicate0, x1, predicate1 );
+* // returns 2
+*/
+declare function countIfs( x0: Collection | AccessorArrayLike, predicate0: Predicate, x1: Collection | AccessorArrayLike, predicate1: Predicate ): number;
+
+/**
+* Counts the number of elements in the input arrays which pass the tests implemented by the predicate functions.
+*
+* @param x0 - first input array
+* @param predicate0 - first predicate function
+* @param x1 - second input array
+* @param predicate1 - second predicate function
+* @param x2 - third input array
+* @param predicate2 - third predicate function
+* @returns result
+*
+* @example
+* function predicate0( v ) {
+* return v > 0;
+* }
+*
+* function predicate1( v ) {
+* return v < 0;
+* }
+*
+* function predicate2( v ) {
+* return v % 2 === 0;
+* }
+*
+* var x0 = [ 0, 1, 0, 1, 1 ];
+* var x1 = [ -1, -2, 4, 5, -8 ];
+* var x2 = [ 0, 4, 3, 2, 12 ];
+*
+* var n = countIfs( x0, predicate0, x1, predicate1 );
+* // returns 2
+*/
+declare function countIfs( x0: Collection | AccessorArrayLike, predicate0: Predicate, x1: Collection | AccessorArrayLike, predicate1: Predicate, x2: Collection | AccessorArrayLike, predicate2: Predicate ): number;
+
+// EXPORTS //
+
+export = countIfs;
diff --git a/lib/node_modules/@stdlib/array/base/count-ifs/docs/types/test.ts b/lib/node_modules/@stdlib/array/base/count-ifs/docs/types/test.ts
new file mode 100644
index 000000000000..438a78f0dbfa
--- /dev/null
+++ b/lib/node_modules/@stdlib/array/base/count-ifs/docs/types/test.ts
@@ -0,0 +1,118 @@
+/*
+* @license Apache-2.0
+*
+* Copyright (c) 2025 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.
+*/
+
+import toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
+import countIfs = require( './index' );
+
+/**
+* Tests whether a value is positive.
+*
+* @param value - input value
+* @returns boolean indicating whether an element is positive
+*/
+function isPositive( value: number ): boolean {
+ return ( value > 0 );
+}
+
+/**
+* Tests whether a value is negative.
+*
+* @param value - input value
+* @returns boolean indicating whether an element is positive
+*/
+function isNegative( value: number ): boolean {
+ return ( value < 0 );
+}
+
+
+// TESTS //
+
+// The function returns a number...
+{
+ countIfs( [ 1, 2, 3 ], isPositive, [ -1, -2, -3 ], isNegative ); // $ExpectType number
+ countIfs( new Float64Array( [ 1, 2, 3 ] ), isPositive, new Float64Array( [ -1, -2, -3 ] ), isNegative ); // $ExpectType number
+ countIfs( new Float32Array( [ 1, 2, 3 ] ), isPositive, new Float32Array( [ -1, -2, -3 ] ), isNegative ); // $ExpectType number
+ countIfs( new Int32Array( [ 1, 2, 3 ] ), isPositive, new Int32Array( [ -1, -2, -3 ] ), isNegative ); // $ExpectType number
+ countIfs( new Int16Array( [ 1, 2, 3 ] ), isPositive, new Int16Array( [ -1, -2, -3 ] ), isNegative ); // $ExpectType number
+ countIfs( new Int8Array( [ 1, 2, 3 ] ), isPositive, new Int8Array( [ -1, -2, -3 ] ), isNegative ); // $ExpectType number
+ countIfs( new Uint32Array( [ 1, 2, 3 ] ), isPositive, new Uint32Array( [ -1, -2, -3 ] ), isNegative ); // $ExpectType number
+ countIfs( new Uint16Array( [ 1, 2, 3 ] ), isPositive, new Uint16Array( [ -1, -2, -3 ] ), isNegative ); // $ExpectType number
+ countIfs( new Uint8Array( [ 1, 2, 3 ] ), isPositive, new Uint8Array( [ -1, -2, -3 ] ), isNegative ); // $ExpectType number
+ countIfs( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive, new Uint8ClampedArray( [ -1, -2, -3 ] ), isNegative ); // $ExpectType number
+ countIfs( toAccessorArray( [ 1, 2, 3 ] ), isPositive, toAccessorArray( [ -1, -2, -3 ] ), isNegative ); // $ExpectType number
+}
+
+// The compiler throws an error if the function is provided a first argument which is not a collection...
+{
+ countIfs( 2, isPositive ); // $ExpectError
+ countIfs( false, isPositive ); // $ExpectError
+ countIfs( true, isPositive ); // $ExpectError
+ countIfs( {}, isPositive ); // $ExpectError
+
+ countIfs( 2, isPositive, {} ); // $ExpectError
+ countIfs( false, isPositive, {} ); // $ExpectError
+ countIfs( true, isPositive, {} ); // $ExpectError
+ countIfs( {}, isPositive, {} ); // $ExpectError
+}
+
+// The compiler throws an error if the function is provided a second argument which is not a function...
+{
+ countIfs( [ 1, 2, 3 ], 'abc' ); // $ExpectError
+ countIfs( [ 1, 2, 3 ], 2 ); // $ExpectError
+ countIfs( [ 1, 2, 3 ], false ); // $ExpectError
+ countIfs( [ 1, 2, 3 ], true ); // $ExpectError
+ countIfs( [ 1, 2, 3 ], null ); // $ExpectError
+ countIfs( [ 1, 2, 3 ], void 0 ); // $ExpectError
+ countIfs( [ 1, 2, 3 ], {} ); // $ExpectError
+ countIfs( [ 1, 2, 3 ], [] ); // $ExpectError
+
+ countIfs( [ 1, 2, 3 ], 'abc', {} ); // $ExpectError
+ countIfs( [ 1, 2, 3 ], 2, {} ); // $ExpectError
+ countIfs( [ 1, 2, 3 ], false, {} ); // $ExpectError
+ countIfs( [ 1, 2, 3 ], true, {} ); // $ExpectError
+ countIfs( [ 1, 2, 3 ], null, {} ); // $ExpectError
+ countIfs( [ 1, 2, 3 ], void 0, {} ); // $ExpectError
+ countIfs( [ 1, 2, 3 ], {}, {} ); // $ExpectError
+ countIfs( [ 1, 2, 3 ], [], {} ); // $ExpectError
+}
+
+// The compiler throws an error if the function is provided a third argument which is not a collection...
+{
+ countIfs( [ 1, 2, 3 ], isPositive, 2, isNegative ); // $ExpectError
+ countIfs( [ 1, 2, 3 ], isPositive, false, isNegative ); // $ExpectError
+ countIfs( [ 1, 2, 3 ], isPositive, true, isNegative ); // $ExpectError
+ countIfs( [ 1, 2, 3 ], isPositive, {}, isNegative ); // $ExpectError
+}
+
+// The compiler throws an error if the function is provided a fourth argument which is not a function...
+{
+ countIfs( [ 1, 2, 3 ], isPositive, [ -1, -2, -3 ], 'abc' ); // $ExpectError
+ countIfs( [ 1, 2, 3 ], isPositive, [ -1, -2, -3 ], 2 ); // $ExpectError
+ countIfs( [ 1, 2, 3 ], isPositive, [ -1, -2, -3 ], false ); // $ExpectError
+ countIfs( [ 1, 2, 3 ], isPositive, [ -1, -2, -3 ], true ); // $ExpectError
+ countIfs( [ 1, 2, 3 ], isPositive, [ -1, -2, -3 ], null ); // $ExpectError
+ countIfs( [ 1, 2, 3 ], isPositive, [ -1, -2, -3 ], void 0 ); // $ExpectError
+ countIfs( [ 1, 2, 3 ], isPositive, [ -1, -2, -3 ], {} ); // $ExpectError
+ countIfs( [ 1, 2, 3 ], isPositive, [ -1, -2, -3 ], [] ); // $ExpectError
+}
+
+// The compiler throws an error if the function is provided an unsupported number of arguments...
+{
+ countIfs(); // $ExpectError
+ countIfs( [ 1, 2, 3 ] ); // $ExpectError
+}
diff --git a/lib/node_modules/@stdlib/array/base/count-ifs/examples/index.js b/lib/node_modules/@stdlib/array/base/count-ifs/examples/index.js
new file mode 100644
index 000000000000..b5e315d16aed
--- /dev/null
+++ b/lib/node_modules/@stdlib/array/base/count-ifs/examples/index.js
@@ -0,0 +1,42 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2025 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';
+
+var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
+var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive;
+var isNegativeInteger = require( '@stdlib/assert/is-negative-integer' ).isPrimitive;
+var naryFunction = require( '@stdlib/utils/nary-function' );
+var countIfs = require( './../lib' );
+
+var x = discreteUniform( 10, -5, 5, {
+ 'dtype': 'int32'
+});
+// returns
+
+var y = discreteUniform( 10, -5, 5, {
+ 'dtype': 'int32'
+});
+// returns
+
+var out = countIfs( x, naryFunction( isPositiveInteger, 1 ), y, naryFunction( isNegativeInteger, 1 ) ); // eslint-disable-line max-len
+// returns
+
+console.log( x );
+console.log( y );
+console.log( out );
diff --git a/lib/node_modules/@stdlib/array/base/count-ifs/lib/index.js b/lib/node_modules/@stdlib/array/base/count-ifs/lib/index.js
new file mode 100644
index 000000000000..15c005345ec5
--- /dev/null
+++ b/lib/node_modules/@stdlib/array/base/count-ifs/lib/index.js
@@ -0,0 +1,51 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2025 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';
+
+/**
+* Count the number of elements in the input arrays which pass the tests implemented by the predicate functions.
+*
+* @module @stdlib/array/base/count-ifs
+*
+* @example
+* var countIfs = require( '@stdlib/array/base/count-ifs' );
+*
+* function predicate0( value ) {
+* return ( value > 0 );
+* }
+*
+* function predicate1( value ) {
+* return ( value < 3 );
+* }
+*
+* var x0 = [ 0, 1, 0, 1, 2 ];
+* var x1 = [ 2, 3, 1, 2, 5 ];
+*
+* var n = countIfs( x0, predicate0, x1, predicate1 );
+* // returns 1
+*/
+
+// MODULES //
+
+var main = require( './main.js' );
+
+
+// EXPORTS //
+
+module.exports = main;
diff --git a/lib/node_modules/@stdlib/array/base/count-ifs/lib/main.js b/lib/node_modules/@stdlib/array/base/count-ifs/lib/main.js
new file mode 100644
index 000000000000..a0c3e24e174d
--- /dev/null
+++ b/lib/node_modules/@stdlib/array/base/count-ifs/lib/main.js
@@ -0,0 +1,122 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2025 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 arraylike2object = require( '@stdlib/array/base/arraylike2object' );
+
+
+// FUNCTIONS //
+
+/**
+* Tests whether a particular value of an array satisfies a predicate.
+*
+* @private
+* @param {Object} x - input array object
+* @param {Collection} x.data - input array data
+* @param {Array} x.accessors - array element accessors
+* @param {Function} predicate - predicate function
+* @param {NonNegativeInteger} idx - element index
+* @returns {Boolean} indicating predicate test result
+*
+* @example
+* var arraylike2object = require( '@stdlib/array/base/arraylike2object' );
+*
+* function predicate( value ) {
+* return ( value > 0 );
+* }
+*
+* var x = [ 0, 1, 0, 1, 1 ];
+*
+* var n = internal( arraylike2object( x ), predicate, 1 );
+* // returns true
+*/
+function internal( x, predicate, idx ) {
+ var buf = x.data;
+ var get = x.accessors[ 0 ];
+ return predicate( get( buf, idx ), idx, x );
+}
+
+
+// MAIN //
+
+/**
+* Counts the number of elements in the input arrays which pass the tests implemented by the predicate functions.
+*
+* @param {Collection} x0 - first input array
+* @param {Function} predicate0 - first predicate function
+* @param {Collection} [x1] - second input array
+* @param {Function} [predicate1] - second predicate function
+* @param {Collection} [x2] - third input array
+* @param {Function} [predicate2] - third predicate function
+* @returns {NonNegativeInteger} result
+*
+* @example
+* function predicate0( value ) {
+* return ( value > 0 );
+* }
+*
+* function predicate1( value ) {
+* return ( value < 3 );
+* }
+*
+* var x0 = [ 0, 1, 0, 1, 2 ];
+* var x1 = [ 2, 3, 1, 2, 5 ];
+*
+* var n = countIfs( x0, predicate0, x1, predicate1 );
+* // returns 1
+*/
+function countIfs() {
+ var predicates;
+ var arrays;
+ var len;
+ var flg;
+ var n;
+ var i;
+ var j;
+
+ arrays = [];
+ predicates = [];
+ for ( i = 0; i < arguments.length; i+=2 ) {
+ arrays.push( arraylike2object( arguments[ i ] ) );
+ predicates.push( arguments[ i + 1 ] );
+ }
+
+ n = 0;
+ len = arrays[ 0 ].data.length;
+ for ( i = 0; i < len; i++ ) {
+ flg = true;
+ for ( j = 0; j < arrays.length; j++ ) {
+ if ( !internal( arrays[j], predicates[j], i ) ) {
+ flg = false;
+ break;
+ }
+ }
+ if ( flg ) {
+ n += 1;
+ }
+ }
+ return n;
+}
+
+
+// EXPORTS //
+
+module.exports = countIfs;
diff --git a/lib/node_modules/@stdlib/array/base/count-ifs/package.json b/lib/node_modules/@stdlib/array/base/count-ifs/package.json
new file mode 100644
index 000000000000..067798bd52f9
--- /dev/null
+++ b/lib/node_modules/@stdlib/array/base/count-ifs/package.json
@@ -0,0 +1,67 @@
+{
+ "name": "@stdlib/array/base/count-ifs",
+ "version": "0.0.0",
+ "description": "Count the number of elements in the input arrays which pass the tests implemented by the predicate functions.",
+ "license": "Apache-2.0",
+ "author": {
+ "name": "The Stdlib Authors",
+ "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
+ },
+ "contributors": [
+ {
+ "name": "The Stdlib Authors",
+ "url": "https://github.com/stdlib-js/stdlib/graphs/contributors"
+ }
+ ],
+ "main": "./lib",
+ "directories": {
+ "benchmark": "./benchmark",
+ "doc": "./docs",
+ "example": "./examples",
+ "lib": "./lib",
+ "test": "./test"
+ },
+ "types": "./docs/types",
+ "scripts": {},
+ "homepage": "https://github.com/stdlib-js/stdlib",
+ "repository": {
+ "type": "git",
+ "url": "git://github.com/stdlib-js/stdlib.git"
+ },
+ "bugs": {
+ "url": "https://github.com/stdlib-js/stdlib/issues"
+ },
+ "dependencies": {},
+ "devDependencies": {},
+ "engines": {
+ "node": ">=0.10.0",
+ "npm": ">2.7.0"
+ },
+ "os": [
+ "aix",
+ "darwin",
+ "freebsd",
+ "linux",
+ "macos",
+ "openbsd",
+ "sunos",
+ "win32",
+ "windows"
+ ],
+ "keywords": [
+ "stdlib",
+ "stdtypes",
+ "types",
+ "data",
+ "structure",
+ "array",
+ "count",
+ "sum",
+ "summation",
+ "countif",
+ "countifs",
+ "range",
+ "total",
+ "truthy"
+ ]
+}
diff --git a/lib/node_modules/@stdlib/array/base/count-ifs/test/test.js b/lib/node_modules/@stdlib/array/base/count-ifs/test/test.js
new file mode 100644
index 000000000000..2e5b96dd2a4b
--- /dev/null
+++ b/lib/node_modules/@stdlib/array/base/count-ifs/test/test.js
@@ -0,0 +1,166 @@
+/**
+* @license Apache-2.0
+*
+* Copyright (c) 2025 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 tape = require( 'tape' );
+var Complex128Array = require( '@stdlib/array/complex128' );
+var Int32Array = require( '@stdlib/array/int32' );
+var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
+var real = require( '@stdlib/complex/float64/real' );
+var imag = require( '@stdlib/complex/float64/imag' );
+var countIfs = require( './../lib' );
+
+
+// FUNCTIONS //
+
+function predicate0( value ) {
+ return value > 0;
+}
+
+function predicate1( value ) {
+ return value < 0;
+}
+
+
+// TESTS //
+
+tape( 'main export is a function', function test( t ) {
+ t.ok( true, __filename );
+ t.strictEqual( typeof countIfs, 'function', 'main export is a function' );
+ t.end();
+});
+
+tape( 'the function counts the number of elements in the input arrays which pass the tests implemented by the predicate functions (generic)', function test( t ) {
+ var actual;
+ var x0;
+ var x1;
+
+ x0 = [ 0, 1, 0, 1, 2 ];
+ x1 = [ 3, -4, -1, 2, -8 ];
+ actual = countIfs( x0, predicate0, x1, predicate1 );
+
+ t.strictEqual( actual, 2, 'returns expected value' );
+ t.end();
+});
+
+tape( 'the function counts the number of elements in the input arrays which pass the tests implemented by the predicate functions (accessors)', function test( t ) {
+ var actual;
+ var x0;
+ var x1;
+
+ x0 = toAccessorArray( [ 0, 1, 0, 1, 2 ] );
+ x1 = toAccessorArray( [ 3, -4, -1, 2, -8 ] );
+ actual = countIfs( x0, predicate0, x1, predicate1 );
+
+ t.strictEqual( actual, 2, 'returns expected value' );
+ t.end();
+});
+
+tape( 'the function counts the number of elements in the input arrays which pass the tests implemented by the predicate functions (real typed array)', function test( t ) {
+ var actual;
+ var x0;
+ var x1;
+
+ x0 = new Int32Array( [ 0, 1, 0, 1, 2 ] );
+ x1 = new Int32Array( [ 3, -4, -1, 2, -8 ] );
+ actual = countIfs( x0, predicate0, x1, predicate1 );
+
+ t.strictEqual( actual, 2, 'returns expected value' );
+ t.end();
+});
+
+tape( 'the function counts the number of elements in the input arrays which pass the tests implemented by the predicate functions (complex typed array)', function test( t ) {
+ var actual;
+ var x0;
+ var x1;
+
+ x0 = new Complex128Array( [ 3.0, 1.0, 1.0, 0.0, 3.0, 4.0, 0.0, 5.0 ] );
+ x1 = new Complex128Array( [ -2.0, -5.0, -3.0, 1.0, -5.0, -1.0, 0.0, 4.0 ] );
+ actual = countIfs( x0, predicate0, x1, predicate1 );
+
+ t.strictEqual( actual, 2, 'returns expected value' );
+ t.end();
+
+ function predicate0( value ) {
+ return (
+ real( value ) > 0 &&
+ imag( value ) > 0
+ );
+ }
+ function predicate1( value ) {
+ return (
+ real( value ) < 0 &&
+ imag( value ) < 0
+ );
+ }
+});
+
+tape( 'the function returns `0` if no elements at the same indices pass the tests implemented by the predicate functions (generic)', function test( t ) {
+ var actual;
+ var x0;
+ var x1;
+
+ x0 = [ -3, -2, -5, -1 ];
+ x1 = [ 2, 4, 5, 8 ];
+ actual = countIfs( x0, predicate0, x1, predicate1 );
+
+ t.strictEqual( actual, 0, 'returns expected value' );
+ t.end();
+});
+
+tape( 'the function returns `0` if no elements at the same indices pass the tests implemented by the predicate functions (accessors)', function test( t ) {
+ var actual;
+ var x0;
+ var x1;
+
+ x0 = toAccessorArray( [ -3, -2, -5, -1 ] );
+ x1 = toAccessorArray( [ 2, 4, 5, 8 ] );
+ actual = countIfs( x0, predicate0, x1, predicate1 );
+
+ t.strictEqual( actual, 0, 'returns expected value' );
+ t.end();
+});
+
+tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (generic)', function test( t ) {
+ var actual;
+ var x0;
+ var x1;
+
+ x0 = [ 1, 1, 1, 1 ];
+ x1 = [ -1, -1, -1, -1 ];
+ actual = countIfs( x0, predicate0, x1, predicate1 );
+
+ t.strictEqual( actual, x0.length, 'returns expected value' );
+ t.end();
+});
+
+tape( 'the function returns the number of elements in an array if all elements pass a test implemented by a predicate function (accessors)', function test( t ) {
+ var actual;
+ var x0;
+ var x1;
+
+ x0 = toAccessorArray( [ 1, 1, 1, 1 ] );
+ x1 = toAccessorArray( [ -1, -1, -1, -1 ] );
+ actual = countIfs( x0, predicate0, x1, predicate1 );
+
+ t.strictEqual( actual, x0.length, 'returns expected value' );
+ t.end();
+});
From 86b2110141bc82397a2730ef8f60c45b01bdb338 Mon Sep 17 00:00:00 2001
From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com>
Date: Mon, 17 Mar 2025 06:52:37 +0000
Subject: [PATCH 2/7] docs: apply suggestions from code review
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown
status: passed
- task: lint_package_json
status: na
- task: lint_repl_help
status: na
- task: lint_javascript_src
status: na
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- task: lint_javascript_tests
status: na
- task: lint_javascript_benchmarks
status: na
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: na
- task: lint_c_examples
status: na
- task: lint_c_benchmarks
status: na
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: na
- task: lint_typescript_tests
status: na
- task: lint_license_headers
status: passed
---
---
lib/node_modules/@stdlib/array/base/count-ifs/README.md | 6 ++++--
1 file changed, 4 insertions(+), 2 deletions(-)
diff --git a/lib/node_modules/@stdlib/array/base/count-ifs/README.md b/lib/node_modules/@stdlib/array/base/count-ifs/README.md
index ab8b02e61644..92c90b9f3d57 100644
--- a/lib/node_modules/@stdlib/array/base/count-ifs/README.md
+++ b/lib/node_modules/@stdlib/array/base/count-ifs/README.md
@@ -60,7 +60,7 @@ var out = countIfs( x0, predicate0, x1, predicate1 );
// returns 1
```
-The `predicate` function is provided three arguments:
+Each predicate function is provided three arguments:
- **value**: current array element.
- **index**: current array element index.
@@ -91,6 +91,8 @@ The `predicate` function is provided three arguments:
+
+
```javascript
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
var isPositiveInteger = require( '@stdlib/assert/is-positive-integer' ).isPrimitive;
@@ -108,7 +110,7 @@ var y = discreteUniform( 10, -5, 5, {
});
// returns
-var out = countIfs( x, naryFunction( isPositiveInteger, 1 ), y, naryFunction( isNegativeInteger, 1 ) ); // eslint-disable-line max-len
+var out = countIfs( x, naryFunction( isPositiveInteger, 1 ), y, naryFunction( isNegativeInteger, 1 ) );
// returns
console.log( x );
From 1dfa5c8292515373f044a80260fa8504259778ad Mon Sep 17 00:00:00 2001
From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com>
Date: Mon, 17 Mar 2025 09:38:54 +0000
Subject: [PATCH 3/7] refactor: apply suggestions from code review
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown
status: na
- task: lint_package_json
status: na
- task: lint_repl_help
status: passed
- task: lint_javascript_src
status: passed
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- task: lint_javascript_tests
status: na
- task: lint_javascript_benchmarks
status: passed
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: na
- task: lint_c_examples
status: na
- task: lint_c_benchmarks
status: na
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: na
- task: lint_license_headers
status: passed
---
---
.../count-ifs/benchmark/benchmark.length.js | 10 +-
.../array/base/count-ifs/docs/repl.txt | 2 +-
.../base/count-ifs/docs/types/index.d.ts | 118 ++++++++++++++++--
.../@stdlib/array/base/count-ifs/lib/main.js | 114 ++++++++++++-----
4 files changed, 195 insertions(+), 49 deletions(-)
diff --git a/lib/node_modules/@stdlib/array/base/count-ifs/benchmark/benchmark.length.js b/lib/node_modules/@stdlib/array/base/count-ifs/benchmark/benchmark.length.js
index aec6a8a6f106..dd52b867a0cb 100644
--- a/lib/node_modules/@stdlib/array/base/count-ifs/benchmark/benchmark.length.js
+++ b/lib/node_modules/@stdlib/array/base/count-ifs/benchmark/benchmark.length.js
@@ -23,7 +23,7 @@
var bench = require( '@stdlib/bench' );
var pow = require( '@stdlib/math/base/special/pow' );
var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive;
-var bernoulli = require( '@stdlib/random/array/bernoulli' );
+var uniform = require( '@stdlib/random/array/uniform' );
var pkg = require( './../package.json' ).name;
var countIfs = require( './../lib' );
@@ -60,11 +60,11 @@ function predicate1( v ) {
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
- var x0 = bernoulli( len, 0.5, {
- 'dtype': 'generic'
+ var x0 = uniform( len, -1.0, 1.0, {
+ 'dype': 'generic'
});
- var x1 = bernoulli( len, 0.5, {
- 'dtype': 'generic'
+ var x1 = uniform( len, -1.0, 1.0, {
+ 'dype': 'generic'
});
return benchmark;
diff --git a/lib/node_modules/@stdlib/array/base/count-ifs/docs/repl.txt b/lib/node_modules/@stdlib/array/base/count-ifs/docs/repl.txt
index 81787be0b185..b4ccee97f2d0 100644
--- a/lib/node_modules/@stdlib/array/base/count-ifs/docs/repl.txt
+++ b/lib/node_modules/@stdlib/array/base/count-ifs/docs/repl.txt
@@ -3,7 +3,7 @@
Counts the number of elements in the input arrays which pass the tests
implemented by the predicate functions.
- The predicate function is provided three arguments:
+ Each predicate function is provided three arguments:
- value: current array element.
- index: current array element index.
diff --git a/lib/node_modules/@stdlib/array/base/count-ifs/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/base/count-ifs/docs/types/index.d.ts
index 57a20670719c..d098d0bb55b0 100644
--- a/lib/node_modules/@stdlib/array/base/count-ifs/docs/types/index.d.ts
+++ b/lib/node_modules/@stdlib/array/base/count-ifs/docs/types/index.d.ts
@@ -22,6 +22,11 @@
import { Collection, AccessorArrayLike } from '@stdlib/types/array';
+/**
+* Input array
+*/
+type InputArray = Collection | AccessorArrayLike;
+
/**
* Returns a boolean indicating whether an element passes a test.
*
@@ -35,7 +40,7 @@ type Nullary = () => boolean;
* @param value - current array element
* @returns boolean indicating whether an element passes a test
*/
-type Unary = ( value: U ) => boolean;
+type Unary = ( value: T ) => boolean;
/**
* Returns a boolean indicating whether an element passes a test.
@@ -44,7 +49,7 @@ type Unary = ( value: U ) => boolean;
* @param index - current array element index
* @returns boolean indicating whether an element passes a test
*/
-type Binary = ( value: U, index: number ) => boolean;
+type Binary = ( value: T, index: number ) => boolean;
/**
* Returns a boolean indicating whether an element passes a test.
@@ -54,7 +59,7 @@ type Binary = ( value: U, index: number ) => boolean;
* @param arr - input array
* @returns boolean indicating whether an element passes a test
*/
-type Ternary = ( value: U, index: number, arr: Collection | AccessorArrayLike ) => boolean;
+type Ternary = ( value: T, index: number, arr: U ) => boolean;
/**
* Returns a boolean indicating whether an element passes a test.
@@ -64,26 +69,26 @@ type Ternary = ( value: U, index: number, arr: Collection | AccessorArrayL
* @param arr - input array
* @returns boolean indicating whether an element passes a test
*/
-type Predicate = Nullary | Unary | Binary | Ternary;
+type Predicate = Nullary | Unary | Binary | Ternary;
/**
* Counts the number of elements in the input arrays which pass the tests implemented by the predicate functions.
*
-* @param x - input array
-* @param predicate - predicate function
+* @param x0 - input array
+* @param predicate0 - predicate function
* @returns result
*
* @example
-* function predicate( v ) {
+* function predicate0( v ) {
* return v > 0;
* }
*
-* var x = [ 0, 1, 0, 1, 1 ];
+* var x0 = [ 0, 1, 0, 1, 1 ];
*
-* var n = countIfs( x, predicate );
+* var n = countIfs( x0, predicate0 );
* // returns 3
*/
-declare function countIfs( x: Collection | AccessorArrayLike, predicate: Predicate ): number;
+declare function countIfs>( x0: U, predicate0: Predicate ): number;
/**
* Counts the number of elements in the input arrays which pass the tests implemented by the predicate functions.
@@ -109,7 +114,7 @@ declare function countIfs( x: Collection | AccessorArrayLike,
* var n = countIfs( x0, predicate0, x1, predicate1 );
* // returns 2
*/
-declare function countIfs( x0: Collection | AccessorArrayLike, predicate0: Predicate, x1: Collection | AccessorArrayLike, predicate1: Predicate ): number;
+declare function countIfs>( x0: U, predicate0: Predicate, x1: U, predicate1: Predicate ): number;
/**
* Counts the number of elements in the input arrays which pass the tests implemented by the predicate functions.
@@ -142,7 +147,96 @@ declare function countIfs( x0: Collection | AccessorArrayLike
* var n = countIfs( x0, predicate0, x1, predicate1 );
* // returns 2
*/
-declare function countIfs( x0: Collection | AccessorArrayLike, predicate0: Predicate, x1: Collection | AccessorArrayLike, predicate1: Predicate, x2: Collection | AccessorArrayLike, predicate2: Predicate ): number;
+declare function countIfs>( x0: U, predicate0: Predicate, x1: U, predicate1: Predicate, x2: U, predicate2: Predicate ): number;
+
+/**
+* Counts the number of elements in the input arrays which pass the tests implemented by the predicate functions.
+*
+* @param x0 - first input array
+* @param predicate0 - first predicate function
+* @param x1 - second input array
+* @param predicate1 - second predicate function
+* @param x2 - third input array
+* @param predicate2 - third predicate function
+* @param x3 - fourth input array
+* @param predicate3 - fourth predicate function
+* @returns result
+*
+* @example
+* function predicate0( v ) {
+* return v > 0;
+* }
+*
+* function predicate1( v ) {
+* return v < 0;
+* }
+*
+* function predicate2( v ) {
+* return v % 2 === 0;
+* }
+*
+* function predicate3( v ) {
+* return v % 2 !== 0;
+* }
+*
+* var x0 = [ 0, 1, 0, 1, 1 ];
+* var x1 = [ -1, -2, 4, 5, -8 ];
+* var x2 = [ 0, 4, 3, 2, 12 ];
+* var x3 = [ 2, 9, 3, 6, 5 ];
+*
+* var n = countIfs( x0, predicate0, x1, predicate1, x3, predicate3 );
+* // returns 2
+*/
+declare function countIfs>( x0: U, predicate0: Predicate, x1: U, predicate1: Predicate, x2: U, predicate2: Predicate, x3: U, predicate3: Predicate ): number;
+
+/**
+* Counts the number of elements in the input arrays which pass the tests implemented by the predicate functions.
+*
+* @param x0 - first input array
+* @param predicate0 - first predicate function
+* @param x1 - second input array
+* @param predicate1 - second predicate function
+* @param x2 - third input array
+* @param predicate2 - third predicate function
+* @param x3 - fourth input array
+* @param predicate3 - fourth predicate function
+* @param x4 - fifth input array
+* @param predicate4 - fifth predicate function
+* @param args - additional input values
+* @returns result
+*
+* @example
+* function predicate0( v ) {
+* return v > 0;
+* }
+*
+* function predicate1( v ) {
+* return v < 0;
+* }
+*
+* function predicate2( v ) {
+* return v % 2 === 0;
+* }
+*
+* function predicate3( v ) {
+* return v % 2 !== 0;
+* }
+*
+* function predicate4( v ) {
+* return v === true;
+* }
+*
+* var x0 = [ 0, 1, 0, 1, 1 ];
+* var x1 = [ -1, -2, 4, 5, -8 ];
+* var x2 = [ 0, 4, 3, 2, 12 ];
+* var x3 = [ 2, 9, 3, 6, 5 ];
+* var x4 = [ false, true, false, true, true ]
+*
+* var n = countIfs( x0, predicate0, x1, predicate1, x3, predicate3, x4, predicate4 );
+* // returns 2
+*/
+declare function countIfs>( x0: U, predicate0: Predicate, x1: U, predicate1: Predicate, x2: U, predicate2: Predicate, x3: U, predicate3: Predicate, x4: U, predicate4: Predicate, ...args: Array> ): number;
+
// EXPORTS //
diff --git a/lib/node_modules/@stdlib/array/base/count-ifs/lib/main.js b/lib/node_modules/@stdlib/array/base/count-ifs/lib/main.js
index a0c3e24e174d..911d809c111e 100644
--- a/lib/node_modules/@stdlib/array/base/count-ifs/lib/main.js
+++ b/lib/node_modules/@stdlib/array/base/count-ifs/lib/main.js
@@ -21,37 +21,94 @@
// MODULES //
var arraylike2object = require( '@stdlib/array/base/arraylike2object' );
+var zeroTo = require( '@stdlib/array/base/zero-to' );
// FUNCTIONS //
/**
-* Tests whether a particular value of an array satisfies a predicate.
+* Returns an array of indices of the input array which pass the test implemented by the predicate function.
*
* @private
-* @param {Object} x - input array object
-* @param {Collection} x.data - input array data
-* @param {Array} x.accessors - array element accessors
+* @param {Collection} x - input array
+* @param {Array} idx - input array indices
* @param {Function} predicate - predicate function
-* @param {NonNegativeInteger} idx - element index
-* @returns {Boolean} indicating predicate test result
+* @returns {Array} filtered index array
*
* @example
* var arraylike2object = require( '@stdlib/array/base/arraylike2object' );
+* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' );
+* var zeroTo = require( '@stdlib/array/base/zero-to' );
*
-* function predicate( value ) {
-* return ( value > 0 );
+* function predicate( v ) {
+* return ( v > 0 );
* }
*
-* var x = [ 0, 1, 0, 1, 1 ];
+* var x = arraylike2object( toAccessorArray( [ -1, 2, 3, -4, 5 ] ) );
+* var idx = zeroTo( 5 );
*
-* var n = internal( arraylike2object( x ), predicate, 1 );
-* // returns true
+* var out = accessors( x, idx, predicate );
+* // returns [ 1, 2, 4 ]
*/
-function internal( x, predicate, idx ) {
- var buf = x.data;
- var get = x.accessors[ 0 ];
- return predicate( get( buf, idx ), idx, x );
+function accessors( x, idx, predicate ) {
+ var buf;
+ var get;
+ var i;
+ var j;
+ var k;
+
+ buf = x.data;
+ get = x.accessors[ 0 ];
+
+ k = 0;
+ for ( i = 0; i < idx.length; i++ ) {
+ j = idx[ i ];
+ if ( predicate( get( buf, j ), j, buf ) ) {
+ idx[ k ] = j;
+ k += 1;
+ }
+ }
+ idx.length = k;
+ return idx;
+}
+
+/**
+* Returns an array of indices of the input array which pass the test implemented by the predicate function.
+*
+* @private
+* @param {Collection} x - input array
+* @param {Array} idx - input array indices
+* @param {Function} predicate - predicate function
+* @returns {Array} filtered index array
+*
+* @example
+* var zeroTo = require( '@stdlib/array/base/zero-to' );
+*
+* function predicate( v ) {
+* return ( v > 0 );
+* }
+*
+* var x = [ -1, 2, 3, -4, 5 ];
+* var idx = zeroTo( 5 );
+*
+* var out = indexed( x, idx, predicate );
+* // returns [ 1, 2, 4 ]
+*/
+function indexed( x, idx, predicate ) {
+ var i;
+ var j;
+ var k;
+
+ k = 0;
+ for ( i = 0; i < idx.length; i++ ) {
+ j = idx[ i ];
+ if ( predicate( x[ j ], j, x ) ) {
+ idx[ k ] = j;
+ k += 1;
+ }
+ }
+ idx.length = k;
+ return idx;
}
@@ -87,10 +144,9 @@ function countIfs() {
var predicates;
var arrays;
var len;
- var flg;
- var n;
+ var idx;
+ var x;
var i;
- var j;
arrays = [];
predicates = [];
@@ -99,21 +155,17 @@ function countIfs() {
predicates.push( arguments[ i + 1 ] );
}
- n = 0;
- len = arrays[ 0 ].data.length;
- for ( i = 0; i < len; i++ ) {
- flg = true;
- for ( j = 0; j < arrays.length; j++ ) {
- if ( !internal( arrays[j], predicates[j], i ) ) {
- flg = false;
- break;
- }
- }
- if ( flg ) {
- n += 1;
+ len = arguments[ 0 ].length;
+ idx = zeroTo( len );
+ for ( i = 0; i < arrays.length; i++ ) {
+ x = arrays[ i ];
+ if ( x.accessorProtocol ) {
+ idx = accessors( x, idx, predicates[ i ] );
+ } else {
+ idx = indexed( x.data, idx, predicates[ i ] );
}
}
- return n;
+ return idx.length;
}
From df5a2825fef224c7cd147c17d2e3bbaf1ef0c953 Mon Sep 17 00:00:00 2001
From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com>
Date: Mon, 17 Mar 2025 09:45:39 +0000
Subject: [PATCH 4/7] fix: incorrect signature
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown
status: na
- task: lint_package_json
status: na
- task: lint_repl_help
status: na
- task: lint_javascript_src
status: na
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- task: lint_javascript_tests
status: na
- task: lint_javascript_benchmarks
status: na
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: na
- task: lint_c_examples
status: na
- task: lint_c_benchmarks
status: na
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: na
- task: lint_license_headers
status: passed
---
---
.../@stdlib/array/base/count-ifs/docs/types/index.d.ts | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/lib/node_modules/@stdlib/array/base/count-ifs/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/base/count-ifs/docs/types/index.d.ts
index d098d0bb55b0..bb1ad23a1a85 100644
--- a/lib/node_modules/@stdlib/array/base/count-ifs/docs/types/index.d.ts
+++ b/lib/node_modules/@stdlib/array/base/count-ifs/docs/types/index.d.ts
@@ -235,7 +235,7 @@ declare function countIfs>( x0: U, predicat
* var n = countIfs( x0, predicate0, x1, predicate1, x3, predicate3, x4, predicate4 );
* // returns 2
*/
-declare function countIfs>( x0: U, predicate0: Predicate, x1: U, predicate1: Predicate, x2: U, predicate2: Predicate, x3: U, predicate3: Predicate, x4: U, predicate4: Predicate, ...args: Array> ): number;
+declare function countIfs>( x0: U, predicate0: Predicate, x1: U, predicate1: Predicate, x2: U, predicate2: Predicate, x3: U, predicate3: Predicate, x4: U, predicate4: Predicate, ...args: Array> ): number;
// EXPORTS //
From 59ce154b223f4dbc04ee6588fcd7b07804564ed4 Mon Sep 17 00:00:00 2001
From: Muhammad Haris <101793258+headlessNode@users.noreply.github.com>
Date: Mon, 17 Mar 2025 09:50:49 +0000
Subject: [PATCH 5/7] fix: error due to default unknown type
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown
status: na
- task: lint_package_json
status: na
- task: lint_repl_help
status: na
- task: lint_javascript_src
status: na
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- task: lint_javascript_tests
status: na
- task: lint_javascript_benchmarks
status: na
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: na
- task: lint_c_examples
status: na
- task: lint_c_benchmarks
status: na
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: na
- task: lint_license_headers
status: passed
---
---
.../@stdlib/array/base/count-ifs/docs/types/index.d.ts | 10 +++++-----
1 file changed, 5 insertions(+), 5 deletions(-)
diff --git a/lib/node_modules/@stdlib/array/base/count-ifs/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/base/count-ifs/docs/types/index.d.ts
index bb1ad23a1a85..c7c115540b95 100644
--- a/lib/node_modules/@stdlib/array/base/count-ifs/docs/types/index.d.ts
+++ b/lib/node_modules/@stdlib/array/base/count-ifs/docs/types/index.d.ts
@@ -88,7 +88,7 @@ type Predicate = Nullary | Unary | Binary | Ternary;
* var n = countIfs( x0, predicate0 );
* // returns 3
*/
-declare function countIfs>( x0: U, predicate0: Predicate ): number;
+declare function countIfs>( x0: U, predicate0: Predicate ): number;
/**
* Counts the number of elements in the input arrays which pass the tests implemented by the predicate functions.
@@ -114,7 +114,7 @@ declare function countIfs>( x0: U, predicat
* var n = countIfs( x0, predicate0, x1, predicate1 );
* // returns 2
*/
-declare function countIfs>( x0: U, predicate0: Predicate, x1: U, predicate1: Predicate ): number;
+declare function countIfs>( x0: U, predicate0: Predicate, x1: U, predicate1: Predicate ): number;
/**
* Counts the number of elements in the input arrays which pass the tests implemented by the predicate functions.
@@ -147,7 +147,7 @@ declare function countIfs>( x0: U, predicat
* var n = countIfs( x0, predicate0, x1, predicate1 );
* // returns 2
*/
-declare function countIfs>( x0: U, predicate0: Predicate, x1: U, predicate1: Predicate, x2: U, predicate2: Predicate ): number;
+declare function countIfs>( x0: U, predicate0: Predicate, x1: U, predicate1: Predicate, x2: U, predicate2: Predicate ): number;
/**
* Counts the number of elements in the input arrays which pass the tests implemented by the predicate functions.
@@ -187,7 +187,7 @@ declare function countIfs>( x0: U, predicat
* var n = countIfs( x0, predicate0, x1, predicate1, x3, predicate3 );
* // returns 2
*/
-declare function countIfs>( x0: U, predicate0: Predicate, x1: U, predicate1: Predicate, x2: U, predicate2: Predicate, x3: U, predicate3: Predicate ): number;
+declare function countIfs>( x0: U, predicate0: Predicate, x1: U, predicate1: Predicate, x2: U, predicate2: Predicate, x3: U, predicate3: Predicate ): number;
/**
* Counts the number of elements in the input arrays which pass the tests implemented by the predicate functions.
@@ -235,7 +235,7 @@ declare function countIfs>( x0: U, predicat
* var n = countIfs( x0, predicate0, x1, predicate1, x3, predicate3, x4, predicate4 );
* // returns 2
*/
-declare function countIfs>( x0: U, predicate0: Predicate, x1: U, predicate1: Predicate, x2: U, predicate2: Predicate, x3: U, predicate3: Predicate, x4: U, predicate4: Predicate, ...args: Array> ): number;
+declare function countIfs>( x0: U, predicate0: Predicate, x1: U, predicate1: Predicate, x2: U, predicate2: Predicate, x3: U, predicate3: Predicate, x4: U, predicate4: Predicate, ...args: Array> ): number;
// EXPORTS //
From 903bcf0cb5347319e0e6d371517f68fcf7788e39 Mon Sep 17 00:00:00 2001
From: Athan
Date: Thu, 10 Apr 2025 02:32:59 -0700
Subject: [PATCH 6/7] chore: clean-up
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown
status: passed
- task: lint_package_json
status: passed
- task: lint_repl_help
status: passed
- task: lint_javascript_src
status: passed
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: passed
- task: lint_javascript_tests
status: passed
- task: lint_javascript_benchmarks
status: passed
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: na
- task: lint_c_examples
status: na
- task: lint_c_benchmarks
status: na
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: passed
- task: lint_license_headers
status: passed
---
---
.../@stdlib/array/base/count-ifs/README.md | 28 +--
.../count-ifs/benchmark/benchmark.length.js | 2 +-
.../array/base/count-ifs/docs/repl.txt | 19 +-
.../base/count-ifs/docs/types/index.d.ts | 26 +--
.../array/base/count-ifs/docs/types/test.ts | 170 +++++++++++++-----
.../array/base/count-ifs/examples/index.js | 8 +-
.../@stdlib/array/base/count-ifs/lib/index.js | 2 +-
.../@stdlib/array/base/count-ifs/lib/main.js | 19 +-
.../@stdlib/array/base/count-ifs/package.json | 6 +-
.../@stdlib/array/base/count-ifs/test/test.js | 72 +++++++-
10 files changed, 247 insertions(+), 105 deletions(-)
diff --git a/lib/node_modules/@stdlib/array/base/count-ifs/README.md b/lib/node_modules/@stdlib/array/base/count-ifs/README.md
index 92c90b9f3d57..28c07bdbf430 100644
--- a/lib/node_modules/@stdlib/array/base/count-ifs/README.md
+++ b/lib/node_modules/@stdlib/array/base/count-ifs/README.md
@@ -20,7 +20,7 @@ limitations under the License.
# countIfs
-> Count the number of elements in the input arrays which pass the tests implemented by the predicate functions.
+> Perform element-wise evaluation of one or more input arrays according to provided predicate functions and count the number of elements for which all predicates respectively return `true`.
@@ -40,9 +40,9 @@ limitations under the License.
var countIfs = require( '@stdlib/array/base/count-ifs' );
```
-#### countIfs( x0, predicate0\[, x1, predicate1\[, x2, predicate2, ...]] )
+#### countIfs( x0, predicate0\[, x1, predicate1\[, x2, predicate2\[, ...args]] )
-Counts the number of elements in the input arrays which pass the tests implemented by the predicate functions.
+Performs element-wise evaluation of one or more input arrays according to provided predicate functions and counts the number of elements for which all predicates respectively return `true`.
```javascript
function predicate0( value ) {
@@ -60,11 +60,21 @@ var out = countIfs( x0, predicate0, x1, predicate1 );
// returns 1
```
+The function has the following parameters:
+
+- **x0**: first input array.
+- **predicate0**: first predicate function.
+- **x1**: second input array (_optional_).
+- **predicate1**: second predicate function (_optional_).
+- **x2**: third input array (_optional_).
+- **predicate2**: third predicate function (_optional_).
+- **args**: additional input arrays and corresponding predicate functions (_optional_).
+
Each predicate function is provided three arguments:
- **value**: current array element.
- **index**: current array element index.
-- **arr**: input array.
+- **arr**: the corresponding input array.
@@ -91,7 +101,7 @@ Each predicate function is provided three arguments:
-
+
```javascript
var discreteUniform = require( '@stdlib/random/array/discrete-uniform' );
@@ -103,18 +113,14 @@ var countIfs = require( '@stdlib/array/base/count-ifs' );
var x = discreteUniform( 10, -5, 5, {
'dtype': 'int32'
});
-// returns
+console.log( x );
var y = discreteUniform( 10, -5, 5, {
'dtype': 'int32'
});
-// returns
+console.log( y );
var out = countIfs( x, naryFunction( isPositiveInteger, 1 ), y, naryFunction( isNegativeInteger, 1 ) );
-// returns
-
-console.log( x );
-console.log( y );
console.log( out );
```
diff --git a/lib/node_modules/@stdlib/array/base/count-ifs/benchmark/benchmark.length.js b/lib/node_modules/@stdlib/array/base/count-ifs/benchmark/benchmark.length.js
index dd52b867a0cb..13d9b2027fe3 100644
--- a/lib/node_modules/@stdlib/array/base/count-ifs/benchmark/benchmark.length.js
+++ b/lib/node_modules/@stdlib/array/base/count-ifs/benchmark/benchmark.length.js
@@ -116,7 +116,7 @@ function main() {
len = pow( 10, i );
f = createBenchmark( len );
- bench( pkg+':dtype=generic,len='+len, f );
+ bench( pkg+':dtype=generic,predicates=2,len='+len, f );
}
}
diff --git a/lib/node_modules/@stdlib/array/base/count-ifs/docs/repl.txt b/lib/node_modules/@stdlib/array/base/count-ifs/docs/repl.txt
index b4ccee97f2d0..8a579394f41f 100644
--- a/lib/node_modules/@stdlib/array/base/count-ifs/docs/repl.txt
+++ b/lib/node_modules/@stdlib/array/base/count-ifs/docs/repl.txt
@@ -1,13 +1,14 @@
-{{alias}}( x0, predicate0[, x1, predicate1[, x2, predicate2, ...]] )
- Counts the number of elements in the input arrays which pass the tests
- implemented by the predicate functions.
+{{alias}}( x0, predicate0[, x1, predicate1[, x2, predicate2[, ...args]] )
+ Performs element-wise evaluation of one or more input arrays according to
+ provided predicate functions and counts the number of elements for which all
+ predicates respectively return `true`.
Each predicate function is provided three arguments:
- value: current array element.
- index: current array element index.
- - arr: the input array.
+ - arr: the corresponding input array.
Parameters
----------
@@ -23,6 +24,15 @@
predicate1: Function (optional)
Second predicate function.
+ x2: ArrayLikeObject (optional)
+ Third input array.
+
+ predicate2: Function (optional)
+ Third predicate function.
+
+ ...args: ArrayLikeObject|Function (optional)
+ Additional input arrays and corresponding predicate functions.
+
Returns
-------
out: integer
@@ -37,3 +47,4 @@
See Also
--------
+
diff --git a/lib/node_modules/@stdlib/array/base/count-ifs/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/base/count-ifs/docs/types/index.d.ts
index c7c115540b95..75e471419bba 100644
--- a/lib/node_modules/@stdlib/array/base/count-ifs/docs/types/index.d.ts
+++ b/lib/node_modules/@stdlib/array/base/count-ifs/docs/types/index.d.ts
@@ -23,7 +23,7 @@
import { Collection, AccessorArrayLike } from '@stdlib/types/array';
/**
-* Input array
+* Input array.
*/
type InputArray = Collection | AccessorArrayLike;
@@ -69,10 +69,10 @@ type Ternary = ( value: T, index: number, arr: U ) => boolean;
* @param arr - input array
* @returns boolean indicating whether an element passes a test
*/
-type Predicate = Nullary | Unary | Binary | Ternary;
+type Predicate = Nullary | Unary | Binary | Ternary;
/**
-* Counts the number of elements in the input arrays which pass the tests implemented by the predicate functions.
+* Performs element-wise evaluation of one or more input arrays according to provided predicate functions and counts the number of elements for which all predicates respectively return `true`.
*
* @param x0 - input array
* @param predicate0 - predicate function
@@ -88,10 +88,10 @@ type Predicate = Nullary | Unary | Binary | Ternary;
* var n = countIfs( x0, predicate0 );
* // returns 3
*/
-declare function countIfs>( x0: U, predicate0: Predicate ): number;
+declare function countIfs = InputArray>( x0: U, predicate0: Predicate ): number;
/**
-* Counts the number of elements in the input arrays which pass the tests implemented by the predicate functions.
+* Performs element-wise evaluation of one or more input arrays according to provided predicate functions and counts the number of elements for which all predicates respectively return `true`.
*
* @param x0 - first input array
* @param predicate0 - first predicate function
@@ -114,10 +114,10 @@ declare function countIfs>( x0: U, predicate0: Predic
* var n = countIfs( x0, predicate0, x1, predicate1 );
* // returns 2
*/
-declare function countIfs>( x0: U, predicate0: Predicate, x1: U, predicate1: Predicate ): number;
+declare function countIfs = InputArray>( x0: U, predicate0: Predicate, x1: U, predicate1: Predicate ): number;
/**
-* Counts the number of elements in the input arrays which pass the tests implemented by the predicate functions.
+* Performs element-wise evaluation of one or more input arrays according to provided predicate functions and counts the number of elements for which all predicates respectively return `true`.
*
* @param x0 - first input array
* @param predicate0 - first predicate function
@@ -147,10 +147,10 @@ declare function countIfs>( x0: U, predicate0: Predic
* var n = countIfs( x0, predicate0, x1, predicate1 );
* // returns 2
*/
-declare function countIfs>( x0: U, predicate0: Predicate, x1: U, predicate1: Predicate, x2: U, predicate2: Predicate ): number;
+declare function countIfs = InputArray>( x0: U, predicate0: Predicate, x1: U, predicate1: Predicate, x2: U, predicate2: Predicate ): number;
/**
-* Counts the number of elements in the input arrays which pass the tests implemented by the predicate functions.
+* Performs element-wise evaluation of one or more input arrays according to provided predicate functions and counts the number of elements for which all predicates respectively return `true`.
*
* @param x0 - first input array
* @param predicate0 - first predicate function
@@ -187,10 +187,10 @@ declare function countIfs>( x0: U, predicate0: Predic
* var n = countIfs( x0, predicate0, x1, predicate1, x3, predicate3 );
* // returns 2
*/
-declare function countIfs>( x0: U, predicate0: Predicate, x1: U, predicate1: Predicate, x2: U, predicate2: Predicate, x3: U, predicate3: Predicate ): number;
+declare function countIfs = InputArray>( x0: U, predicate0: Predicate, x1: U, predicate1: Predicate, x2: U, predicate2: Predicate, x3: U, predicate3: Predicate ): number;
/**
-* Counts the number of elements in the input arrays which pass the tests implemented by the predicate functions.
+* Performs element-wise evaluation of one or more input arrays according to provided predicate functions and counts the number of elements for which all predicates respectively return `true`.
*
* @param x0 - first input array
* @param predicate0 - first predicate function
@@ -202,7 +202,7 @@ declare function countIfs>( x0: U, predicate0: Predic
* @param predicate3 - fourth predicate function
* @param x4 - fifth input array
* @param predicate4 - fifth predicate function
-* @param args - additional input values
+* @param args - additional input arrays and predicate functions
* @returns result
*
* @example
@@ -235,7 +235,7 @@ declare function countIfs>( x0: U, predicate0: Predic
* var n = countIfs( x0, predicate0, x1, predicate1, x3, predicate3, x4, predicate4 );
* // returns 2
*/
-declare function countIfs>( x0: U, predicate0: Predicate, x1: U, predicate1: Predicate, x2: U, predicate2: Predicate, x3: U, predicate3: Predicate, x4: U, predicate4: Predicate, ...args: Array> ): number;
+declare function countIfs = InputArray>( x0: U, predicate0: Predicate, x1: U, predicate1: Predicate, x2: U, predicate2: Predicate, x3: U, predicate3: Predicate, x4: U, predicate4: Predicate, ...args: Array> ): number;
// EXPORTS //
diff --git a/lib/node_modules/@stdlib/array/base/count-ifs/docs/types/test.ts b/lib/node_modules/@stdlib/array/base/count-ifs/docs/types/test.ts
index 438a78f0dbfa..679095e2a9fd 100644
--- a/lib/node_modules/@stdlib/array/base/count-ifs/docs/types/test.ts
+++ b/lib/node_modules/@stdlib/array/base/count-ifs/docs/types/test.ts
@@ -33,7 +33,7 @@ function isPositive( value: number ): boolean {
* Tests whether a value is negative.
*
* @param value - input value
-* @returns boolean indicating whether an element is positive
+* @returns boolean indicating whether an element is negative
*/
function isNegative( value: number ): boolean {
return ( value < 0 );
@@ -44,17 +44,27 @@ function isNegative( value: number ): boolean {
// The function returns a number...
{
- countIfs( [ 1, 2, 3 ], isPositive, [ -1, -2, -3 ], isNegative ); // $ExpectType number
- countIfs( new Float64Array( [ 1, 2, 3 ] ), isPositive, new Float64Array( [ -1, -2, -3 ] ), isNegative ); // $ExpectType number
- countIfs( new Float32Array( [ 1, 2, 3 ] ), isPositive, new Float32Array( [ -1, -2, -3 ] ), isNegative ); // $ExpectType number
- countIfs( new Int32Array( [ 1, 2, 3 ] ), isPositive, new Int32Array( [ -1, -2, -3 ] ), isNegative ); // $ExpectType number
- countIfs( new Int16Array( [ 1, 2, 3 ] ), isPositive, new Int16Array( [ -1, -2, -3 ] ), isNegative ); // $ExpectType number
- countIfs( new Int8Array( [ 1, 2, 3 ] ), isPositive, new Int8Array( [ -1, -2, -3 ] ), isNegative ); // $ExpectType number
- countIfs( new Uint32Array( [ 1, 2, 3 ] ), isPositive, new Uint32Array( [ -1, -2, -3 ] ), isNegative ); // $ExpectType number
- countIfs( new Uint16Array( [ 1, 2, 3 ] ), isPositive, new Uint16Array( [ -1, -2, -3 ] ), isNegative ); // $ExpectType number
- countIfs( new Uint8Array( [ 1, 2, 3 ] ), isPositive, new Uint8Array( [ -1, -2, -3 ] ), isNegative ); // $ExpectType number
- countIfs( new Uint8ClampedArray( [ 1, 2, 3 ] ), isPositive, new Uint8ClampedArray( [ -1, -2, -3 ] ), isNegative ); // $ExpectType number
- countIfs( toAccessorArray( [ 1, 2, 3 ] ), isPositive, toAccessorArray( [ -1, -2, -3 ] ), isNegative ); // $ExpectType number
+ const x = [ 1, 2, 3 ];
+ const y = [ -1, -2, -3 ];
+
+ countIfs( x, isPositive ); // $ExpectType number
+ countIfs( x, isPositive, y, isNegative ); // $ExpectType number
+ countIfs( x, isPositive, x, isPositive, y, isNegative ); // $ExpectType number
+ countIfs( x, isPositive, x, isPositive, x, isPositive, y, isNegative ); // $ExpectType number
+ countIfs( x, isPositive, x, isPositive, x, isPositive, x, isPositive, y, isNegative ); // $ExpectType number
+ countIfs( x, isPositive, x, isPositive, x, isPositive, x, isPositive, x, isPositive, y, isNegative ); // $ExpectType number
+ countIfs( x, isPositive, x, isPositive, x, isPositive, x, isPositive, x, isPositive, x, isPositive, y, isNegative ); // $ExpectType number
+
+ countIfs( new Float64Array( x ), isPositive, new Float64Array( y ), isNegative ); // $ExpectType number
+ countIfs( new Float32Array( x ), isPositive, new Float32Array( y ), isNegative ); // $ExpectType number
+ countIfs( new Int32Array( x ), isPositive, new Int32Array( y ), isNegative ); // $ExpectType number
+ countIfs( new Int16Array( x ), isPositive, new Int16Array( y ), isNegative ); // $ExpectType number
+ countIfs( new Int8Array( x ), isPositive, new Int8Array( y ), isNegative ); // $ExpectType number
+ countIfs( new Uint32Array( x ), isPositive, new Uint32Array( y ), isNegative ); // $ExpectType number
+ countIfs( new Uint16Array( x ), isPositive, new Uint16Array( y ), isNegative ); // $ExpectType number
+ countIfs( new Uint8Array( x ), isPositive, new Uint8Array( y ), isNegative ); // $ExpectType number
+ countIfs( new Uint8ClampedArray( x ), isPositive, new Uint8ClampedArray( y ), isNegative ); // $ExpectType number
+ countIfs( toAccessorArray( x ), isPositive, toAccessorArray( y ), isNegative ); // $ExpectType number
}
// The compiler throws an error if the function is provided a first argument which is not a collection...
@@ -63,56 +73,122 @@ function isNegative( value: number ): boolean {
countIfs( false, isPositive ); // $ExpectError
countIfs( true, isPositive ); // $ExpectError
countIfs( {}, isPositive ); // $ExpectError
-
- countIfs( 2, isPositive, {} ); // $ExpectError
- countIfs( false, isPositive, {} ); // $ExpectError
- countIfs( true, isPositive, {} ); // $ExpectError
- countIfs( {}, isPositive, {} ); // $ExpectError
}
// The compiler throws an error if the function is provided a second argument which is not a function...
{
- countIfs( [ 1, 2, 3 ], 'abc' ); // $ExpectError
- countIfs( [ 1, 2, 3 ], 2 ); // $ExpectError
- countIfs( [ 1, 2, 3 ], false ); // $ExpectError
- countIfs( [ 1, 2, 3 ], true ); // $ExpectError
- countIfs( [ 1, 2, 3 ], null ); // $ExpectError
- countIfs( [ 1, 2, 3 ], void 0 ); // $ExpectError
- countIfs( [ 1, 2, 3 ], {} ); // $ExpectError
- countIfs( [ 1, 2, 3 ], [] ); // $ExpectError
-
- countIfs( [ 1, 2, 3 ], 'abc', {} ); // $ExpectError
- countIfs( [ 1, 2, 3 ], 2, {} ); // $ExpectError
- countIfs( [ 1, 2, 3 ], false, {} ); // $ExpectError
- countIfs( [ 1, 2, 3 ], true, {} ); // $ExpectError
- countIfs( [ 1, 2, 3 ], null, {} ); // $ExpectError
- countIfs( [ 1, 2, 3 ], void 0, {} ); // $ExpectError
- countIfs( [ 1, 2, 3 ], {}, {} ); // $ExpectError
- countIfs( [ 1, 2, 3 ], [], {} ); // $ExpectError
+ const x = [ 1, 2, 3 ];
+
+ countIfs( x, 'abc' ); // $ExpectError
+ countIfs( x, 2 ); // $ExpectError
+ countIfs( x, false ); // $ExpectError
+ countIfs( x, true ); // $ExpectError
+ countIfs( x, null ); // $ExpectError
+ countIfs( x, void 0 ); // $ExpectError
+ countIfs( x, {} ); // $ExpectError
+ countIfs( x, [] ); // $ExpectError
}
// The compiler throws an error if the function is provided a third argument which is not a collection...
{
- countIfs( [ 1, 2, 3 ], isPositive, 2, isNegative ); // $ExpectError
- countIfs( [ 1, 2, 3 ], isPositive, false, isNegative ); // $ExpectError
- countIfs( [ 1, 2, 3 ], isPositive, true, isNegative ); // $ExpectError
- countIfs( [ 1, 2, 3 ], isPositive, {}, isNegative ); // $ExpectError
+ const x = [ 1, 2, 3 ];
+
+ countIfs( x, isPositive, 2, isNegative ); // $ExpectError
+ countIfs( x, isPositive, false, isNegative ); // $ExpectError
+ countIfs( x, isPositive, true, isNegative ); // $ExpectError
+ countIfs( x, isPositive, {}, isNegative ); // $ExpectError
}
// The compiler throws an error if the function is provided a fourth argument which is not a function...
{
- countIfs( [ 1, 2, 3 ], isPositive, [ -1, -2, -3 ], 'abc' ); // $ExpectError
- countIfs( [ 1, 2, 3 ], isPositive, [ -1, -2, -3 ], 2 ); // $ExpectError
- countIfs( [ 1, 2, 3 ], isPositive, [ -1, -2, -3 ], false ); // $ExpectError
- countIfs( [ 1, 2, 3 ], isPositive, [ -1, -2, -3 ], true ); // $ExpectError
- countIfs( [ 1, 2, 3 ], isPositive, [ -1, -2, -3 ], null ); // $ExpectError
- countIfs( [ 1, 2, 3 ], isPositive, [ -1, -2, -3 ], void 0 ); // $ExpectError
- countIfs( [ 1, 2, 3 ], isPositive, [ -1, -2, -3 ], {} ); // $ExpectError
- countIfs( [ 1, 2, 3 ], isPositive, [ -1, -2, -3 ], [] ); // $ExpectError
+ const x = [ 1, 2, 3 ];
+
+ countIfs( x, isPositive, x, 'abc' ); // $ExpectError
+ countIfs( x, isPositive, x, 2 ); // $ExpectError
+ countIfs( x, isPositive, x, false ); // $ExpectError
+ countIfs( x, isPositive, x, true ); // $ExpectError
+ countIfs( x, isPositive, x, null ); // $ExpectError
+ countIfs( x, isPositive, x, void 0 ); // $ExpectError
+ countIfs( x, isPositive, x, {} ); // $ExpectError
+ countIfs( x, isPositive, x, [] ); // $ExpectError
+}
+
+// The compiler throws an error if the function is provided a fifth argument which is not a collection...
+{
+ const x = [ 1, 2, 3 ];
+
+ countIfs( x, isPositive, x, isPositive, 2, isNegative ); // $ExpectError
+ countIfs( x, isPositive, x, isPositive, false, isNegative ); // $ExpectError
+ countIfs( x, isPositive, x, isPositive, true, isNegative ); // $ExpectError
+ countIfs( x, isPositive, x, isPositive, {}, isNegative ); // $ExpectError
+}
+
+// The compiler throws an error if the function is provided a sixth argument which is not a function...
+{
+ const x = [ 1, 2, 3 ];
+
+ countIfs( x, isPositive, x, isPositive, x, 'abc' ); // $ExpectError
+ countIfs( x, isPositive, x, isPositive, x, 2 ); // $ExpectError
+ countIfs( x, isPositive, x, isPositive, x, false ); // $ExpectError
+ countIfs( x, isPositive, x, isPositive, x, true ); // $ExpectError
+ countIfs( x, isPositive, x, isPositive, x, null ); // $ExpectError
+ countIfs( x, isPositive, x, isPositive, x, void 0 ); // $ExpectError
+ countIfs( x, isPositive, x, isPositive, x, {} ); // $ExpectError
+ countIfs( x, isPositive, x, isPositive, x, [] ); // $ExpectError
+}
+
+// The compiler throws an error if the function is provided a seventh argument which is not a collection...
+{
+ const x = [ 1, 2, 3 ];
+
+ countIfs( x, isPositive, x, isPositive, x, isPositive, 2, isNegative ); // $ExpectError
+ countIfs( x, isPositive, x, isPositive, x, isPositive, false, isNegative ); // $ExpectError
+ countIfs( x, isPositive, x, isPositive, x, isPositive, true, isNegative ); // $ExpectError
+ countIfs( x, isPositive, x, isPositive, x, isPositive, {}, isNegative ); // $ExpectError
+}
+
+// The compiler throws an error if the function is provided an eighth argument which is not a function...
+{
+ const x = [ 1, 2, 3 ];
+
+ countIfs( x, isPositive, x, isPositive, x, isPositive, x, 'abc' ); // $ExpectError
+ countIfs( x, isPositive, x, isPositive, x, isPositive, x, 2 ); // $ExpectError
+ countIfs( x, isPositive, x, isPositive, x, isPositive, x, false ); // $ExpectError
+ countIfs( x, isPositive, x, isPositive, x, isPositive, x, true ); // $ExpectError
+ countIfs( x, isPositive, x, isPositive, x, isPositive, x, null ); // $ExpectError
+ countIfs( x, isPositive, x, isPositive, x, isPositive, x, void 0 ); // $ExpectError
+ countIfs( x, isPositive, x, isPositive, x, isPositive, x, {} ); // $ExpectError
+ countIfs( x, isPositive, x, isPositive, x, isPositive, x, [] ); // $ExpectError
+}
+
+// The compiler throws an error if the function is provided a ninth argument which is not a collection...
+{
+ const x = [ 1, 2, 3 ];
+
+ countIfs( x, isPositive, x, isPositive, x, isPositive, x, isPositive, 2, isNegative ); // $ExpectError
+ countIfs( x, isPositive, x, isPositive, x, isPositive, x, isPositive, false, isNegative ); // $ExpectError
+ countIfs( x, isPositive, x, isPositive, x, isPositive, x, isPositive, true, isNegative ); // $ExpectError
+ countIfs( x, isPositive, x, isPositive, x, isPositive, x, isPositive, {}, isNegative ); // $ExpectError
+}
+
+// The compiler throws an error if the function is provided a tenth argument which is not a function...
+{
+ const x = [ 1, 2, 3 ];
+
+ countIfs( x, isPositive, x, isPositive, x, isPositive, x, isPositive, x, 'abc' ); // $ExpectError
+ countIfs( x, isPositive, x, isPositive, x, isPositive, x, isPositive, x, 2 ); // $ExpectError
+ countIfs( x, isPositive, x, isPositive, x, isPositive, x, isPositive, x, false ); // $ExpectError
+ countIfs( x, isPositive, x, isPositive, x, isPositive, x, isPositive, x, true ); // $ExpectError
+ countIfs( x, isPositive, x, isPositive, x, isPositive, x, isPositive, x, null ); // $ExpectError
+ countIfs( x, isPositive, x, isPositive, x, isPositive, x, isPositive, x, void 0 ); // $ExpectError
+ countIfs( x, isPositive, x, isPositive, x, isPositive, x, isPositive, x, {} ); // $ExpectError
+ countIfs( x, isPositive, x, isPositive, x, isPositive, x, isPositive, x, [] ); // $ExpectError
}
// The compiler throws an error if the function is provided an unsupported number of arguments...
{
+ const x = [ 1, 2, 3 ];
+
countIfs(); // $ExpectError
- countIfs( [ 1, 2, 3 ] ); // $ExpectError
+ countIfs( x ); // $ExpectError
}
diff --git a/lib/node_modules/@stdlib/array/base/count-ifs/examples/index.js b/lib/node_modules/@stdlib/array/base/count-ifs/examples/index.js
index b5e315d16aed..3b148e70f84b 100644
--- a/lib/node_modules/@stdlib/array/base/count-ifs/examples/index.js
+++ b/lib/node_modules/@stdlib/array/base/count-ifs/examples/index.js
@@ -27,16 +27,12 @@ var countIfs = require( './../lib' );
var x = discreteUniform( 10, -5, 5, {
'dtype': 'int32'
});
-// returns
+console.log( x );
var y = discreteUniform( 10, -5, 5, {
'dtype': 'int32'
});
-// returns
+console.log( y );
var out = countIfs( x, naryFunction( isPositiveInteger, 1 ), y, naryFunction( isNegativeInteger, 1 ) ); // eslint-disable-line max-len
-// returns
-
-console.log( x );
-console.log( y );
console.log( out );
diff --git a/lib/node_modules/@stdlib/array/base/count-ifs/lib/index.js b/lib/node_modules/@stdlib/array/base/count-ifs/lib/index.js
index 15c005345ec5..3b8632f51c67 100644
--- a/lib/node_modules/@stdlib/array/base/count-ifs/lib/index.js
+++ b/lib/node_modules/@stdlib/array/base/count-ifs/lib/index.js
@@ -19,7 +19,7 @@
'use strict';
/**
-* Count the number of elements in the input arrays which pass the tests implemented by the predicate functions.
+* Perform element-wise evaluation of one or more input arrays according to provided predicate functions and count the number of elements for which all predicates respectively return `true`.
*
* @module @stdlib/array/base/count-ifs
*
diff --git a/lib/node_modules/@stdlib/array/base/count-ifs/lib/main.js b/lib/node_modules/@stdlib/array/base/count-ifs/lib/main.js
index 911d809c111e..7ab87971ba43 100644
--- a/lib/node_modules/@stdlib/array/base/count-ifs/lib/main.js
+++ b/lib/node_modules/@stdlib/array/base/count-ifs/lib/main.js
@@ -27,13 +27,13 @@ var zeroTo = require( '@stdlib/array/base/zero-to' );
// FUNCTIONS //
/**
-* Returns an array of indices of the input array which pass the test implemented by the predicate function.
+* Returns an array of indices of elements of an input array which pass a test implemented by a predicate function.
*
* @private
* @param {Collection} x - input array
-* @param {Array} idx - input array indices
+* @param {Array} idx - list of indices
* @param {Function} predicate - predicate function
-* @returns {Array