From 3c9e0d5e32bf1959f0d35d57e08eb72f46287b87 Mon Sep 17 00:00:00 2001 From: Priyanshu Agarwl Date: Sun, 25 Feb 2024 17:49:06 +0530 Subject: [PATCH 1/6] feat: added @stdlib/array/base/count-same-value-zero count the number of elements that are equal to a given value in an array Fixes #1326 --- .../base/count-same-value-zero/README.md | 111 ++++++++++ .../benchmark/benchmark.length.js | 96 +++++++++ .../docs/types/index.d.ts | 43 ++++ .../count-same-value-zero/docs/types/test.ts | 43 ++++ .../count-same-value-zero/example/index.js | 30 +++ .../base/count-same-value-zero/lib/index.js | 42 ++++ .../base/count-same-value-zero/lib/main.js | 165 +++++++++++++++ .../base/count-same-value-zero/package.json | 65 ++++++ .../base/count-same-value-zero/test/test.js | 191 ++++++++++++++++++ 9 files changed, 786 insertions(+) create mode 100644 lib/node_modules/@stdlib/array/base/count-same-value-zero/README.md create mode 100644 lib/node_modules/@stdlib/array/base/count-same-value-zero/benchmark/benchmark.length.js create mode 100644 lib/node_modules/@stdlib/array/base/count-same-value-zero/docs/types/index.d.ts create mode 100644 lib/node_modules/@stdlib/array/base/count-same-value-zero/docs/types/test.ts create mode 100644 lib/node_modules/@stdlib/array/base/count-same-value-zero/example/index.js create mode 100644 lib/node_modules/@stdlib/array/base/count-same-value-zero/lib/index.js create mode 100644 lib/node_modules/@stdlib/array/base/count-same-value-zero/lib/main.js create mode 100644 lib/node_modules/@stdlib/array/base/count-same-value-zero/package.json create mode 100644 lib/node_modules/@stdlib/array/base/count-same-value-zero/test/test.js diff --git a/lib/node_modules/@stdlib/array/base/count-same-value-zero/README.md b/lib/node_modules/@stdlib/array/base/count-same-value-zero/README.md new file mode 100644 index 00000000000..cb75ff0c328 --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/count-same-value-zero/README.md @@ -0,0 +1,111 @@ + + +# countSameValueZero + +> Count the number of elements that are equal to a given value in an array. + + + +
+ +
+ + + + + +
+ +## Usage + +```javascript +var countSameValueZero = require( '@stdlib/array/base/count-same-value-zero' ); +``` + +#### countSameValueZero( x, value ) + +Counts the number of elements that are equal to a given value in an array. + +```javascript +var x = [ 0, 1, 0, 1, 2 ]; + +var out = countSameValueZero( x, 1 ); +// returns 2 +``` + +
+ + + + + +
+ +
+ + + + + +
+ +## Examples + + + +```javascript +var sample = require( '@stdlib/random/sample' ); +var countSameValueZero = require( '@stdlib/array/base/count-same-value-zero' ); + +var x = sample( [ 1, 2, 3, 4, 5 ] ); +console.log( x ); + +var n = countSameValueZero( x, 1 ); +console.log( n ); +``` + +
+ + + + + +
+ +
+ + + + + + + + + + + + + + diff --git a/lib/node_modules/@stdlib/array/base/count-same-value-zero/benchmark/benchmark.length.js b/lib/node_modules/@stdlib/array/base/count-same-value-zero/benchmark/benchmark.length.js new file mode 100644 index 00000000000..d320d1a11f6 --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/count-same-value-zero/benchmark/benchmark.length.js @@ -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 pow = require( '@stdlib/math/base/special/pow' ); +var isNonNegativeInteger = require( '@stdlib/assert/is-nonnegative-integer' ).isPrimitive; +var ones = require( '@stdlib/array/base/ones' ); +var pkg = require( './../package.json' ).name; +var countSameValueZero = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + var x = ones( len ); + 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 = countSameValueZero( x, 1 ); + 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-same-value-zero/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/base/count-same-value-zero/docs/types/index.d.ts new file mode 100644 index 00000000000..006b4f194f0 --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/count-same-value-zero/docs/types/index.d.ts @@ -0,0 +1,43 @@ +/* +* @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. +*/ + +// TypeScript Version: 4.1 + +/// + +import { Collection } from '@stdlib/types/array'; + +/** +* Counts the number of elements that are equal to a given value in an array. +* +* @param x - input array +* @param value - given value +* @returns number of elements that are equal to the given value +* +* @example +* var x = [ 0, 1, 0, 1, 1 ]; +* +* var out = countSameValue( x, 1 ); +* // returns 3 +*/ +declare function countSameValueZero( x: Collection, value: any ): number; + + +// EXPORTS // + +export = countSameValueZero; diff --git a/lib/node_modules/@stdlib/array/base/count-same-value-zero/docs/types/test.ts b/lib/node_modules/@stdlib/array/base/count-same-value-zero/docs/types/test.ts new file mode 100644 index 00000000000..e385f56bd75 --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/count-same-value-zero/docs/types/test.ts @@ -0,0 +1,43 @@ +/* +* @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. +*/ + +import countSameValueZero = require( './index' ); + + +// TESTS // + +// The function returns a number... +{ + countSameValueZero( [ 1, 2, 3 ], 1 ); // $ExpectType number +} + +// The compiler throws an error if the first argument is not a collection... +{ + countSameValueZero( 5, 1 ); // $ExpectError + countSameValueZero( true, 1 ); // $ExpectError + countSameValueZero( false, 1 ); // $ExpectError + countSameValueZero( null, 1 ); // $ExpectError + countSameValueZero( {}, 1 ); // $ExpectError +} + +// The compiler throws an error if the function is provided an unsupported number of arguments... +{ + countSameValueZero(); // $ExpectError + countSameValueZero( [ 1, 2, 3 ] ); // $ExpectError + countSameValueZero( [ 1, 2, 3 ], 2, 3 ); // $ExpectError +} diff --git a/lib/node_modules/@stdlib/array/base/count-same-value-zero/example/index.js b/lib/node_modules/@stdlib/array/base/count-same-value-zero/example/index.js new file mode 100644 index 00000000000..c85282e909e --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/count-same-value-zero/example/index.js @@ -0,0 +1,30 @@ +/** +* @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'; + +var sample = require( '@stdlib/random/sample' ); +var countSameValueZero = require( './../lib' ); +var x; +var n; + +x = sample( [ 1, 2, 3, 4, 5 ] ); +console.log( x ); + +n = countSameValueZero( x, 1 ); +console.log( n ); diff --git a/lib/node_modules/@stdlib/array/base/count-same-value-zero/lib/index.js b/lib/node_modules/@stdlib/array/base/count-same-value-zero/lib/index.js new file mode 100644 index 00000000000..75abf6a6044 --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/count-same-value-zero/lib/index.js @@ -0,0 +1,42 @@ +/** +* @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'; + +/** +* Count the number of elements that are equal to a given value in an array. +* +* @module @stdlib/array/base/count-same-value-zero +* +* @example +* var countSameValueZero = require( '@stdlib/array/base/count-same-value-zero' ); +* +* var x = [ 0, 0, 1, 0, 1 ]; +* +* var n = countSameValueZero( x, 1 ); +* // returns 2 +*/ + +// MODULES // + +var main = require( './main.js' ); + + +// EXPORTS // + +module.exports = main; diff --git a/lib/node_modules/@stdlib/array/base/count-same-value-zero/lib/main.js b/lib/node_modules/@stdlib/array/base/count-same-value-zero/lib/main.js new file mode 100644 index 00000000000..555e70e7263 --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/count-same-value-zero/lib/main.js @@ -0,0 +1,165 @@ +/** +* @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 isComplexTypedArray = require( '@stdlib/array/base/assert/is-complex-typed-array' ); +var isComplexLike = require( '@stdlib/assert/is-complex-like' ); +var real = require( '@stdlib/complex/real' ); +var imag = require( '@stdlib/complex/imag' ); +var reinterpret = require( '@stdlib/strided/base/reinterpret-complex' ); +var isAccessorArray = require( '@stdlib/array/base/assert/is-accessor-array' ); +var resolveGetter = require( '@stdlib/array/base/resolve-getter' ); +var isSameValueZero = require( '@stdlib/assert/is-same-value-zero' ); + + +// FUNCTIONS // + +/** +* Counts the number of elements that are equal to a given value in an indexed array. +* +* @private +* @param {Collection} x - input array +* @param {*} value - given value +* @returns {NonNegativeInteger} number of elements that are equal to the given value +* +* @example +* var x = [ 0, 0, 1, 0, 1 ]; +* +* var n = indexed( x, 0 ); +* // returns 3 +*/ +function indexed( x, value ) { + var n; + var i; + + n = 0; + for ( i = 0; i < x.length; i++ ) { + if ( isSameValueZero( x[ i ], value ) ) { + n += 1; + } + } + return n; +} + +/** +* Counts the number of elements that are equal to a given value in an accessor array. +* +* @private +* @param {Collection} x - input array +* @param {*} value - given value +* @returns {NonNegativeInteger} number of elements that are equal to the given value +* +* @example +* var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +* +* var x = toAccessorArray( [ 0, 0, 1, 0, 1 ] ); +* +* var n = accessors( x, 0 ); +* // returns 3 +*/ +function accessors( x, value ) { + var get; + var n; + var i; + + get = resolveGetter( x ); + + n = 0; + for ( i = 0; i < x.length; i++ ) { + if ( isSameValueZero( get( x, i ), value ) ) { + n += 1; + } + } + return n; +} + +/** +* Counts the number of elements that are equal to a given value in a complex array. +* +* @private +* @param {Collection} x - input array +* @param {*} value - given value +* @returns {NonNegativeInteger} number of elements that are equal to the given value +* +* @example +* var Complex128 = require( '@stdlib/complex/float64' ); +* var Complex128Array = require( '@stdlib/array/complex128' ); +* +* var x = new Complex128Array( [ 1.0, 2.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0 ] ); +* +* var n = complex( x, new Complex128( 1.0, 2.0 ) ); +* // returns 1 +*/ +function complex( x, value ) { + var view; + var re; + var im; + var n; + var i; + + if ( !isComplexLike( value ) ) { + return 0; + } + + re = real( value ); + im = imag( value ); + + view = reinterpret( x, 0 ); + + n = 0; + for ( i = 0; i < view.length; i += 2 ) { + if ( isSameValueZero( view[ i ], re ) && isSameValueZero( view[ i + 1 ], im ) ) { + n += 1; + } + } + return n; +} + + +// MAIN // + +/** +* Counts the number of elements that are equal to a given value in an array. +* +* @param {Collection} x - input array +* @param {*} value - given value +* @returns {NonNegativeInteger} number of elements that are equal to the given value +* +* @example +* var x = [ 0, 0, 1, 0, 1 ]; +* +* var n = countSameValue( x, 1 ); +* // throws +*/ +function countSameValueZero( x, value ) { + if ( isAccessorArray( x, value ) ) { + if ( isComplexTypedArray( x, value ) ) { + return complex( x, value ); + } + return accessors( x, value ); + } + return indexed( x, value ); +} + + +// EXPORTS // + +module.exports = countSameValueZero; diff --git a/lib/node_modules/@stdlib/array/base/count-same-value-zero/package.json b/lib/node_modules/@stdlib/array/base/count-same-value-zero/package.json new file mode 100644 index 00000000000..10c33514e01 --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/count-same-value-zero/package.json @@ -0,0 +1,65 @@ +{ + "name": "@stdlib/array/base/count-same-value-zero", + "version": "0.0.0", + "description": "Count the number of elements that are equal to a given value in an array.", + "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", + "total", + "same" + ] + } \ No newline at end of file diff --git a/lib/node_modules/@stdlib/array/base/count-same-value-zero/test/test.js b/lib/node_modules/@stdlib/array/base/count-same-value-zero/test/test.js new file mode 100644 index 00000000000..65327a5b4a4 --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/count-same-value-zero/test/test.js @@ -0,0 +1,191 @@ +/** +* @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 tape = require( 'tape' ); +var Complex128 = require( '@stdlib/complex/float64' ); +var Complex128Array = require( '@stdlib/array/complex128' ); +var Int32Array = require( '@stdlib/array/int32' ); +var Float32Array = require( '@stdlib/array/float32' ); +var toAccessorArray = require( '@stdlib/array/base/to-accessor-array' ); +var countSameValueZero = require( './../lib' ); + + +// TESTS // + +tape( 'main export is a function', function test( t ) { + t.ok( true, __filename ); + t.strictEqual( typeof countSameValueZero, 'function', 'main export is a function' ); + t.end(); +}); + +tape( 'the function counts the number of same values (generic)', function test( t ) { + var expected; + var actual; + var x; + + x = [ 0, 1, 0, 1, 2 ]; + expected = 2; + actual = countSameValueZero( x, 1 ); + t.strictEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function consider positive and negative zeros to be indentical (generic)', function test( t ) { + var expected; + var actual; + var x; + + x = [ 0.0, -0.0, 0.0, -0.0, 0.0, NaN, 1.0 ]; + expected = 5; + actual = countSameValueZero( x, 0.0 ); + + t.strictEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function considers all NaN values to be identical (generic)', function test( t ) { + var expected; + var actual; + var x; + + x = [ NaN, 0, NaN, 2, NaN, 9, NaN ]; + expected = 4; + actual = countSameValueZero( x, NaN ); + + t.strictEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function counts the number of same values (accessors)', function test( t ) { + var expected; + var actual; + var x; + + x = toAccessorArray( [ 0, 1, 0, 1, 2 ] ); + expected = 2; + actual = countSameValueZero( x, 1 ); + t.strictEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function consider positive and negative zeros to be indentical (accessors)', function test( t ) { + var expected; + var actual; + var x; + + x = toAccessorArray( [ 0.0, -0.0, 0.0, -0.0, 0.0, NaN, 1.0 ] ); + expected = 5; + actual = countSameValueZero( x, 0.0 ); + + t.strictEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function considers all NaN values to be identical (accessors)', function test( t ) { + var expected; + var actual; + var x; + + x = toAccessorArray( [ NaN, 0, NaN, 2, NaN, 9, NaN ] ); + expected = 4; + actual = countSameValueZero( x, NaN ); + + t.strictEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function counts the number of same values (real typed array)', function test( t ) { + var expected; + var actual; + var x; + + x = new Int32Array( [ 0, 1, 0, 1, 2 ] ); + expected = 2; + actual = countSameValueZero( x, 1 ); + + t.strictEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function consider positive and negative zeros to be indentical (real typed array)', function test( t ) { + var expected; + var actual; + var x; + + x = new Float32Array( [ 0.0, -0.0, 0.0, -0.0, 0.0, NaN, 1.0 ] ); + expected = 5; + actual = countSameValueZero( x, 0.0 ); + + t.strictEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function considers all NaN values to be identical (real typed array)', function test( t ) { + var expected; + var actual; + var x; + + x = new Float32Array( [ NaN, 0, NaN, 2, NaN, 9, NaN ] ); + expected = 4; + actual = countSameValueZero( x, NaN ); + + t.strictEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function counts the number of same values (complex typed array)', function test( t ) { + var expected; + var actual; + var x; + + x = new Complex128Array( [ 0.0, 0.0, 1.0, 0.0, 3.0, 4.0, 0.0, 5.0 ] ); + expected = 1; + actual = countSameValueZero( x, new Complex128( 3.0, 4.0 ) ); + t.strictEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function consider positive and negative zeros to be indentical (complex typed array)', function test( t ) { + var expected; + var actual; + var x; + + x = new Complex128Array( [ 0.0, -0.0, 0.0, -0.0, 0.0, 0.0, -0.0, -0.0, -0.0, 0.0 ] ); + expected = 5; + actual = countSameValueZero( x, new Complex128( 0.0, -0.0 ) ); + + t.strictEqual( actual, expected, 'returns expected value' ); + t.end(); +}); + +tape( 'the function considers all NaN values to be identical (complex typed array)', function test( t ) { + var expected; + var actual; + var x; + + x = new Complex128Array( [ NaN, NaN, NaN, 2.0, NaN, 9.0, NaN, NaN ] ); + expected = 2; + actual = countSameValueZero( x, new Complex128( NaN, NaN ) ); + + t.strictEqual( actual, expected, 'returns expected value' ); + t.end(); +}); From 218106af15c226b7885dc81e001a67dc967c1fae Mon Sep 17 00:00:00 2001 From: AgPriyanshu18 <113460573+AgPriyanshu18@users.noreply.github.com> Date: Sun, 25 Feb 2024 21:45:35 +0530 Subject: [PATCH 2/6] Apply suggestions from code review Co-authored-by: Jaysukh Makvana <111515433+Jaysukh-409@users.noreply.github.com> Signed-off-by: AgPriyanshu18 <113460573+AgPriyanshu18@users.noreply.github.com> --- .../array/base/count-same-value-zero/docs/types/index.d.ts | 2 +- .../@stdlib/array/base/count-same-value-zero/lib/main.js | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/lib/node_modules/@stdlib/array/base/count-same-value-zero/docs/types/index.d.ts b/lib/node_modules/@stdlib/array/base/count-same-value-zero/docs/types/index.d.ts index 006b4f194f0..fdc419661b3 100644 --- a/lib/node_modules/@stdlib/array/base/count-same-value-zero/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/array/base/count-same-value-zero/docs/types/index.d.ts @@ -32,7 +32,7 @@ import { Collection } from '@stdlib/types/array'; * @example * var x = [ 0, 1, 0, 1, 1 ]; * -* var out = countSameValue( x, 1 ); +* var out = countSameValueZero( x, 1 ); * // returns 3 */ declare function countSameValueZero( x: Collection, value: any ): number; diff --git a/lib/node_modules/@stdlib/array/base/count-same-value-zero/lib/main.js b/lib/node_modules/@stdlib/array/base/count-same-value-zero/lib/main.js index 555e70e7263..fb45e287593 100644 --- a/lib/node_modules/@stdlib/array/base/count-same-value-zero/lib/main.js +++ b/lib/node_modules/@stdlib/array/base/count-same-value-zero/lib/main.js @@ -146,7 +146,7 @@ function complex( x, value ) { * @example * var x = [ 0, 0, 1, 0, 1 ]; * -* var n = countSameValue( x, 1 ); +* var n = countSameValueZero( x, 1 ); * // throws */ function countSameValueZero( x, value ) { From d69eb54bfb448c70675971c04d321d426a01b6b5 Mon Sep 17 00:00:00 2001 From: AgPriyanshu18 <113460573+AgPriyanshu18@users.noreply.github.com> Date: Mon, 26 Feb 2024 16:02:00 +0000 Subject: [PATCH 3/6] feat: added array/base/count-same-value-zero. Suggested changes done Fixes #1328 --- .../base/count-same-value-zero/docs/repl.txt | 25 +++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 lib/node_modules/@stdlib/array/base/count-same-value-zero/docs/repl.txt diff --git a/lib/node_modules/@stdlib/array/base/count-same-value-zero/docs/repl.txt b/lib/node_modules/@stdlib/array/base/count-same-value-zero/docs/repl.txt new file mode 100644 index 00000000000..dd1d1fc13c7 --- /dev/null +++ b/lib/node_modules/@stdlib/array/base/count-same-value-zero/docs/repl.txt @@ -0,0 +1,25 @@ + +{{alias}}( x, value ) + Counts the number of elements that are equal to a given value in an array. + + Parameters + ---------- + x: ArrayLikeObject + Input array. + + value: any + Input value. + + Returns + ------- + out: integer + Number of elements that are equal to the given value. + + Examples + -------- + > var out = {{alias}}( [ 0, 1, 1 ], 1 ) + 2 + + See Also + -------- + From c080fc3204ae7601f51a6719f20b0747adc7e9a9 Mon Sep 17 00:00:00 2001 From: AgPriyanshu18 <113460573+AgPriyanshu18@users.noreply.github.com> Date: Mon, 26 Feb 2024 17:46:54 +0000 Subject: [PATCH 4/6] feat: added array/base/count-same-value-zero. --- .../@stdlib/array/base/count-same-value-zero/lib/main.js | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/array/base/count-same-value-zero/lib/main.js b/lib/node_modules/@stdlib/array/base/count-same-value-zero/lib/main.js index fb45e287593..d4ad2141f0c 100644 --- a/lib/node_modules/@stdlib/array/base/count-same-value-zero/lib/main.js +++ b/lib/node_modules/@stdlib/array/base/count-same-value-zero/lib/main.js @@ -144,10 +144,13 @@ function complex( x, value ) { * @returns {NonNegativeInteger} number of elements that are equal to the given value * * @example +* +* var countSameValueZero = require( '@stdlib/array/base/is-same-value-zero' ); +* * var x = [ 0, 0, 1, 0, 1 ]; * * var n = countSameValueZero( x, 1 ); -* // throws +* // return 2 */ function countSameValueZero( x, value ) { if ( isAccessorArray( x, value ) ) { From 3aed4448a8faff0f868d886ded387f62f542f56b Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Tue, 27 Feb 2024 19:18:00 -0500 Subject: [PATCH 5/6] Update lib/node_modules/@stdlib/array/base/count-same-value-zero/lib/main.js Signed-off-by: Philipp Burckhardt --- .../@stdlib/array/base/count-same-value-zero/lib/main.js | 1 - 1 file changed, 1 deletion(-) diff --git a/lib/node_modules/@stdlib/array/base/count-same-value-zero/lib/main.js b/lib/node_modules/@stdlib/array/base/count-same-value-zero/lib/main.js index d4ad2141f0c..ed25978b49d 100644 --- a/lib/node_modules/@stdlib/array/base/count-same-value-zero/lib/main.js +++ b/lib/node_modules/@stdlib/array/base/count-same-value-zero/lib/main.js @@ -144,7 +144,6 @@ function complex( x, value ) { * @returns {NonNegativeInteger} number of elements that are equal to the given value * * @example -* * var countSameValueZero = require( '@stdlib/array/base/is-same-value-zero' ); * * var x = [ 0, 0, 1, 0, 1 ]; From 678ea55c80798ff4fbe472d1cedb46ecfa30b062 Mon Sep 17 00:00:00 2001 From: Philipp Burckhardt Date: Tue, 27 Feb 2024 19:18:04 -0500 Subject: [PATCH 6/6] Update lib/node_modules/@stdlib/array/base/count-same-value-zero/lib/main.js Signed-off-by: Philipp Burckhardt --- .../@stdlib/array/base/count-same-value-zero/lib/main.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/node_modules/@stdlib/array/base/count-same-value-zero/lib/main.js b/lib/node_modules/@stdlib/array/base/count-same-value-zero/lib/main.js index ed25978b49d..728b0e2849e 100644 --- a/lib/node_modules/@stdlib/array/base/count-same-value-zero/lib/main.js +++ b/lib/node_modules/@stdlib/array/base/count-same-value-zero/lib/main.js @@ -149,7 +149,7 @@ function complex( x, value ) { * var x = [ 0, 0, 1, 0, 1 ]; * * var n = countSameValueZero( x, 1 ); -* // return 2 +* // returns 2 */ function countSameValueZero( x, value ) { if ( isAccessorArray( x, value ) ) {