From eae52da81f573eb2d4e2f5f6cb7d1cd3bfec3d4a Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 1 Jul 2024 19:24:34 +0000 Subject: [PATCH] Auto-generated commit --- .github/workflows/publish.yml | 4 + CHANGELOG.md | 122 ++++++++++++++++++++++- CONTRIBUTORS | 3 +- README.md | 23 +---- benchmark/benchmark.js | 24 ++++- benchmark/benchmark.length.bool.js | 97 ++++++++++++++++++ dist/index.js | 39 +++++++- dist/index.js.map | 6 +- docs/repl.txt | 17 ---- docs/types/index.d.ts | 130 +++---------------------- lib/main.js | 6 +- package.json | 8 +- test/test.js | 151 ++++++++++++++++++++++++++++- 13 files changed, 463 insertions(+), 167 deletions(-) create mode 100644 benchmark/benchmark.length.bool.js diff --git a/.github/workflows/publish.yml b/.github/workflows/publish.yml index ad3a3e0..b1d4bb8 100644 --- a/.github/workflows/publish.yml +++ b/.github/workflows/publish.yml @@ -94,6 +94,10 @@ jobs: # Replace branch in README.md link definitions for badges with the new version: find . -type f -name '*.md' -print0 | xargs -0 sed -Ei "s/branch([=:])[^ ]+/branch\1v${NEW_VERSION}/g" + # Rewrite CHANGELOG.md to replace "Unreleased" with the new version: + sed -Ei "s/Unreleased/${NEW_VERSION}/g" CHANGELOG.md + sed -Ei "s/unreleased/v${NEW_VERSION}/g" CHANGELOG.md + # Create a new commit and tag: git add package.json README.md git commit -m "Release v${NEW_VERSION}" diff --git a/CHANGELOG.md b/CHANGELOG.md index 7e977b7..c9c0b40 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -2,4 +2,124 @@ > Package changelog. -See [GitHub Releases](https://github.com/stdlib-js/array-filled-by/releases) for the changelog. \ No newline at end of file +
+ +## Unreleased (2024-07-01) + +
+ +### Features + +- [`37ca4b7`](https://github.com/stdlib-js/stdlib/commit/37ca4b7ca0d5a2d0553f4d3b0d763d81e38a1bc9) - add boolean dtype support to `array/filled-by` [(#2487)](https://github.com/stdlib-js/stdlib/pull/2487) + +
+ + + +
+ +### Commits + +
+ +- [`37ca4b7`](https://github.com/stdlib-js/stdlib/commit/37ca4b7ca0d5a2d0553f4d3b0d763d81e38a1bc9) - **feat:** add boolean dtype support to `array/filled-by` [(#2487)](https://github.com/stdlib-js/stdlib/pull/2487) _(by Jaysukh Makvana, Athan Reines)_ +- [`75d4f83`](https://github.com/stdlib-js/stdlib/commit/75d4f83cb85610d23a04dc21a03f8075f6d3665f) - **refactor:** update require and include paths _(by Athan Reines)_ + +
+ +
+ + + +
+ +### Contributors + +A total of 2 people contributed to this release. Thank you to the following contributors: + +- Athan Reines +- Jaysukh Makvana + +
+ + + +
+ + + +
+ +## 0.2.1 (2024-02-25) + +
+ +### Features + +- [`e29732d`](https://github.com/stdlib-js/stdlib/commit/e29732dee616e2d94e91f87f78afd8aceb806017) - update minimum TypeScript version + +
+ + + +
+ +### Bug Fixes + +- [`14bacb3`](https://github.com/stdlib-js/stdlib/commit/14bacb3cbfced427bcbadae7cbc649a62bb62b69) - update import path for `Collection` type definition + +
+ + + +
+ +### BREAKING CHANGES + +- [`e29732d`](https://github.com/stdlib-js/stdlib/commit/e29732dee616e2d94e91f87f78afd8aceb806017): update minimum TypeScript version +- [`e29732d`](https://github.com/stdlib-js/stdlib/commit/e29732dee616e2d94e91f87f78afd8aceb806017): update minimum TypeScript version to 4.1 + + - To migrate, users should upgrade their TypeScript version to at least version 4.1. + +
+ + + +
+ +### Commits + +
+ +- [`9758584`](https://github.com/stdlib-js/stdlib/commit/975858483dc5155f126cc472ea9bc681166dfc91) - **refactor:** query default dtype _(by Athan Reines)_ +- [`dea49e0`](https://github.com/stdlib-js/stdlib/commit/dea49e03ab5571233e3da26835a6a6d3256d5737) - **docs:** use single quotes in require calls instead of backticks _(by Philipp Burckhardt)_ +- [`6a9cc0e`](https://github.com/stdlib-js/stdlib/commit/6a9cc0e47fa5783053f8fd2895ea76f5deea0829) - **build:** replace tslint directive with eslint equivalent _(by Philipp Burckhardt)_ +- [`e3fc2d4`](https://github.com/stdlib-js/stdlib/commit/e3fc2d48bf55690a3ead6cc37eed3472f34561c0) - **docs:** update links _(by Athan Reines)_ +- [`3b59a50`](https://github.com/stdlib-js/stdlib/commit/3b59a503252cfe16765f84eab3bdb0ca06f6bb79) - **build:** remove vestiges of tslint directives _(by Philipp Burckhardt)_ +- [`df3c9b3`](https://github.com/stdlib-js/stdlib/commit/df3c9b368d8a3dd7dd38f8768deb53c2a780c055) - **build:** remove tslint directives _(by Philipp Burckhardt)_ +- [`e29732d`](https://github.com/stdlib-js/stdlib/commit/e29732dee616e2d94e91f87f78afd8aceb806017) - **feat:** update minimum TypeScript version _(by Philipp Burckhardt)_ +- [`14bacb3`](https://github.com/stdlib-js/stdlib/commit/14bacb3cbfced427bcbadae7cbc649a62bb62b69) - **fix:** update import path for `Collection` type definition _(by Athan Reines)_ + +
+ +
+ + + +
+ +### Contributors + +A total of 2 people contributed to this release. Thank you to the following contributors: + +- Athan Reines +- Philipp Burckhardt + +
+ + + +
+ + + diff --git a/CONTRIBUTORS b/CONTRIBUTORS index a44d7ac..7ec15a7 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -63,6 +63,7 @@ Pushpendra Chandravanshi Raunak Kumar Gupta Rejoan Sardar <119718513+Rejoan-Sardar@users.noreply.github.com> Ricky Reusser +Ridam Garg <67867319+RidamGarg@users.noreply.github.com> Robert Gislason Roman Stetsyk <25715951+romanstetsyk@users.noreply.github.com> Rutam <138517416+performant23@users.noreply.github.com> @@ -75,7 +76,7 @@ Shraddheya Shendre Shubh Mehta <93862397+Shubh942@users.noreply.github.com> Shubham Mishra Sivam Das <100067002+Sivam2313@users.noreply.github.com> -Snehil Shah <130062020+Snehil-Shah@users.noreply.github.com> +Snehil Shah Soumajit Chatterjee <121816890+soumajit23@users.noreply.github.com> Spandan Barve Stephannie JimĂ©nez Gacha diff --git a/README.md b/README.md index 7b55742..cdee376 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ @license Apache-2.0 -Copyright (c) 2021 The Stdlib Authors. +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. @@ -75,29 +75,14 @@ var filledarrayBy = require( '@stdlib/array-filled-by' ); #### filledarrayBy( \[dtype] ) -Creates a filled array having a specified data type `dtype`. +Creates a filled array having a specified [data type][@stdlib/array/dtypes] `dtype`. ```javascript var arr = filledarrayBy(); // returns ``` -The function recognizes the following data types: - -- `float64`: double-precision floating-point numbers (IEEE 754) -- `float32`: single-precision floating-point numbers (IEEE 754) -- `complex128`: double-precision complex floating-point numbers -- `complex64`: single-precision complex floating-point numbers -- `int32`: 32-bit two's complement signed integers -- `uint32`: 32-bit unsigned integers -- `int16`: 16-bit two's complement signed integers -- `uint16`: 16-bit unsigned integers -- `int8`: 8-bit two's complement signed integers -- `uint8`: 8-bit unsigned integers -- `uint8c`: 8-bit unsigned integers clamped to `0-255` -- `generic`: generic JavaScript values - -By default, the output array data type is `float64` (i.e., a [typed array][mdn-typed-array]). To specify an alternative data type, provide a `dtype` argument. +By default, the output array [data type][@stdlib/array/dtypes] is `float64` (i.e., a [typed array][mdn-typed-array]). To specify an alternative [data type][@stdlib/array/dtypes], provide a `dtype` argument. ```javascript var arr = filledarrayBy( 'int32' ); @@ -362,6 +347,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors]. [mdn-arraybuffer]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/ArrayBuffer +[@stdlib/array/dtypes]: https://github.com/stdlib-js/array-dtypes + [@stdlib/array/filled]: https://github.com/stdlib-js/array-filled diff --git a/benchmark/benchmark.js b/benchmark/benchmark.js index 571faf0..17cfb5a 100644 --- a/benchmark/benchmark.js +++ b/benchmark/benchmark.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2021 The Stdlib Authors. +* 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. @@ -98,6 +98,28 @@ bench( pkg+':dtype=float32', function benchmark( b ) { b.end(); }); +bench( pkg+':dtype=bool', function benchmark( b ) { + var clbk; + var arr; + var i; + + clbk = constantFunction( true ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = filledarrayBy( 0, 'bool', clbk ); + if ( arr.length !== 0 ) { + b.fail( 'should have length 0' ); + } + } + b.toc(); + if ( !isTypedArrayLike( arr ) ) { + b.fail( 'should return a typed array' ); + } + b.pass( 'benchmark finished' ); + b.end(); +}); + bench( pkg+':dtype=complex128', function benchmark( b ) { var clbk; var arr; diff --git a/benchmark/benchmark.length.bool.js b/benchmark/benchmark.length.bool.js new file mode 100644 index 0000000..3cdd152 --- /dev/null +++ b/benchmark/benchmark.length.bool.js @@ -0,0 +1,97 @@ +/** +* @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-harness' ); +var pow = require( '@stdlib/math-base-special-pow' ); +var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' ); +var constantFunction = require( '@stdlib/utils-constant-function' ); +var pkg = require( './../package.json' ).name; +var filledarray = require( './../lib' ); + + +// FUNCTIONS // + +/** +* Creates a benchmark function. +* +* @private +* @param {PositiveInteger} len - array length +* @returns {Function} benchmark function +*/ +function createBenchmark( len ) { + return benchmark; + + /** + * Benchmark function. + * + * @private + * @param {Benchmark} b - benchmark instance + */ + function benchmark( b ) { + var clbk; + var arr; + var i; + + clbk = constantFunction( true ); + + b.tic(); + for ( i = 0; i < b.iterations; i++ ) { + arr = filledarray( len, 'bool', clbk ); + if ( arr.length !== len ) { + b.fail( 'unexpected length' ); + } + } + b.toc(); + if ( !isTypedArrayLike( arr ) ) { + b.fail( 'should return a typed array' ); + } + 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=bool,len='+len, f ); + } +} + +main(); diff --git a/dist/index.js b/dist/index.js index 468e99c..65ae3db 100644 --- a/dist/index.js +++ b/dist/index.js @@ -1,5 +1,36 @@ -"use strict";var k=function(i,e){return function(){return e||i((e={exports:{}}).exports,e),e.exports}};var b=k(function(L,h){ -var d=require('@stdlib/assert-is-string/dist').isPrimitive,p=require('@stdlib/assert-is-nonnegative-integer/dist').isPrimitive,f=require('@stdlib/assert-is-collection/dist'),y=require('@stdlib/assert-is-arraybuffer/dist'),m=require('@stdlib/assert-is-object/dist'),u=require('@stdlib/assert-is-function/dist'),v=require('@stdlib/array-ctors/dist'),M=require('@stdlib/blas-ext-base-gfill-by/dist'),q=require('@stdlib/array-base-filled-by/dist'),j=require('@stdlib/assert-has-iterator-symbol-support/dist'),g=require('@stdlib/symbol-iterator/dist'),V=require('@stdlib/iter-length/dist'),A=require('@stdlib/array-defaults/dist'),o=require('@stdlib/error-tools-fmtprodmsg/dist'),w=j(),c=A.get("dtypes.default");function S(i,e,n){var a,t,l;for(a=[],t=-1;l=i.next(),!l.done;)t+=1,a.push(e.call(n,t));return a}function B(i,e,n){var a;for(a=0;a1)throw new TypeError(o('00h05'));if(t=v(n),t===null)throw new TypeError(o('00h2Y',n));return new t(0)}if(e<2)throw new TypeError(o('00h05'));if(e-=1,u(arguments[e]))if(u(arguments[e-1])){if(i=arguments[e],e-=1,a=arguments[e],e===0)throw new TypeError(o('00h05'))}else a=arguments[e];else if(e>=2){if(i=arguments[e],e-=1,a=arguments[e],!u(a))throw new TypeError(o('00h2b',a))}else throw new TypeError(o('00h05'));if(e-=1,e>=0&&d(arguments[e])?(n=arguments[e],e-=1):n=c,t=v(n),t===null)throw new TypeError(o('00h2Y',n));if(n==="generic"){if(r=arguments[0],e===0){if(p(r)?s=r:f(r)&&(s=r.length),s!==void 0)return q(s,a,i);if(y(r))throw new Error(o('00h04'));if(m(r)){if(w===!1)throw new TypeError(o('00h2Z',r));if(!u(r[g]))throw new TypeError(o('00h2a',r));if(r=r[g](),!u(r.next))throw new TypeError(o('00h2a',r));return S(r,a,i)}throw new TypeError(o('00h2a',r))}else if(y(r))throw new Error(o('00h04'));throw new TypeError(o('00h2a',r))}if(e===0)if(r=arguments[0],f(r))l=new t(r.length);else if(y(r))l=new t(r);else if(p(r))l=new t(r);else if(m(r)){if(w===!1)throw new TypeError(o('00h2Z',r));if(!u(r[g]))throw new TypeError(o('00h2a',r));if(r=r[g](),!u(r.next))throw new TypeError(o('00h2a',r));l=new t(V(r))}else throw new TypeError(o('00h2a',r));else e===1?l=new t(arguments[0],arguments[1]):l=new t(arguments[0],arguments[1],arguments[2]);return l.length>0&&(/^complex/.test(n)?B(l,a,i):M(l.length,l,1,E)),l;function E(O,T){return a.call(i,T)}}h.exports=x -});var I=b();module.exports=I; -/** @license Apache-2.0 */ +"use strict";var k=function(n,e){return function(){return e||n((e={exports:{}}).exports,e),e.exports}};var b=k(function(R,c){"use strict";var p=require("@stdlib/assert-is-string").isPrimitive,d=require("@stdlib/assert-is-nonnegative-integer").isPrimitive,q=require("@stdlib/array-base-assert-is-complex-floating-point-data-type"),M=require("@stdlib/array-base-assert-is-boolean-data-type"),f=require("@stdlib/assert-is-collection"),g=require("@stdlib/assert-is-arraybuffer"),m=require("@stdlib/assert-is-object"),u=require("@stdlib/assert-is-function"),v=require("@stdlib/array-ctors"),j=require("@stdlib/blas-ext-base-gfill-by"),V=require("@stdlib/array-base-filled-by"),A=require("@stdlib/assert-has-iterator-symbol-support"),y=require("@stdlib/symbol-iterator"),B=require("@stdlib/iter-length"),S=require("@stdlib/array-defaults"),o=require("@stdlib/string-format"),w=A(),h=S.get("dtypes.default");function x(n,e,i){var a,t,l;for(a=[],t=-1;l=n.next(),!l.done;)t+=1,a.push(e.call(i,t));return a}function C(n,e,i){var a;for(a=0;a1)throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.");if(t=v(i),t===null)throw new TypeError(o("invalid argument. Must provide a recognized data type. Value: `%s`.",i));return new t(0)}if(e<2)throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.");if(e-=1,u(arguments[e]))if(u(arguments[e-1])){if(n=arguments[e],e-=1,a=arguments[e],e===0)throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.")}else a=arguments[e];else if(e>=2){if(n=arguments[e],e-=1,a=arguments[e],!u(a))throw new TypeError(o("invalid argument. Callback argument must be a function. Value: `%s`.",a))}else throw new TypeError("invalid arguments. Must provide a length, typed array, array-like object, or an iterable.");if(e-=1,e>=0&&p(arguments[e])?(i=arguments[e],e-=1):i=h,t=v(i),t===null)throw new TypeError(o("invalid argument. Must provide a recognized data type. Value: `%s`.",i));if(i==="generic"){if(r=arguments[0],e===0){if(d(r)?s=r:f(r)&&(s=r.length),s!==void 0)return V(s,a,n);if(g(r))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");if(m(r)){if(w===!1)throw new TypeError(o("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",r));if(!u(r[y]))throw new TypeError(o("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));if(r=r[y](),!u(r.next))throw new TypeError(o("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));return x(r,a,n)}throw new TypeError(o("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r))}else if(g(r))throw new Error("invalid arguments. Creating a generic array from an ArrayBuffer is not supported.");throw new TypeError(o("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r))}if(e===0)if(r=arguments[0],f(r))l=new t(r.length);else if(g(r))l=new t(r);else if(d(r))l=new t(r);else if(m(r)){if(w===!1)throw new TypeError(o("invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.",r));if(!u(r[y]))throw new TypeError(o("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));if(r=r[y](),!u(r.next))throw new TypeError(o("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));l=new t(B(r))}else throw new TypeError(o("invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.",r));else e===1?l=new t(arguments[0],arguments[1]):l=new t(arguments[0],arguments[1],arguments[2]);return l.length>0&&(q(i)||M(i)?C(l,a,n):j(l.length,l,1,E)),l;function E(D,T){return a.call(n,T)}}c.exports=I});var O=b();module.exports=O; +/** +* @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. +*/ +/** +* @license Apache-2.0 +* +* Copyright (c) 2021 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. +*/ //# sourceMappingURL=index.js.map diff --git a/dist/index.js.map b/dist/index.js.map index 00888a2..e88f9aa 100644 --- a/dist/index.js.map +++ b/dist/index.js.map @@ -1,7 +1,7 @@ { "version": 3, "sources": ["../lib/main.js", "../lib/index.js"], - "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 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 isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar ctors = require( '@stdlib/array-ctors' );\nvar gfillBy = require( '@stdlib/blas-ext-base-gfill-by' );\nvar filledArray = require( '@stdlib/array-base-filled-by' );\nvar hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' );\nvar ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' );\nvar iterLength = require( '@stdlib/iter-length' );\nvar defaults = require( '@stdlib/array-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\n\n\n// FUNCTIONS //\n\n/**\n* Creates a filled \"generic\" array from an iterator.\n*\n* @private\n* @param {Iterable} it - iterator\n* @param {Callback} clbk - callback function\n* @param {*} thisArg - callback function execution context\n* @returns {Array} filled array\n*/\nfunction filledArrayIterator( it, clbk, thisArg ) {\n\tvar arr;\n\tvar i;\n\tvar v;\n\n\tarr = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tarr.push( clbk.call( thisArg, i ) );\n\t}\n\treturn arr;\n}\n\n/**\n* Fills an array exposing accessors for getting and setting array elements.\n*\n* @private\n* @param {Collection} arr - input array\n* @param {Callback} clbk - callback function\n* @param {*} thisArg - callback function execution context\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, clbk, thisArg ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( clbk.call( thisArg, i ), i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array according to a provided callback function.\n*\n* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @param {string} [dtype=\"float64\"] - data type\n* @param {Callback} [clbk] - callback to invoke\n* @param {*} [thisArg] - callback execution context\n* @throws {TypeError} must provide a recognized data type\n* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable\n* @throws {TypeError} callback argument must be a function.\n* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array)} array or typed array\n*\n* @example\n* var arr = filledarrayBy();\n* // returns \n*\n* @example\n* function clbk() {\n* return 1.0;\n* }\n*\n* var arr = filledarrayBy( 2, clbk );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* function clbk() {\n* return 1.0;\n* }\n*\n* var arr = filledarrayBy( 2, 'float32', clbk );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* function clbk() {\n* return 1.0;\n* }\n*\n* var arr = filledarrayBy( 2, 'generic', clbk );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* function clbk() {\n* return 1.0;\n* }\n*\n* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* function clbk() {\n* return 1;\n* }\n*\n* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk );\n* // returns [ 1, 1 ]\n*\n* @example\n* function clbk1() {\n* return 10;\n* }\n*\n* function clbk2() {\n* return 1.0;\n* }\n*\n* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 );\n* var arr2 = filledarrayBy( arr1, clbk2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* function clbk1() {\n* return 1.0;\n* }\n*\n* function clbk2() {\n* return 2;\n* }\n*\n* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 );\n* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 );\n* // returns [ 2, 2 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* function clbk() {\n* return 1.0;\n* }\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarrayBy( buf, clbk );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* function clbk() {\n* return 1.0;\n* }\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarrayBy( buf, 'float32', clbk );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* function clbk() {\n* return 1.0;\n* }\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarrayBy( buf, 8, clbk );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* function clbk() {\n* return 1.0;\n* }\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarrayBy( buf, 8, 'float32', clbk );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* function clbk() {\n* return 1.0;\n* }\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarrayBy( buf, 8, 2, clbk );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* function clbk() {\n* return 1;\n* }\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk );\n* // returns [ 1, 1 ]\n*/\nfunction filledarrayBy() {\n\tvar thisArg;\n\tvar nargs;\n\tvar dtype;\n\tvar clbk;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\n\n\t// If we weren't provided any arguments, return an empty array...\n\tif ( nargs === 0 ) {\n\t\tctor = ctors( DEFAULT_DTYPE );\n\t\treturn new ctor( 0 );\n\t}\n\t// Check if we were provided a dtype as the first argument...\n\tdtype = arguments[ 0 ];\n\tif ( isString( dtype ) ) {\n\t\t// Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)...\n\t\tif ( nargs > 1 ) {\n\t\t\tthrow new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) );\n\t\t}\n\t\t// Return an empty array having the specified dtype:\n\t\treturn new ctor( 0 );\n\t}\n\t// For all other supported invocations, we need at least two arguments...\n\tif ( nargs < 2 ) {\n\t\tthrow new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' );\n\t}\n\t// At this point, we need to do some argument juggling...\n\tnargs -= 1; // henceforth, the number of available arguments is `nargs+1`\n\n\t// Determine whether the last argument is a callback or \"this\" context...\n\tif ( isFunction( arguments[ nargs ] ) ) {\n\t\t// If the last argument is a function, we need to check the next-to-last argument, and, if the next-to-last argument is a function, assume that the next-to-last argument is the callback and the last argument is a \"this\" context...\n\t\tif ( isFunction( arguments[ nargs-1 ] ) ) {\n\t\t\tthisArg = arguments[ nargs ];\n\t\t\tnargs -= 1;\n\t\t\tclbk = arguments[ nargs ];\n\n\t\t\t// Check if we were provided only a callback and a \"this\" context..\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\tthrow new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' );\n\t\t\t}\n\t\t} else {\n\t\t\t// \"this\" context is left undefined...\n\t\t\tclbk = arguments[ nargs ];\n\t\t}\n\t}\n\t// If we were provided 3 or more arguments and the last argument was not a function, assume that we were provided a callback and a \"this\" context...\n\telse if ( nargs >= 2 ) {\n\t\tthisArg = arguments[ nargs ];\n\t\tnargs -= 1;\n\t\tclbk = arguments[ nargs ];\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t}\n\t// If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments...\n\telse {\n\t\tthrow new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' );\n\t}\n\t// Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument...\n\tnargs -= 1;\n\tif ( nargs >= 0 && isString( arguments[ nargs ] ) ) {\n\t\tdtype = arguments[ nargs ];\n\t\tnargs -= 1;\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\t// At this point, we've resolved the output array data type, and now we can actually create the output array...\n\tif ( dtype === 'generic' ) {\n\t\targ = arguments[ 0 ];\n\t\tif ( nargs === 0 ) {\n\t\t\tif ( isNonNegativeInteger( arg ) ) {\n\t\t\t\tlen = arg;\n\t\t\t} else if ( isCollection( arg ) ) {\n\t\t\t\tlen = arg.length;\n\t\t\t}\n\t\t\tif ( len !== void 0 ) {\n\t\t\t\treturn filledArray( len, clbk, thisArg );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' );\n\t\t\t}\n\t\t\tif ( isObject( arg ) ) {\n\t\t\t\tif ( HAS_ITERATOR_SYMBOL === false ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\targ = arg[ ITERATOR_SYMBOL ]();\n\t\t\t\tif ( !isFunction( arg.next ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledArrayIterator( arg, clbk, thisArg );\n\t\t\t}\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' );\n\t\t}\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t}\n\tif ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 0 ];\n\t\tif ( isCollection( arg ) ) {\n\t\t\tarr = new ctor( arg.length );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tarr = new ctor( arg );\n\t\t} else if ( isNonNegativeInteger( arg ) ) {\n\t\t\tarr = new ctor( arg );\n\t\t} else if ( isObject( arg ) ) {\n\t\t\tif ( HAS_ITERATOR_SYMBOL === false ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\targ = arg[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( arg.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t}\n\t} else if ( nargs === 1 ) {\n\t\tarr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[0], arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( /^complex/.test( dtype ) ) {\n\t\t\tfilledAccessors( arr, clbk, thisArg );\n\t\t} else {\n\t\t\tgfillBy( arr.length, arr, 1, callback );\n\t\t}\n\t}\n\treturn arr;\n\n\t/**\n\t* Callback which wraps a provided callback and is invoked for each array element.\n\t*\n\t* @private\n\t* @param {*} value - element value\n\t* @param {NonNegativeInteger} aidx - array index\n\t* @param {NonNegativeInteger} sidx - strided index\n\t* @param {Collection} array - input array/collection\n\t* @returns {*} callback return value\n\t*/\n\tfunction callback( value, aidx ) {\n\t\treturn clbk.call( thisArg, aidx );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = filledarrayBy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 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* Create a filled array according to a provided callback function.\n*\n* @module @stdlib/array-filled-by\n*\n* @example\n* var filledarrayBy = require( '@stdlib/array-filled-by' );\n*\n* var arr = filledarrayBy();\n* // returns \n*\n* @example\n* var filledarrayBy = require( '@stdlib/array-filled-by' );\n*\n* function clbk() {\n* return 1.0;\n* }\n*\n* var arr = filledarrayBy( 2, clbk );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarrayBy = require( '@stdlib/array-filled-by' );\n*\n* function clbk() {\n* return 1.0;\n* }\n*\n* var arr = filledarrayBy( 2, 'float32', clbk );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarrayBy = require( '@stdlib/array-filled-by' );\n*\n* function clbk() {\n* return 1.0;\n* }\n*\n* var arr = filledarrayBy( 2, 'generic', clbk );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarrayBy = require( '@stdlib/array-filled-by' );\n*\n* function clbk() {\n* return 1.0;\n* }\n*\n* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarrayBy = require( '@stdlib/array-filled-by' );\n*\n* function clbk() {\n* return 1;\n* }\n*\n* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk );\n* // returns [ 1, 1 ]\n*\n* @example\n* var filledarrayBy = require( '@stdlib/array-filled-by' );\n*\n* function clbk1() {\n* return 10;\n* }\n*\n* function clbk2() {\n* return 1.0;\n* }\n*\n* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 );\n* var arr2 = filledarrayBy( arr1, clbk2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarrayBy = require( '@stdlib/array-filled-by' );\n*\n* function clbk1() {\n* return 1.0;\n* }\n*\n* function clbk2() {\n* return 2;\n* }\n*\n* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 );\n* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 );\n* // returns [ 2, 2 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarrayBy = require( '@stdlib/array-filled-by' );\n*\n* function clbk() {\n* return 1.0;\n* }\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarrayBy( buf, clbk );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarrayBy = require( '@stdlib/array-filled-by' );\n*\n* function clbk() {\n* return 1.0;\n* }\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarrayBy( buf, 'float32', clbk );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarrayBy = require( '@stdlib/array-filled-by' );\n*\n* function clbk() {\n* return 1.0;\n* }\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarrayBy( buf, 8, clbk );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarrayBy = require( '@stdlib/array-filled-by' );\n*\n* function clbk() {\n* return 1.0;\n* }\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarrayBy( buf, 8, 'float32', clbk );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarrayBy = require( '@stdlib/array-filled-by' );\n*\n* function clbk() {\n* return 1.0;\n* }\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarrayBy( buf, 8, 2, clbk );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarrayBy = require( '@stdlib/array-filled-by' );\n*\n* function clbk() {\n* return 1;\n* }\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk );\n* // returns [ 1, 1 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], - "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,0BAA2B,EAAE,YACjDC,EAAuB,QAAS,uCAAwC,EAAE,YAC1EC,EAAe,QAAS,8BAA+B,EACvDC,EAAgB,QAAS,+BAAgC,EACzDC,EAAW,QAAS,0BAA2B,EAC/CC,EAAa,QAAS,4BAA6B,EACnDC,EAAQ,QAAS,qBAAsB,EACvCC,EAAU,QAAS,gCAAiC,EACpDC,EAAc,QAAS,8BAA+B,EACtDC,EAA2B,QAAS,4CAA6C,EACjFC,EAAkB,QAAS,yBAA0B,EACrDC,EAAa,QAAS,qBAAsB,EAC5CC,EAAW,QAAS,wBAAyB,EAC7CC,EAAS,QAAS,uBAAwB,EAK1CC,EAAsBL,EAAyB,EAC/CM,EAAgBH,EAAS,IAAK,gBAAiB,EAcnD,SAASI,EAAqBC,EAAIC,EAAMC,EAAU,CACjD,IAAIC,EACAC,EACAC,EAIJ,IAFAF,EAAM,CAAC,EACPC,EAAI,GAEHC,EAAIL,EAAG,KAAK,EACP,CAAAK,EAAE,MAGPD,GAAK,EACLD,EAAI,KAAMF,EAAK,KAAMC,EAASE,CAAE,CAAE,EAEnC,OAAOD,CACR,CAWA,SAASG,EAAiBH,EAAKF,EAAMC,EAAU,CAC9C,IAAIE,EACJ,IAAMA,EAAI,EAAGA,EAAID,EAAI,OAAQC,IAC5BD,EAAI,IAAKF,EAAK,KAAMC,EAASE,CAAE,EAAGA,CAAE,EAErC,OAAOD,CACR,CA4JA,SAASI,GAAgB,CACxB,IAAIL,EACAM,EACAC,EACAR,EACAS,EACAP,EACAQ,EACAC,EAKJ,GAHAJ,E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AAQ,wGAAyGgB,CAAI,CAAE,EAE7IT,EAAM,IAAIO,EAAMhB,EAAYkB,CAAI,CAAE,CACnC,KACC,OAAM,IAAI,UAAWhB,EAAQ,wGAAyGgB,CAAI,CAAE,OAElIJ,IAAU,EACrBL,EAAM,IAAIO,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,EAE3CP,EAAM,IAAIO,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,EAE1D,OAAKP,EAAI,OAAS,IACZ,WAAW,KAAMM,CAAM,EAC3BH,EAAiBH,EAAKF,EAAMC,CAAQ,EAEpCZ,EAASa,EAAI,OAAQA,EAAK,EAAGU,CAAS,GAGjCV,EAYP,SAASU,EAAUC,EAAOC,EAAO,CAChC,OAAOd,EAAK,KAAMC,EAASa,CAAK,CACjC,CACD,CAKAjC,EAAO,QAAUyB,ICnOjB,IAAIS,EAAO,IAKX,OAAO,QAAUA", - "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "isNonNegativeInteger", "isCollection", "isArrayBuffer", "isObject", "isFunction", "ctors", "gfillBy", "filledArray", "hasIteratorSymbolSupport", "ITERATOR_SYMBOL", "iterLength", "defaults", "format", "HAS_ITERATOR_SYMBOL", "DEFAULT_DTYPE", "filledArrayIterator", "it", "clbk", "thisArg", "arr", "i", "v", "filledAccessors", "filledarrayBy", "nargs", "dtype", "ctor", "len", "arg", "callback", "value", "aidx", "main"] + "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 isString = require( '@stdlib/assert-is-string' ).isPrimitive;\nvar isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive;\nvar isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' );\nvar isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' );\nvar isCollection = require( '@stdlib/assert-is-collection' );\nvar isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' );\nvar isObject = require( '@stdlib/assert-is-object' );\nvar isFunction = require( '@stdlib/assert-is-function' );\nvar ctors = require( '@stdlib/array-ctors' );\nvar gfillBy = require( '@stdlib/blas-ext-base-gfill-by' );\nvar filledArray = require( '@stdlib/array-base-filled-by' );\nvar hasIteratorSymbolSupport = require( '@stdlib/assert-has-iterator-symbol-support' );\nvar ITERATOR_SYMBOL = require( '@stdlib/symbol-iterator' );\nvar iterLength = require( '@stdlib/iter-length' );\nvar defaults = require( '@stdlib/array-defaults' );\nvar format = require( '@stdlib/string-format' );\n\n\n// VARIABLES //\n\nvar HAS_ITERATOR_SYMBOL = hasIteratorSymbolSupport();\nvar DEFAULT_DTYPE = defaults.get( 'dtypes.default' );\n\n\n// FUNCTIONS //\n\n/**\n* Creates a filled \"generic\" array from an iterator.\n*\n* @private\n* @param {Iterable} it - iterator\n* @param {Callback} clbk - callback function\n* @param {*} thisArg - callback function execution context\n* @returns {Array} filled array\n*/\nfunction filledArrayIterator( it, clbk, thisArg ) {\n\tvar arr;\n\tvar i;\n\tvar v;\n\n\tarr = [];\n\ti = -1;\n\twhile ( true ) {\n\t\tv = it.next();\n\t\tif ( v.done ) {\n\t\t\tbreak;\n\t\t}\n\t\ti += 1;\n\t\tarr.push( clbk.call( thisArg, i ) );\n\t}\n\treturn arr;\n}\n\n/**\n* Fills an array exposing accessors for getting and setting array elements.\n*\n* @private\n* @param {Collection} arr - input array\n* @param {Callback} clbk - callback function\n* @param {*} thisArg - callback function execution context\n* @returns {Collection} input array\n*/\nfunction filledAccessors( arr, clbk, thisArg ) {\n\tvar i;\n\tfor ( i = 0; i < arr.length; i++ ) {\n\t\tarr.set( clbk.call( thisArg, i ), i );\n\t}\n\treturn arr;\n}\n\n\n// MAIN //\n\n/**\n* Creates a filled array according to a provided callback function.\n*\n* @param {(NonNegativeInteger|TypedArray|ArrayLikeObject|ArrayBuffer|Iterable)} [arg] - a length, typed array, array-like object, buffer, or iterable\n* @param {NonNegativeInteger} [byteOffset=0] - byte offset\n* @param {NonNegativeInteger} [length] - view length\n* @param {string} [dtype=\"float64\"] - data type\n* @param {Callback} [clbk] - callback to invoke\n* @param {*} [thisArg] - callback execution context\n* @throws {TypeError} must provide a recognized data type\n* @throws {TypeError} must provide a length, typed array, array-like object, buffer, or iterable\n* @throws {TypeError} callback argument must be a function.\n* @throws {Error} creating a generic array from an `ArrayBuffer` is not supported\n* @returns {(TypedArray|Array)} array or typed array\n*\n* @example\n* var arr = filledarrayBy();\n* // returns \n*\n* @example\n* function clbk() {\n* return 1.0;\n* }\n*\n* var arr = filledarrayBy( 2, clbk );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* function clbk() {\n* return 1.0;\n* }\n*\n* var arr = filledarrayBy( 2, 'float32', clbk );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* function clbk() {\n* return 1.0;\n* }\n*\n* var arr = filledarrayBy( 2, 'generic', clbk );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* function clbk() {\n* return 1.0;\n* }\n*\n* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* function clbk() {\n* return 1;\n* }\n*\n* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk );\n* // returns [ 1, 1 ]\n*\n* @example\n* function clbk1() {\n* return 10;\n* }\n*\n* function clbk2() {\n* return 1.0;\n* }\n*\n* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 );\n* var arr2 = filledarrayBy( arr1, clbk2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* function clbk1() {\n* return 1.0;\n* }\n*\n* function clbk2() {\n* return 2;\n* }\n*\n* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 );\n* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 );\n* // returns [ 2, 2 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* function clbk() {\n* return 1.0;\n* }\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarrayBy( buf, clbk );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* function clbk() {\n* return 1.0;\n* }\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarrayBy( buf, 'float32', clbk );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* function clbk() {\n* return 1.0;\n* }\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarrayBy( buf, 8, clbk );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* function clbk() {\n* return 1.0;\n* }\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarrayBy( buf, 8, 'float32', clbk );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* function clbk() {\n* return 1.0;\n* }\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarrayBy( buf, 8, 2, clbk );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n*\n* function clbk() {\n* return 1;\n* }\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk );\n* // returns [ 1, 1 ]\n*/\nfunction filledarrayBy() {\n\tvar thisArg;\n\tvar nargs;\n\tvar dtype;\n\tvar clbk;\n\tvar ctor;\n\tvar arr;\n\tvar len;\n\tvar arg;\n\n\tnargs = arguments.length;\n\n\t// If we weren't provided any arguments, return an empty array...\n\tif ( nargs === 0 ) {\n\t\tctor = ctors( DEFAULT_DTYPE );\n\t\treturn new ctor( 0 );\n\t}\n\t// Check if we were provided a dtype as the first argument...\n\tdtype = arguments[ 0 ];\n\tif ( isString( dtype ) ) {\n\t\t// Invoking this function with arguments `f( dtype, clbk[, thisArg] )` is not allowed (otherwise, we'd need to also allow `f( clbk[, thisArg] )`)...\n\t\tif ( nargs > 1 ) {\n\t\t\tthrow new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' );\n\t\t}\n\t\tctor = ctors( dtype );\n\t\tif ( ctor === null ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) );\n\t\t}\n\t\t// Return an empty array having the specified dtype:\n\t\treturn new ctor( 0 );\n\t}\n\t// For all other supported invocations, we need at least two arguments...\n\tif ( nargs < 2 ) {\n\t\tthrow new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' );\n\t}\n\t// At this point, we need to do some argument juggling...\n\tnargs -= 1; // henceforth, the number of available arguments is `nargs+1`\n\n\t// Determine whether the last argument is a callback or \"this\" context...\n\tif ( isFunction( arguments[ nargs ] ) ) {\n\t\t// If the last argument is a function, we need to check the next-to-last argument, and, if the next-to-last argument is a function, assume that the next-to-last argument is the callback and the last argument is a \"this\" context...\n\t\tif ( isFunction( arguments[ nargs-1 ] ) ) {\n\t\t\tthisArg = arguments[ nargs ];\n\t\t\tnargs -= 1;\n\t\t\tclbk = arguments[ nargs ];\n\n\t\t\t// Check if we were provided only a callback and a \"this\" context..\n\t\t\tif ( nargs === 0 ) {\n\t\t\t\tthrow new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' );\n\t\t\t}\n\t\t} else {\n\t\t\t// \"this\" context is left undefined...\n\t\t\tclbk = arguments[ nargs ];\n\t\t}\n\t}\n\t// If we were provided 3 or more arguments and the last argument was not a function, assume that we were provided a callback and a \"this\" context...\n\telse if ( nargs >= 2 ) {\n\t\tthisArg = arguments[ nargs ];\n\t\tnargs -= 1;\n\t\tclbk = arguments[ nargs ];\n\t\tif ( !isFunction( clbk ) ) {\n\t\t\tthrow new TypeError( format( 'invalid argument. Callback argument must be a function. Value: `%s`.', clbk ) );\n\t\t}\n\t}\n\t// If were were only provided 2 arguments and the last argument was not a function, we've been provided an insufficient number of arguments...\n\telse {\n\t\tthrow new TypeError( 'invalid arguments. Must provide a length, typed array, array-like object, or an iterable.' );\n\t}\n\t// Now that we've processed the callback arguments, let's continue working backward to see if we've been provided a `dtype` argument...\n\tnargs -= 1;\n\tif ( nargs >= 0 && isString( arguments[ nargs ] ) ) {\n\t\tdtype = arguments[ nargs ];\n\t\tnargs -= 1;\n\t} else {\n\t\tdtype = DEFAULT_DTYPE;\n\t}\n\tctor = ctors( dtype );\n\tif ( ctor === null ) {\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a recognized data type. Value: `%s`.', dtype ) );\n\t}\n\t// At this point, we've resolved the output array data type, and now we can actually create the output array...\n\tif ( dtype === 'generic' ) {\n\t\targ = arguments[ 0 ];\n\t\tif ( nargs === 0 ) {\n\t\t\tif ( isNonNegativeInteger( arg ) ) {\n\t\t\t\tlen = arg;\n\t\t\t} else if ( isCollection( arg ) ) {\n\t\t\t\tlen = arg.length;\n\t\t\t}\n\t\t\tif ( len !== void 0 ) {\n\t\t\t\treturn filledArray( len, clbk, thisArg );\n\t\t\t}\n\t\t\tif ( isArrayBuffer( arg ) ) {\n\t\t\t\tthrow new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' );\n\t\t\t}\n\t\t\tif ( isObject( arg ) ) {\n\t\t\t\tif ( HAS_ITERATOR_SYMBOL === false ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\targ = arg[ ITERATOR_SYMBOL ]();\n\t\t\t\tif ( !isFunction( arg.next ) ) {\n\t\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t\t}\n\t\t\t\treturn filledArrayIterator( arg, clbk, thisArg );\n\t\t\t}\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tthrow new Error( 'invalid arguments. Creating a generic array from an ArrayBuffer is not supported.' );\n\t\t}\n\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t}\n\tif ( nargs === 0 ) { // length || array-like || ArrayBuffer || iterable\n\t\targ = arguments[ 0 ];\n\t\tif ( isCollection( arg ) ) {\n\t\t\tarr = new ctor( arg.length );\n\t\t} else if ( isArrayBuffer( arg ) ) {\n\t\t\tarr = new ctor( arg );\n\t\t} else if ( isNonNegativeInteger( arg ) ) {\n\t\t\tarr = new ctor( arg );\n\t\t} else if ( isObject( arg ) ) {\n\t\t\tif ( HAS_ITERATOR_SYMBOL === false ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Environment lacks Symbol.iterator support. Must provide a length, typed array, or array-like object. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\tif ( !isFunction( arg[ ITERATOR_SYMBOL ] ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\targ = arg[ ITERATOR_SYMBOL ]();\n\t\t\tif ( !isFunction( arg.next ) ) {\n\t\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t\t}\n\t\t\tarr = new ctor( iterLength( arg ) );\n\t\t} else {\n\t\t\tthrow new TypeError( format( 'invalid argument. Must provide a length, typed array, array-like object, or an iterable. Value: `%s`.', arg ) );\n\t\t}\n\t} else if ( nargs === 1 ) {\n\t\tarr = new ctor( arguments[0], arguments[1] ); // (ArrayBuffer, byteOffset)\n\t} else {\n\t\tarr = new ctor( arguments[0], arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset, length)\n\t}\n\tif ( arr.length > 0 ) {\n\t\tif ( isComplexDataType( dtype ) || isBooleanDataType( dtype ) ) {\n\t\t\tfilledAccessors( arr, clbk, thisArg );\n\t\t} else {\n\t\t\tgfillBy( arr.length, arr, 1, callback );\n\t\t}\n\t}\n\treturn arr;\n\n\t/**\n\t* Callback which wraps a provided callback and is invoked for each array element.\n\t*\n\t* @private\n\t* @param {*} value - element value\n\t* @param {NonNegativeInteger} aidx - array index\n\t* @param {NonNegativeInteger} sidx - strided index\n\t* @param {Collection} array - input array/collection\n\t* @returns {*} callback return value\n\t*/\n\tfunction callback( value, aidx ) {\n\t\treturn clbk.call( thisArg, aidx );\n\t}\n}\n\n\n// EXPORTS //\n\nmodule.exports = filledarrayBy;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 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* Create a filled array according to a provided callback function.\n*\n* @module @stdlib/array-filled-by\n*\n* @example\n* var filledarrayBy = require( '@stdlib/array-filled-by' );\n*\n* var arr = filledarrayBy();\n* // returns \n*\n* @example\n* var filledarrayBy = require( '@stdlib/array-filled-by' );\n*\n* function clbk() {\n* return 1.0;\n* }\n*\n* var arr = filledarrayBy( 2, clbk );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarrayBy = require( '@stdlib/array-filled-by' );\n*\n* function clbk() {\n* return 1.0;\n* }\n*\n* var arr = filledarrayBy( 2, 'float32', clbk );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarrayBy = require( '@stdlib/array-filled-by' );\n*\n* function clbk() {\n* return 1.0;\n* }\n*\n* var arr = filledarrayBy( 2, 'generic', clbk );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarrayBy = require( '@stdlib/array-filled-by' );\n*\n* function clbk() {\n* return 1.0;\n* }\n*\n* var arr = filledarrayBy( [ 0.5, 0.5 ], clbk );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarrayBy = require( '@stdlib/array-filled-by' );\n*\n* function clbk() {\n* return 1;\n* }\n*\n* var arr = filledarrayBy( [ 5, -3 ], 'int32', clbk );\n* // returns [ 1, 1 ]\n*\n* @example\n* var filledarrayBy = require( '@stdlib/array-filled-by' );\n*\n* function clbk1() {\n* return 10;\n* }\n*\n* function clbk2() {\n* return 1.0;\n* }\n*\n* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 );\n* var arr2 = filledarrayBy( arr1, clbk2 );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var filledarrayBy = require( '@stdlib/array-filled-by' );\n*\n* function clbk1() {\n* return 1.0;\n* }\n*\n* function clbk2() {\n* return 2;\n* }\n*\n* var arr1 = filledarrayBy( [ 5, 3 ], 'int32', clbk1 );\n* var arr2 = filledarrayBy( arr1, 'uint32', clbk2 );\n* // returns [ 2, 2 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarrayBy = require( '@stdlib/array-filled-by' );\n*\n* function clbk() {\n* return 1.0;\n* }\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarrayBy( buf, clbk );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarrayBy = require( '@stdlib/array-filled-by' );\n*\n* function clbk() {\n* return 1.0;\n* }\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarrayBy( buf, 'float32', clbk );\n* // returns [ 1.0, 1.0, 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarrayBy = require( '@stdlib/array-filled-by' );\n*\n* function clbk() {\n* return 1.0;\n* }\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarrayBy( buf, 8, clbk );\n* // returns [ 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarrayBy = require( '@stdlib/array-filled-by' );\n*\n* function clbk() {\n* return 1.0;\n* }\n*\n* var buf = new ArrayBuffer( 16 );\n* var arr = filledarrayBy( buf, 8, 'float32', clbk );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarrayBy = require( '@stdlib/array-filled-by' );\n*\n* function clbk() {\n* return 1.0;\n* }\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarrayBy( buf, 8, 2, clbk );\n* // returns [ 1.0, 1.0 ]\n*\n* @example\n* var ArrayBuffer = require( '@stdlib/array-buffer' );\n* var filledarrayBy = require( '@stdlib/array-filled-by' );\n*\n* function clbk() {\n* return 1;\n* }\n*\n* var buf = new ArrayBuffer( 32 );\n* var arr = filledarrayBy( buf, 8, 2, 'int32', clbk );\n* // returns [ 1, 1 ]\n*/\n\n// MODULES //\n\nvar main = require( './main.js' );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"], + "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAW,QAAS,0BAA2B,EAAE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EAAM,IAAIO,EAAM,UAAU,CAAC,EAAG,UAAU,CAAC,EAAG,UAAU,CAAC,CAAE,EAE1D,OAAKP,EAAI,OAAS,IACZpB,EAAmB0B,CAAM,GAAKzB,EAAmByB,CAAM,EAC3DH,EAAiBH,EAAKF,EAAMC,CAAQ,EAEpCZ,EAASa,EAAI,OAAQA,EAAK,EAAGU,CAAS,GAGjCV,EAYP,SAASU,EAAUC,EAAOC,EAAO,CAChC,OAAOd,EAAK,KAAMC,EAASa,CAAK,CACjC,CACD,CAKAnC,EAAO,QAAU2B,ICrOjB,IAAIS,EAAO,IAKX,OAAO,QAAUA", + "names": ["require_main", "__commonJSMin", "exports", "module", "isString", "isNonNegativeInteger", "isComplexDataType", "isBooleanDataType", "isCollection", "isArrayBuffer", "isObject", "isFunction", "ctors", "gfillBy", "filledArray", "hasIteratorSymbolSupport", "ITERATOR_SYMBOL", "iterLength", "defaults", "format", "HAS_ITERATOR_SYMBOL", "DEFAULT_DTYPE", "filledArrayIterator", "it", "clbk", "thisArg", "arr", "i", "v", "filledAccessors", "filledarrayBy", "nargs", "dtype", "ctor", "len", "arg", "callback", "value", "aidx", "main"] } diff --git a/docs/repl.txt b/docs/repl.txt index 5a68984..06f3146 100644 --- a/docs/repl.txt +++ b/docs/repl.txt @@ -2,23 +2,6 @@ {{alias}}( [dtype] ) Creates a filled array. - The function supports the following data types: - - - float64: double-precision floating-point numbers (IEEE 754) - - float32: single-precision floating-point numbers (IEEE 754) - - complex128: double-precision complex floating-point numbers - - complex64: single-precision complex floating-point numbers - - int32: 32-bit two's complement signed integers - - uint32: 32-bit unsigned integers - - int16: 16-bit two's complement signed integers - - uint16: 16-bit unsigned integers - - int8: 8-bit two's complement signed integers - - uint8: 8-bit unsigned integers - - uint8c: 8-bit unsigned integers clamped to 0-255 - - generic: generic JavaScript values - - The default array data type is `float64`. - Parameters ---------- dtype: string (optional) diff --git a/docs/types/index.d.ts b/docs/types/index.d.ts index b1fd829..5b42a1d 100644 --- a/docs/types/index.d.ts +++ b/docs/types/index.d.ts @@ -1,7 +1,7 @@ /* * @license Apache-2.0 * -* Copyright (c) 2021 The Stdlib Authors. +* 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. @@ -20,13 +20,13 @@ /// -import { Collection, RealOrComplexTypedArray, DataType } from '@stdlib/types/array'; +import { Collection, RealOrComplexTypedArray, BooleanArray, DataType } from '@stdlib/types/array'; import { IterableIterator } from '@stdlib/types/iter'; /** * Array or typed array. */ -type ArrayOrTypedArray = Array | RealOrComplexTypedArray; +type ArrayOrTypedArray = Array | RealOrComplexTypedArray | BooleanArray; /** * Nullary callback function. @@ -54,21 +54,6 @@ type Callback = Nullary | Unary; /** * Creates a filled array according to a provided callback function and having a specified data type. * -* The function recognizes the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* * @param dtype - data type * @returns filled array * @@ -101,21 +86,6 @@ declare function filledarrayBy( length: number, clbk: Callback, thisArg?: any ): /** * Creates a filled array according to a provided callback function and having a specified `length`. * -* The function recognizes the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* * @param length - array length * @param dtype - data type * @param clbk - callback function @@ -144,26 +114,11 @@ declare function filledarrayBy( length: number, dtype: DataType, clbk: Callback, * var arr = filledarrayBy( [ 5.0, -3.0, 2.0 ], constantFunction( 1.0 ) ); * // returns [ 1.0, 1.0, 1.0 ] */ -declare function filledarrayBy( array: Collection, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; +declare function filledarrayBy( array: Collection, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures /** * Creates a filled array from another `array` according to a provided callback function. * -* The function recognizes the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* * @param array - typed array or array-like object * @param dtype - data type * @param clbk - callback function @@ -176,7 +131,7 @@ declare function filledarrayBy( array: Collection, clbk: Callback, thisArg?: any * var arr = filledarrayBy( [ 5.0, -3.0, 2.0 ], 'float64', constantFunction( 1.0 ) ); * // returns [ 1.0, 1.0, 1.0 ] */ -declare function filledarrayBy( array: Collection, dtype: DataType, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; +declare function filledarrayBy( array: Collection, dtype: DataType, clbk: Callback, thisArg?: any ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures /** * Creates a filled array from an iterable according to a callback function. @@ -196,26 +151,11 @@ declare function filledarrayBy( array: Collection, dtype: DataType, clbk: Callba * var arr = filledarrayBy( it, constantFunction( 1.0 ) ); * // returns [ 1.0, 1.0, 1.0 ] */ -declare function filledarrayBy( iterable: IterableIterator, callback: Callback, thisArg?: any ): ArrayOrTypedArray; +declare function filledarrayBy( iterable: IterableIterator, callback: Callback, thisArg?: any ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures /** * Creates a filled array from an iterable according to a callback function. * -* The function recognizes the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* * @param iterable - iterable * @param dtype - data type * @param clbk - callback function @@ -232,7 +172,7 @@ declare function filledarrayBy( iterable: IterableIterator, callback: Callback, * var arr = filledarrayBy( it, 'float64', constantFunction( 1.0 ) ); * // returns [ 1.0, 1.0, 1.0 ] */ -declare function filledarrayBy( iterable: IterableIterator, dtype: DataType, callback: Callback, thisArg?: any ): ArrayOrTypedArray; +declare function filledarrayBy( iterable: IterableIterator, dtype: DataType, callback: Callback, thisArg?: any ): ArrayOrTypedArray; // eslint-disable-line @typescript-eslint/unified-signatures /** * Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. @@ -256,25 +196,11 @@ declare function filledarrayBy( iterable: IterableIterator, dtype: DataType, cal * var arr = filledarrayBy( buf, 8, 2, constantFunction( 1.0 ) ); * // returns [ 1.0, 1.0 ] */ -declare function filledarrayBy( buffer: ArrayBuffer, byteOffset: number, length: number, clbk: Callback, thisArg?: any ): RealOrComplexTypedArray; +declare function filledarrayBy( buffer: ArrayBuffer, byteOffset: number, length: number, clbk: Callback, thisArg?: any ): RealOrComplexTypedArray | BooleanArray; /** * Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. * -* The function recognizes the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values * * ## Notes * @@ -296,7 +222,7 @@ declare function filledarrayBy( buffer: ArrayBuffer, byteOffset: number, length: * var arr = filledarrayBy( buf, 8, 2, 'float64', constantFunction( 1.0 ) ); * // returns [ 1.0, 1.0 ] */ -declare function filledarrayBy( buffer: ArrayBuffer, byteOffset: number, length: number, dtype: DataType, clbk: Callback, thisArg?: any ): RealOrComplexTypedArray; +declare function filledarrayBy( buffer: ArrayBuffer, byteOffset: number, length: number, dtype: DataType, clbk: Callback, thisArg?: any ): RealOrComplexTypedArray | BooleanArray; /** * Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. @@ -319,26 +245,11 @@ declare function filledarrayBy( buffer: ArrayBuffer, byteOffset: number, length: * var arr = filledarrayBy( buf, 8, constantFunction( 1.0 ) ); * // returns [ 1.0, 1.0, 1.0 ] */ -declare function filledarrayBy( buffer: ArrayBuffer, byteOffset: number, clbk: Callback, thisArg?: any ): RealOrComplexTypedArray; +declare function filledarrayBy( buffer: ArrayBuffer, byteOffset: number, clbk: Callback, thisArg?: any ): RealOrComplexTypedArray | BooleanArray; /** * Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. * -* The function recognizes the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* * ## Notes * * - Creating a generic array from an `ArrayBuffer` is **not** supported. @@ -358,7 +269,7 @@ declare function filledarrayBy( buffer: ArrayBuffer, byteOffset: number, clbk: C * var arr = filledarrayBy( buf, 8, 'float64', constantFunction( 1.0 ) ); * // returns [ 1.0, 1.0, 1.0 ] */ -declare function filledarrayBy( buffer: ArrayBuffer, byteOffset: number, dtype: DataType, clbk: Callback, thisArg?: any ): RealOrComplexTypedArray; +declare function filledarrayBy( buffer: ArrayBuffer, byteOffset: number, dtype: DataType, clbk: Callback, thisArg?: any ): RealOrComplexTypedArray | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures /** * Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. @@ -380,26 +291,11 @@ declare function filledarrayBy( buffer: ArrayBuffer, byteOffset: number, dtype: * var arr = filledarrayBy( buf, constantFunction( 1.0 ) ); * // returns [ 1.0, 1.0, 1.0, 1.0 ] */ -declare function filledarrayBy( buffer: ArrayBuffer, clbk: Callback, thisArg?: any ): RealOrComplexTypedArray; +declare function filledarrayBy( buffer: ArrayBuffer, clbk: Callback, thisArg?: any ): RealOrComplexTypedArray | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures /** * Returns a filled typed array view of an `ArrayBuffer` according to a provided callback function. * -* The function recognizes the following data types: -* -* - `float64`: double-precision floating-point numbers (IEEE 754) -* - `float32`: single-precision floating-point numbers (IEEE 754) -* - `complex128`: double-precision complex floating-point numbers -* - `complex64`: single-precision complex floating-point numbers -* - `int32`: 32-bit two's complement signed integers -* - `uint32`: 32-bit unsigned integers -* - `int16`: 16-bit two's complement signed integers -* - `uint16`: 16-bit unsigned integers -* - `int8`: 8-bit two's complement signed integers -* - `uint8`: 8-bit unsigned integers -* - `uint8c`: 8-bit unsigned integers clamped to `0-255` -* - `generic`: generic JavaScript values -* * ## Notes * * - Creating a generic array from an `ArrayBuffer` is **not** supported. @@ -418,7 +314,7 @@ declare function filledarrayBy( buffer: ArrayBuffer, clbk: Callback, thisArg?: a * var arr = filledarrayBy( buf, 'float64', constantFunction( 1.0 ) ); * // returns [ 1.0, 1.0, 1.0, 1.0 ] */ -declare function filledarrayBy( buffer: ArrayBuffer, dtype: DataType, clbk: Callback, thisArg?: any ): RealOrComplexTypedArray; +declare function filledarrayBy( buffer: ArrayBuffer, dtype: DataType, clbk: Callback, thisArg?: any ): RealOrComplexTypedArray | BooleanArray; // eslint-disable-line @typescript-eslint/unified-signatures // EXPORTS // diff --git a/lib/main.js b/lib/main.js index 0f134bb..b322cfe 100644 --- a/lib/main.js +++ b/lib/main.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2021 The Stdlib Authors. +* 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. @@ -22,6 +22,8 @@ var isString = require( '@stdlib/assert-is-string' ).isPrimitive; var isNonNegativeInteger = require( '@stdlib/assert-is-nonnegative-integer' ).isPrimitive; +var isComplexDataType = require( '@stdlib/array-base-assert-is-complex-floating-point-data-type' ); +var isBooleanDataType = require( '@stdlib/array-base-assert-is-boolean-data-type' ); var isCollection = require( '@stdlib/assert-is-collection' ); var isArrayBuffer = require( '@stdlib/assert-is-arraybuffer' ); var isObject = require( '@stdlib/assert-is-object' ); @@ -385,7 +387,7 @@ function filledarrayBy() { arr = new ctor( arguments[0], arguments[1], arguments[2] ); // (ArrayBuffer, byteOffset, length) } if ( arr.length > 0 ) { - if ( /^complex/.test( dtype ) ) { + if ( isComplexDataType( dtype ) || isBooleanDataType( dtype ) ) { filledAccessors( arr, clbk, thisArg ); } else { gfillBy( arr.length, arr, 1, callback ); diff --git a/package.json b/package.json index 4d10db8..9d53835 100644 --- a/package.json +++ b/package.json @@ -37,6 +37,8 @@ "url": "https://github.com/stdlib-js/stdlib/issues" }, "dependencies": { + "@stdlib/array-base-assert-is-boolean-data-type": "^0.0.1", + "@stdlib/array-base-assert-is-complex-floating-point-data-type": "^0.2.1", "@stdlib/array-base-filled-by": "^0.2.1", "@stdlib/array-ctors": "^0.2.1", "@stdlib/array-defaults": "^0.2.1", @@ -55,6 +57,7 @@ "@stdlib/error-tools-fmtprodmsg": "^0.2.1" }, "devDependencies": { + "@stdlib/array-bool": "^0.0.1", "@stdlib/array-buffer": "^0.2.1", "@stdlib/array-complex128": "^0.2.1", "@stdlib/array-complex64": "^0.2.1", @@ -72,11 +75,12 @@ "@stdlib/assert-is-array": "^0.2.1", "@stdlib/assert-is-typed-array": "^0.2.1", "@stdlib/assert-is-typed-array-like": "^0.2.1", - "@stdlib/complex-float32-ctor": "github:stdlib-js/complex-float32-ctor#main", - "@stdlib/complex-float64-ctor": "github:stdlib-js/complex-float64-ctor#main", + "@stdlib/complex-float32-ctor": "^0.0.1", + "@stdlib/complex-float64-ctor": "^0.0.1", "@stdlib/iter-constant": "^0.2.1", "@stdlib/math-base-special-pow": "^0.2.1", "@stdlib/random-base-discrete-uniform": "^0.2.1", + "@stdlib/strided-base-reinterpret-boolean": "^0.0.1", "@stdlib/strided-base-reinterpret-complex128": "^0.2.1", "@stdlib/strided-base-reinterpret-complex64": "^0.2.0", "@stdlib/utils-constant-function": "^0.2.1", diff --git a/test/test.js b/test/test.js index 59ff59f..ca0cf25 100644 --- a/test/test.js +++ b/test/test.js @@ -1,7 +1,7 @@ /** * @license Apache-2.0 * -* Copyright (c) 2020 The Stdlib Authors. +* 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. @@ -35,9 +35,11 @@ var Uint8Array = require( '@stdlib/array-uint8' ); var Uint8ClampedArray = require( '@stdlib/array-uint8c' ); var Complex64Array = require( '@stdlib/array-complex64' ); var Complex128Array = require( '@stdlib/array-complex128' ); +var BooleanArray = require( '@stdlib/array-bool' ); var ArrayBuffer = require( '@stdlib/array-buffer' ); var reinterpret64 = require( '@stdlib/strided-base-reinterpret-complex64' ); var reinterpret128 = require( '@stdlib/strided-base-reinterpret-complex128' ); +var reinterpretBoolean = require( '@stdlib/strided-base-reinterpret-boolean' ); var Complex128 = require( '@stdlib/complex-float64-ctor' ); var Complex64 = require( '@stdlib/complex-float32-ctor' ); var instanceOf = require( '@stdlib/assert-instance-of' ); @@ -1829,6 +1831,20 @@ tape( 'the function returns a filled array (dtype=float32)', function test( t ) t.end(); }); +tape( 'the function returns a filled array (dtype=bool)', function test( t ) { + var expected; + var arr; + + expected = new BooleanArray( 0 ); + arr = filledarrayBy( 'bool' ); + + t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); + t.strictEqual( arr.length, 0, 'returns expected value' ); + t.deepEqual( arr, expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns a filled array (dtype=complex128)', function test( t ) { var expected; var arr; @@ -2169,6 +2185,23 @@ tape( 'the function returns a filled array (dtype=float32, length)', function te t.end(); }); +tape( 'the function returns a filled array (dtype=bool, length)', function test( t ) { + var expected; + var clbk; + var arr; + + expected = new Uint8Array( [ 1, 1, 1, 1, 1 ] ); + + clbk = constantFunction( true ); + arr = filledarrayBy( 5, 'bool', clbk ); + + t.strictEqual( instanceOf( arr, BooleanArray ), true, 'returns expected value' ); + t.strictEqual( arr.length, expected.length, 'returns expected value' ); + t.deepEqual( reinterpretBoolean( arr, 0 ), expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns a filled array (dtype=complex128, length)', function test( t ) { var expected; var clbk; @@ -2462,6 +2495,25 @@ tape( 'the function returns a filled array (dtype=float32, array)', function tes t.end(); }); +tape( 'the function returns a filled array (dtype=bool, array)', function test( t ) { + var expected; + var clbk; + var arr; + var out; + + expected = new Uint8Array( [ 0, 0, 0, 0 ] ); + + clbk = constantFunction( false ); + arr = [ 1.0, 2.0, 3.0, 4.0 ]; + out = filledarrayBy( arr, 'bool', clbk ); + + t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns a filled array (dtype=complex128, array)', function test( t ) { var expected; var clbk; @@ -2774,6 +2826,25 @@ tape( 'the function returns a filled array (dtype=float32, typed array)', functi t.end(); }); +tape( 'the function returns a filled array (dtype=bool, typed array)', function test( t ) { + var expected; + var clbk; + var arr; + var out; + + expected = new Uint8Array( [ 1, 1, 1, 1 ] ); + + clbk = constantFunction( true ); + arr = new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ); + out = filledarrayBy( arr, 'bool', clbk ); + + t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns a filled array (dtype=complex128, typed array)', function test( t ) { var expected; var clbk; @@ -3087,6 +3158,25 @@ tape( 'the function returns a filled typed array (dtype=float32, arraybuffer)', t.end(); }); +tape( 'the function returns a filled typed array (dtype=bool, arraybuffer)', function test( t ) { + var expected; + var clbk; + var buf; + var out; + + expected = new Uint8Array( [ 0, 0, 0, 0 ] ); + + clbk = constantFunction( false ); + buf = new ArrayBuffer( 4 ); + out = filledarrayBy( buf, 'bool', clbk ); + + t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns a filled typed array (dtype=complex128, arraybuffer)', function test( t ) { var expected; var clbk; @@ -3401,6 +3491,25 @@ tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, by t.end(); }); +tape( 'the function returns a filled typed array (dtype=bool, arraybuffer, byteoffset)', function test( t ) { + var expected; + var clbk; + var buf; + var out; + + expected = new Uint8Array( [ 1, 1, 1, 1 ] ); + + clbk = constantFunction( true ); + buf = new ArrayBuffer( 6 ); + out = filledarrayBy( buf, 2, 'bool', clbk ); + + t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns a filled typed array (dtype=complex128, arraybuffer, byteoffset)', function test( t ) { var expected; var clbk; @@ -3713,6 +3822,25 @@ tape( 'the function returns a filled typed array (dtype=float32, arraybuffer, by t.end(); }); +tape( 'the function returns a filled typed array (dtype=bool, arraybuffer, byteoffset, length)', function test( t ) { + var expected; + var clbk; + var buf; + var out; + + expected = new Uint8Array( [ 0, 0, 0, 0 ] ); + + clbk = constantFunction( false ); + buf = new ArrayBuffer( 8 ); + out = filledarrayBy( buf, 2, 4, 'bool', clbk ); + + t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns a filled typed array (dtype=complex128, arraybuffer, byteoffset, length)', function test( t ) { var expected; var clbk; @@ -4037,6 +4165,27 @@ tape( 'the function returns a filled array (dtype=float32, iterator)', opts, fun t.end(); }); +tape( 'the function returns a filled array (dtype=bool, iterator)', opts, function test( t ) { + var expected; + var clbk; + var arr; + var out; + + expected = new Uint8Array( [ 1, 1, 1, 1 ] ); + + clbk = constantFunction( true ); + arr = iterConstant( false, { + 'iter': 4 + }); + out = filledarrayBy( arr, 'bool', clbk ); + + t.strictEqual( instanceOf( out, BooleanArray ), true, 'returns expected value' ); + t.strictEqual( out.length, expected.length, 'returns expected value' ); + t.deepEqual( reinterpretBoolean( out, 0 ), expected, 'returns expected value' ); + + t.end(); +}); + tape( 'the function returns a filled array (dtype=complex128, iterator)', opts, function test( t ) { var expected; var clbk;