@stdlib/array-base-count-same-value-zero 0.1.0 → 0.2.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/NOTICE CHANGED
@@ -1 +1 @@
1
- Copyright (c) 2016-2024 The Stdlib Authors.
1
+ Copyright (c) 2016-2026 The Stdlib Authors.
package/README.md CHANGED
@@ -171,7 +171,7 @@ See [LICENSE][stdlib-license].
171
171
 
172
172
  ## Copyright
173
173
 
174
- Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
174
+ Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors].
175
175
 
176
176
  </section>
177
177
 
@@ -184,8 +184,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
184
184
  [npm-image]: http://img.shields.io/npm/v/@stdlib/array-base-count-same-value-zero.svg
185
185
  [npm-url]: https://npmjs.org/package/@stdlib/array-base-count-same-value-zero
186
186
 
187
- [test-image]: https://github.com/stdlib-js/array-base-count-same-value-zero/actions/workflows/test.yml/badge.svg?branch=v0.1.0
188
- [test-url]: https://github.com/stdlib-js/array-base-count-same-value-zero/actions/workflows/test.yml?query=branch:v0.1.0
187
+ [test-image]: https://github.com/stdlib-js/array-base-count-same-value-zero/actions/workflows/test.yml/badge.svg?branch=v0.2.1
188
+ [test-url]: https://github.com/stdlib-js/array-base-count-same-value-zero/actions/workflows/test.yml?query=branch:v0.2.1
189
189
 
190
190
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/array-base-count-same-value-zero/main.svg
191
191
  [coverage-url]: https://codecov.io/github/stdlib-js/array-base-count-same-value-zero?branch=main
@@ -197,8 +197,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
197
197
 
198
198
  -->
199
199
 
200
- [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
201
- [chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
200
+ [chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
201
+ [chat-url]: https://stdlib.zulipchat.com
202
202
 
203
203
  [stdlib]: https://github.com/stdlib-js/stdlib
204
204
 
package/dist/index.js CHANGED
@@ -1,5 +1,5 @@
1
- "use strict";var f=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var v=f(function(Z,s){
2
- var c=require('@stdlib/array-base-assert-is-complex-typed-array/dist'),q=require('@stdlib/assert-is-complex-like/dist'),m=require('@stdlib/complex-real/dist'),p=require('@stdlib/complex-imag/dist'),g=require('@stdlib/strided-base-reinterpret-complex/dist'),l=require('@stdlib/array-base-assert-is-accessor-array/dist'),d=require('@stdlib/array-base-resolve-getter/dist'),u=require('@stdlib/assert-is-same-value-zero/dist');function h(e,r){var i,t;for(i=0,t=0;t<e.length;t++)u(e[t],r)&&(i+=1);return i}function y(e,r){var i,t,n;for(i=d(e),t=0,n=0;n<e.length;n++)u(i(e,n),r)&&(t+=1);return t}function A(e,r){var i,t,n,o,a;if(!q(r))return 0;for(t=m(r),n=p(r),i=g(e,0),o=0,a=0;a<i.length;a+=2)u(i[a],t)&&u(i[a+1],n)&&(o+=1);return o}function C(e,r){return l(e,r)?c(e,r)?A(e,r):y(e,r):h(e,r)}s.exports=C
3
- });var S=v();module.exports=S;
1
+ "use strict";var f=function(r,e){return function(){return e||r((e={exports:{}}).exports,e),e.exports}};var s=f(function(k,v){
2
+ var c=require('@stdlib/array-base-assert-is-complex-typed-array/dist'),q=require('@stdlib/array-base-assert-is-booleanarray/dist'),l=require('@stdlib/assert-is-complex-like/dist'),m=require('@stdlib/assert-is-boolean/dist').isPrimitive,p=require('@stdlib/complex-float64-real/dist'),g=require('@stdlib/complex-float64-imag/dist'),h=require('@stdlib/strided-base-reinterpret-complex/dist'),y=require('@stdlib/strided-base-reinterpret-boolean/dist'),A=require('@stdlib/array-base-assert-is-accessor-array/dist'),d=require('@stdlib/array-base-resolve-getter/dist'),u=require('@stdlib/assert-is-same-value-zero/dist');function B(r,e){var i,n;for(i=0,n=0;n<r.length;n++)u(r[n],e)&&(i+=1);return i}function w(r,e){var i,n,a;for(i=d(r),n=0,a=0;a<r.length;a++)u(i(r,a),e)&&(n+=1);return n}function C(r,e){var i,n,a,t,o;if(!l(e))return 0;for(n=p(e),a=g(e),i=h(r,0),t=0,o=0;o<i.length;o+=2)u(i[o],n)&&u(i[o+1],a)&&(t+=1);return t}function S(r,e){var i,n,a,t;if(!m(e))return 0;for(i=y(r,0),a=e?1:0,n=0,t=0;t<i.length;t++)i[t]===a&&(n+=1);return n}function V(r,e){return A(r)?c(r)?C(r,e):q(r)?S(r,e):w(r,e):B(r,e)}v.exports=V
3
+ });var Z=s();module.exports=Z;
4
4
  /** @license Apache-2.0 */
5
5
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "version": 3,
3
3
  "sources": ["../lib/main.js", "../lib/index.js"],
4
- "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isComplexTypedArray = require( '@stdlib/array-base-assert-is-complex-typed-array' );\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar real = require( '@stdlib/complex-real' );\nvar imag = require( '@stdlib/complex-imag' );\nvar reinterpret = require( '@stdlib/strided-base-reinterpret-complex' );\nvar isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' );\nvar resolveGetter = require( '@stdlib/array-base-resolve-getter' );\nvar isSameValueZero = require( '@stdlib/assert-is-same-value-zero' );\n\n\n// FUNCTIONS //\n\n/**\n* Counts the number of elements in an indexed array that are equal to a specified value.\n*\n* @private\n* @param {Collection} x - input array\n* @param {*} value - search value\n* @returns {NonNegativeInteger} number of elements that are equal to a specified value\n*\n* @example\n* var x = [ 0, 0, 1, 0, 1 ];\n*\n* var n = indexed( x, 0 );\n* // returns 3\n*/\nfunction indexed( x, value ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( isSameValueZero( x[ i ], value ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array that are equal to a specified value.\n*\n* @private\n* @param {Collection} x - input array\n* @param {*} value - search value\n* @returns {NonNegativeInteger} number of elements that are equal to a specified value\n*\n* @example\n* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' );\n*\n* var x = toAccessorArray( [ 0, 0, 1, 0, 1 ] );\n*\n* var n = accessors( x, 0 );\n* // returns 3\n*/\nfunction accessors( x, value ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( isSameValueZero( get( x, i ), value ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in a complex array that are equal to a specified value.\n*\n* @private\n* @param {Collection} x - input array\n* @param {*} value - search value\n* @returns {NonNegativeInteger} number of elements that are equal to a specified value\n*\n* @example\n* var Complex128Array = require( '@stdlib/array-complex128' );\n* var Complex128 = require( '@stdlib/complex-float64' );\n*\n* var x = new Complex128Array( [ 1.0, 2.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0 ] );\n*\n* var n = complex( x, new Complex128( 1.0, 2.0 ) );\n* // returns 1\n*/\nfunction complex( x, value ) {\n\tvar view;\n\tvar re;\n\tvar im;\n\tvar n;\n\tvar i;\n\n\tif ( !isComplexLike( value ) ) {\n\t\treturn 0;\n\t}\n\tre = real( value );\n\tim = imag( value );\n\n\tview = reinterpret( x, 0 );\n\n\tn = 0;\n\tfor ( i = 0; i < view.length; i += 2 ) {\n\t\tif ( isSameValueZero( view[ i ], re ) && isSameValueZero( view[ i+1 ], im ) ) { // eslint-disable-line max-len\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array that are equal to a specified value.\n*\n* ## Notes\n*\n* - The function uses the SameValueZero Algorithm used by `TypedArray` and `ArrayBuffer` constructors, `Map` and `Set` operations, `String.prototype.includes`, and `Array.prototype.includes` since ES2016.\n* - In contrast to an implementation based on the strict equality operator `===`, the function treats `NaNs` as the same value.\n*\n* @param {Collection} x - input array\n* @param {*} value - search value\n* @returns {NonNegativeInteger} number of elements that are equal to a specified value\n*\n* @example\n* var countSameValueZero = require( '@stdlib/array-base-count-same-value-zero' );\n*\n* var x = [ 0, 0, 1, 0, 1 ];\n*\n* var n = countSameValueZero( x, 1 );\n* // returns 2\n*/\nfunction countSameValueZero( x, value ) {\n\tif ( isAccessorArray( x, value ) ) {\n\t\tif ( isComplexTypedArray( x, value ) ) {\n\t\t\treturn complex( x, value );\n\t\t}\n\t\treturn accessors( x, value );\n\t}\n\treturn indexed( x, value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = countSameValueZero;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Count the number of elements in an array that are equal to a specified value.\n*\n* @module @stdlib/array-base-count-same-value-zero\n*\n* @example\n* var countSameValueZero = require( '@stdlib/array-base-count-same-value-zero' );\n*\n* var x = [ 0, 0, 1, 0, 1 ];\n*\n* var n = countSameValueZero( x, 1 );\n* // returns 2\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
5
- "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAsB,QAAS,kDAAmD,EAClFC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAO,QAAS,sBAAuB,EACvCC,EAAO,QAAS,sBAAuB,EACvCC,EAAc,QAAS,0CAA2C,EAClEC,EAAkB,QAAS,6CAA8C,EACzEC,EAAgB,QAAS,mCAAoC,EAC7DC,EAAkB,QAAS,mCAAoC,EAmBnE,SAASC,EAASC,EAAGC,EAAQ,CAC5B,IAAIC,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIH,EAAE,OAAQG,IACrBL,EAAiBE,EAAGG,CAAE,EAAGF,CAAM,IACnCC,GAAK,GAGP,OAAOA,CACR,CAkBA,SAASE,EAAWJ,EAAGC,EAAQ,CAC9B,IAAII,EACAH,EACAC,EAKJ,IAHAE,EAAMR,EAAeG,CAAE,EAEvBE,EAAI,EACEC,EAAI,EAAGA,EAAIH,EAAE,OAAQG,IACrBL,EAAiBO,EAAKL,EAAGG,CAAE,EAAGF,CAAM,IACxCC,GAAK,GAGP,OAAOA,CACR,CAmBA,SAASI,EAASN,EAAGC,EAAQ,CAC5B,IAAIM,EACAC,EACAC,EACAP,EACAC,EAEJ,GAAK,CAACX,EAAeS,CAAM,EAC1B,MAAO,GAQR,IANAO,EAAKf,EAAMQ,CAAM,EACjBQ,EAAKf,EAAMO,CAAM,EAEjBM,EAAOZ,EAAaK,EAAG,CAAE,EAEzBE,EAAI,EACEC,EAAI,EAAGA,EAAII,EAAK,OAAQJ,GAAK,EAC7BL,EAAiBS,EAAMJ,CAAE,EAAGK,CAAG,GAAKV,EAAiBS,EAAMJ,EAAE,CAAE,EAAGM,CAAG,IACzEP,GAAK,GAGP,OAAOA,CACR,CAyBA,SAASQ,EAAoBV,EAAGC,EAAQ,CACvC,OAAKL,EAAiBI,EAAGC,CAAM,EACzBV,EAAqBS,EAAGC,CAAM,EAC3BK,EAASN,EAAGC,CAAM,EAEnBG,EAAWJ,EAAGC,CAAM,EAErBF,EAASC,EAAGC,CAAM,CAC1B,CAKAX,EAAO,QAAUoB,ICtIjB,IAAIC,EAAO,IAKX,OAAO,QAAUA",
6
- "names": ["require_main", "__commonJSMin", "exports", "module", "isComplexTypedArray", "isComplexLike", "real", "imag", "reinterpret", "isAccessorArray", "resolveGetter", "isSameValueZero", "indexed", "x", "value", "n", "i", "accessors", "get", "complex", "view", "re", "im", "countSameValueZero", "main"]
4
+ "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar isComplexTypedArray = require( '@stdlib/array-base-assert-is-complex-typed-array' );\nvar isBooleanArray = require( '@stdlib/array-base-assert-is-booleanarray' );\nvar isComplexLike = require( '@stdlib/assert-is-complex-like' );\nvar isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;\nvar real = require( '@stdlib/complex-float64-real' );\nvar imag = require( '@stdlib/complex-float64-imag' );\nvar reinterpret = require( '@stdlib/strided-base-reinterpret-complex' );\nvar reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );\nvar isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' );\nvar resolveGetter = require( '@stdlib/array-base-resolve-getter' );\nvar isSameValueZero = require( '@stdlib/assert-is-same-value-zero' );\n\n\n// FUNCTIONS //\n\n/**\n* Counts the number of elements in an indexed array that are equal to a specified value.\n*\n* @private\n* @param {Collection} x - input array\n* @param {*} value - search value\n* @returns {NonNegativeInteger} number of elements that are equal to a specified value\n*\n* @example\n* var x = [ 0, 0, 1, 0, 1 ];\n*\n* var n = indexed( x, 0 );\n* // returns 3\n*/\nfunction indexed( x, value ) {\n\tvar n;\n\tvar i;\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( isSameValueZero( x[ i ], value ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in an accessor array that are equal to a specified value.\n*\n* @private\n* @param {Collection} x - input array\n* @param {*} value - search value\n* @returns {NonNegativeInteger} number of elements that are equal to a specified value\n*\n* @example\n* var toAccessorArray = require( '@stdlib/array-base-to-accessor-array' );\n*\n* var x = toAccessorArray( [ 0, 0, 1, 0, 1 ] );\n*\n* var n = accessors( x, 0 );\n* // returns 3\n*/\nfunction accessors( x, value ) {\n\tvar get;\n\tvar n;\n\tvar i;\n\n\tget = resolveGetter( x );\n\n\tn = 0;\n\tfor ( i = 0; i < x.length; i++ ) {\n\t\tif ( isSameValueZero( get( x, i ), value ) ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in a complex array that are equal to a specified value.\n*\n* @private\n* @param {Collection} x - input array\n* @param {*} value - search value\n* @returns {NonNegativeInteger} number of elements that are equal to a specified value\n*\n* @example\n* var Complex128Array = require( '@stdlib/array-complex128' );\n* var Complex128 = require( '@stdlib/complex-float64-ctor' );\n*\n* var x = new Complex128Array( [ 1.0, 2.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0 ] );\n*\n* var n = complex( x, new Complex128( 1.0, 2.0 ) );\n* // returns 1\n*/\nfunction complex( x, value ) {\n\tvar view;\n\tvar re;\n\tvar im;\n\tvar n;\n\tvar i;\n\n\tif ( !isComplexLike( value ) ) {\n\t\treturn 0;\n\t}\n\tre = real( value );\n\tim = imag( value );\n\n\tview = reinterpret( x, 0 );\n\n\tn = 0;\n\tfor ( i = 0; i < view.length; i += 2 ) {\n\t\tif ( isSameValueZero( view[ i ], re ) && isSameValueZero( view[ i+1 ], im ) ) { // eslint-disable-line max-len\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n/**\n* Counts the number of elements in a boolean array that are equal to a specified value.\n*\n* @private\n* @param {Collection} x - input array\n* @param {*} value - search value\n* @returns {NonNegativeInteger} number of elements that are equal to a specified value\n*\n* @example\n* var BooleanArray = require( '@stdlib/array-bool' );\n*\n* var x = new BooleanArray( [ true, false, true, false, true ] );\n*\n* var n = boolean( x, true );\n* // returns 3\n*/\nfunction boolean( x, value ) {\n\tvar view;\n\tvar n;\n\tvar v;\n\tvar i;\n\n\tif ( !isBoolean( value ) ) {\n\t\treturn 0;\n\t}\n\tview = reinterpretBoolean( x, 0 );\n\n\tv = ( value ) ? 1 : 0;\n\tn = 0;\n\tfor ( i = 0; i < view.length; i++ ) {\n\t\tif ( view[ i ] === v ) {\n\t\t\tn += 1;\n\t\t}\n\t}\n\treturn n;\n}\n\n\n// MAIN //\n\n/**\n* Counts the number of elements in an array that are equal to a specified value.\n*\n* ## Notes\n*\n* - The function uses the SameValueZero Algorithm used by `TypedArray` and `ArrayBuffer` constructors, `Map` and `Set` operations, `String.prototype.includes`, and `Array.prototype.includes` since ES2016.\n* - In contrast to an implementation based on the strict equality operator `===`, the function treats `NaNs` as the same value.\n*\n* @param {Collection} x - input array\n* @param {*} value - search value\n* @returns {NonNegativeInteger} number of elements that are equal to a specified value\n*\n* @example\n* var countSameValueZero = require( '@stdlib/array-base-count-same-value-zero' );\n*\n* var x = [ 0, 0, 1, 0, 1 ];\n*\n* var n = countSameValueZero( x, 1 );\n* // returns 2\n*/\nfunction countSameValueZero( x, value ) {\n\tif ( isAccessorArray( x ) ) {\n\t\tif ( isComplexTypedArray( x ) ) {\n\t\t\treturn complex( x, value );\n\t\t}\n\t\tif ( isBooleanArray( x ) ) {\n\t\t\treturn boolean( x, value );\n\t\t}\n\t\treturn accessors( x, value );\n\t}\n\treturn indexed( x, value );\n}\n\n\n// EXPORTS //\n\nmodule.exports = countSameValueZero;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2024 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Count the number of elements in an array that are equal to a specified value.\n*\n* @module @stdlib/array-base-count-same-value-zero\n*\n* @example\n* var countSameValueZero = require( '@stdlib/array-base-count-same-value-zero' );\n*\n* var x = [ 0, 0, 1, 0, 1 ];\n*\n* var n = countSameValueZero( x, 1 );\n* // returns 2\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
5
+ "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAsB,QAAS,kDAAmD,EAClFC,EAAiB,QAAS,2CAA4C,EACtEC,EAAgB,QAAS,gCAAiC,EAC1DC,EAAY,QAAS,2BAA4B,EAAE,YACnDC,EAAO,QAAS,8BAA+B,EAC/CC,EAAO,QAAS,8BAA+B,EAC/CC,EAAc,QAAS,0CAA2C,EAClEC,EAAqB,QAAS,0CAA2C,EACzEC,EAAkB,QAAS,6CAA8C,EACzEC,EAAgB,QAAS,mCAAoC,EAC7DC,EAAkB,QAAS,mCAAoC,EAmBnE,SAASC,EAASC,EAAGC,EAAQ,CAC5B,IAAIC,EACAC,EAGJ,IADAD,EAAI,EACEC,EAAI,EAAGA,EAAIH,EAAE,OAAQG,IACrBL,EAAiBE,EAAGG,CAAE,EAAGF,CAAM,IACnCC,GAAK,GAGP,OAAOA,CACR,CAkBA,SAASE,EAAWJ,EAAGC,EAAQ,CAC9B,IAAII,EACA,EACAF,EAKJ,IAHAE,EAAMR,EAAeG,CAAE,EAEvB,EAAI,EACEG,EAAI,EAAGA,EAAIH,EAAE,OAAQG,IACrBL,EAAiBO,EAAKL,EAAGG,CAAE,EAAGF,CAAM,IACxC,GAAK,GAGP,OAAO,CACR,CAmBA,SAASK,EAASN,EAAGC,EAAQ,CAC5B,IAAIM,EACAC,EACAC,EACAP,EACAC,EAEJ,GAAK,CAACb,EAAeW,CAAM,EAC1B,MAAO,GAQR,IANAO,EAAKhB,EAAMS,CAAM,EACjBQ,EAAKhB,EAAMQ,CAAM,EAEjBM,EAAOb,EAAaM,EAAG,CAAE,EAEzBE,EAAI,EACEC,EAAI,EAAGA,EAAII,EAAK,OAAQJ,GAAK,EAC7BL,EAAiBS,EAAMJ,CAAE,EAAGK,CAAG,GAAKV,EAAiBS,EAAMJ,EAAE,CAAE,EAAGM,CAAG,IACzEP,GAAK,GAGP,OAAOA,CACR,CAkBA,SAASQ,EAASV,EAAGC,EAAQ,CAC5B,IAAIM,EACA,EACAI,EACAR,EAEJ,GAAK,CAACZ,EAAWU,CAAM,EACtB,MAAO,GAMR,IAJAM,EAAOZ,EAAoBK,EAAG,CAAE,EAEhCW,EAAMV,EAAU,EAAI,EACpB,EAAI,EACEE,EAAI,EAAGA,EAAII,EAAK,OAAQJ,IACxBI,EAAMJ,CAAE,IAAMQ,IAClB,GAAK,GAGP,OAAO,CACR,CAyBA,SAASC,EAAoBZ,EAAGC,EAAQ,CACvC,OAAKL,EAAiBI,CAAE,EAClBZ,EAAqBY,CAAE,EACpBM,EAASN,EAAGC,CAAM,EAErBZ,EAAgBW,CAAE,EACfU,EAASV,EAAGC,CAAM,EAEnBG,EAAWJ,EAAGC,CAAM,EAErBF,EAASC,EAAGC,CAAM,CAC1B,CAKAd,EAAO,QAAUyB,ICjLjB,IAAIC,EAAO,IAKX,OAAO,QAAUA",
6
+ "names": ["require_main", "__commonJSMin", "exports", "module", "isComplexTypedArray", "isBooleanArray", "isComplexLike", "isBoolean", "real", "imag", "reinterpret", "reinterpretBoolean", "isAccessorArray", "resolveGetter", "isSameValueZero", "indexed", "x", "value", "n", "i", "accessors", "get", "complex", "view", "re", "im", "boolean", "v", "countSameValueZero", "main"]
7
7
  }
package/lib/main.js CHANGED
@@ -21,10 +21,13 @@
21
21
  // MODULES //
22
22
 
23
23
  var isComplexTypedArray = require( '@stdlib/array-base-assert-is-complex-typed-array' );
24
+ var isBooleanArray = require( '@stdlib/array-base-assert-is-booleanarray' );
24
25
  var isComplexLike = require( '@stdlib/assert-is-complex-like' );
25
- var real = require( '@stdlib/complex-real' );
26
- var imag = require( '@stdlib/complex-imag' );
26
+ var isBoolean = require( '@stdlib/assert-is-boolean' ).isPrimitive;
27
+ var real = require( '@stdlib/complex-float64-real' );
28
+ var imag = require( '@stdlib/complex-float64-imag' );
27
29
  var reinterpret = require( '@stdlib/strided-base-reinterpret-complex' );
30
+ var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' );
28
31
  var isAccessorArray = require( '@stdlib/array-base-assert-is-accessor-array' );
29
32
  var resolveGetter = require( '@stdlib/array-base-resolve-getter' );
30
33
  var isSameValueZero = require( '@stdlib/assert-is-same-value-zero' );
@@ -101,7 +104,7 @@ function accessors( x, value ) {
101
104
  *
102
105
  * @example
103
106
  * var Complex128Array = require( '@stdlib/array-complex128' );
104
- * var Complex128 = require( '@stdlib/complex-float64' );
107
+ * var Complex128 = require( '@stdlib/complex-float64-ctor' );
105
108
  *
106
109
  * var x = new Complex128Array( [ 1.0, 2.0, 0.0, 0.0, 3.0, 4.0, 0.0, 0.0 ] );
107
110
  *
@@ -132,6 +135,43 @@ function complex( x, value ) {
132
135
  return n;
133
136
  }
134
137
 
138
+ /**
139
+ * Counts the number of elements in a boolean array that are equal to a specified value.
140
+ *
141
+ * @private
142
+ * @param {Collection} x - input array
143
+ * @param {*} value - search value
144
+ * @returns {NonNegativeInteger} number of elements that are equal to a specified value
145
+ *
146
+ * @example
147
+ * var BooleanArray = require( '@stdlib/array-bool' );
148
+ *
149
+ * var x = new BooleanArray( [ true, false, true, false, true ] );
150
+ *
151
+ * var n = boolean( x, true );
152
+ * // returns 3
153
+ */
154
+ function boolean( x, value ) {
155
+ var view;
156
+ var n;
157
+ var v;
158
+ var i;
159
+
160
+ if ( !isBoolean( value ) ) {
161
+ return 0;
162
+ }
163
+ view = reinterpretBoolean( x, 0 );
164
+
165
+ v = ( value ) ? 1 : 0;
166
+ n = 0;
167
+ for ( i = 0; i < view.length; i++ ) {
168
+ if ( view[ i ] === v ) {
169
+ n += 1;
170
+ }
171
+ }
172
+ return n;
173
+ }
174
+
135
175
 
136
176
  // MAIN //
137
177
 
@@ -156,10 +196,13 @@ function complex( x, value ) {
156
196
  * // returns 2
157
197
  */
158
198
  function countSameValueZero( x, value ) {
159
- if ( isAccessorArray( x, value ) ) {
160
- if ( isComplexTypedArray( x, value ) ) {
199
+ if ( isAccessorArray( x ) ) {
200
+ if ( isComplexTypedArray( x ) ) {
161
201
  return complex( x, value );
162
202
  }
203
+ if ( isBooleanArray( x ) ) {
204
+ return boolean( x, value );
205
+ }
163
206
  return accessors( x, value );
164
207
  }
165
208
  return indexed( x, value );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/array-base-count-same-value-zero",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
4
  "description": "Count the number of elements in an array that are equal to a specified value.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -30,14 +30,17 @@
30
30
  "url": "https://github.com/stdlib-js/stdlib/issues"
31
31
  },
32
32
  "dependencies": {
33
- "@stdlib/array-base-assert-is-accessor-array": "^0.2.1",
34
- "@stdlib/array-base-assert-is-complex-typed-array": "^0.1.1",
35
- "@stdlib/array-base-resolve-getter": "^0.2.1",
36
- "@stdlib/assert-is-complex-like": "^0.2.1",
37
- "@stdlib/assert-is-same-value-zero": "^0.2.1",
38
- "@stdlib/complex-imag": "^0.2.1",
39
- "@stdlib/complex-real": "^0.2.1",
40
- "@stdlib/strided-base-reinterpret-complex": "^0.1.1"
33
+ "@stdlib/array-base-assert-is-accessor-array": "^0.2.2",
34
+ "@stdlib/array-base-assert-is-booleanarray": "^0.0.2",
35
+ "@stdlib/array-base-assert-is-complex-typed-array": "^0.1.2",
36
+ "@stdlib/array-base-resolve-getter": "^0.2.2",
37
+ "@stdlib/assert-is-boolean": "^0.2.2",
38
+ "@stdlib/assert-is-complex-like": "^0.2.2",
39
+ "@stdlib/assert-is-same-value-zero": "^0.2.2",
40
+ "@stdlib/complex-float64-imag": "^0.1.1",
41
+ "@stdlib/complex-float64-real": "^0.1.1",
42
+ "@stdlib/strided-base-reinterpret-boolean": "^0.0.2",
43
+ "@stdlib/strided-base-reinterpret-complex": "^0.1.2"
41
44
  },
42
45
  "devDependencies": {},
43
46
  "engines": {